# Unexpected results being returned in python example code

**URL:** https://discourse.kitware.com/t/unexpected-results-being-returned-in-python-example-code/1351
**Category:** Pulse Physiology Engine
**Created:** [August 27, 2024, 4:32pm UTC](https://discourse.kitware.com/t/unexpected-results-being-returned-in-python-example-code/1351 "2024-08-27T16:32:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jdyreson](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/j/47e85d/32.png) [@jdyreson](https://discourse.kitware.com/u/jdyreson)
#### Post date: [August 27, 2024, 4:32pm UTC](https://discourse.kitware.com/t/unexpected-results-being-returned-in-python-example-code/1351/1 "2024-08-27T16:32:04Z")

</div>

Hello, I am attempting to get started with integrating the Pulse engine into a Python project. The output I am getting from pulse.pull\_data() and pulse.print\_results() doesn’t make sense to me. All of the values are the same (seems to be SimulationTime). I am hoping there is something obvious I am missing. Below is my code and the output

```auto
def HowTo_Hemorrhage():
    pulse = PulseEngine()
    pulse.set_log_filename("./test_results/howto/HowTo_Hemorrhage.py.log")
    pulse.log_to_console(True)

    # NOTE: No data requests are being provided, so Pulse will return the default vitals data
    if not pulse.serialize_from_file("../../builds/install/bin/states/Soldier@0s.json", None):
        print("Unable to load initial state file")
        return

    # Get default data at time 0s from the engine
    results = pulse.pull_data()
    pulse.print_results()

    # Perform an action
    hemorrhage = SEHemorrhage()
    hemorrhage.set_comment("Laceration to the leg")
    hemorrhage.set_compartment(eHemorrhage_Compartment.RightLeg)
    hemorrhage.get_severity().set_value(0.8)
    # Optionally, You can set the flow rate of the hemorrhage,
    # but this needs to be provided the proper flow rate associated with the anatomy
    # This is implemented as a flow source, this rate will be constant, and will not be affected by dropping blood pressures
    # It is intended to interact with sensors or with something continuously monitoring physiology and updating the flow
    #hemorrhage.get_flow_rate().set_value(75,VolumePerTimeUnit.mL_Per_min)
    pulse.process_action(hemorrhage)

    # Advance some time and print out the vitals
    pulse.advance_time_s(10)
    results = pulse.pull_data()
    pulse.print_results()
    print(results)

    pulse.advance_time_s(10)
    results = pulse.pull_data()
    pulse.print_results()
    print(results)

    pulse.advance_time_s(10)
    results = pulse.pull_data()
    pulse.print_results()
    print(results)

    # For this example, you will see a decrease in blood volume

HowTo_Hemorrhage()

```

[INFO] [0(s)] [SerializingFromFile] …/…/builds/install/bin/states/Soldier@0s.json  
[INFO] [0(s)] Human Adult Whole Body  
[INFO] [0(s)] Version : 4.2.0  
[INFO] [0(s)] GitHash : b5ef23de0  
[INFO] [0(s)] Build Time : Tue Aug 27 17:30:07 2024  
[INFO] [0(s)] Loading state generated from Pulse-4.2.0-b5ef23de0  
[INFO] [0(s)] [SimTime(s)] 0(s)  
SimulationTime(s)=0.0)  
HeartRate(1/min)=0.0  
ArterialPressure(mmHg)=0.0  
MeanArterialPressure(mmHg)=0.0  
SystolicArterialPressure(mmHg)=0.0  
DiastolicArterialPressure(mmHg)=0.0  
OxygenSaturation=0.0  
EndTidalCarbonDioxidePressure(mmHg)=0.0  
RespirationRate(1/min)=0.0  
SkinTemperature(degC)=0.0  
CardiacOutput(L/min)=0.0  
BloodVolume(mL)=0.0  
ECG-Lead3ElectricPotential(mV)=0.0  
Carina-CarbonDioxide-PartialPressure(mmHg)=0.0  
[INFO] [0(s)] [Action]  
{  
“PatientAction”: {  
“Hemorrhage”: {  
“PatientAction”: {  
“Action”: {  
“Comment”: “Laceration to the leg”  
}  
},  
“Compartment”: “RightLeg”,  
“Type”: “External”,  
“Severity”: {  
“Scalar0To1”: {  
“Value”: 0.8,  
“Unit”: “”,  
“ReadOnly”: false  
}  
}  
}  
}  
}

SimulationTime(s)=9.999999999999876)  
HeartRate(1/min)=9.999999999999876  
ArterialPressure(mmHg)=9.999999999999876  
MeanArterialPressure(mmHg)=9.999999999999876  
SystolicArterialPressure(mmHg)=9.999999999999876  
DiastolicArterialPressure(mmHg)=9.999999999999876  
OxygenSaturation=9.999999999999876  
EndTidalCarbonDioxidePressure(mmHg)=9.999999999999876  
RespirationRate(1/min)=9.999999999999876  
SkinTemperature(degC)=9.999999999999876  
CardiacOutput(L/min)=9.999999999999876  
BloodVolume(mL)=9.999999999999876  
ECG-Lead3ElectricPotential(mV)=9.999999999999876  
Carina-CarbonDioxide-PartialPressure(mmHg)=9.999999999999876  
[10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10.]  
SimulationTime(s)=19.999999999999662)  
HeartRate(1/min)=19.999999999999662  
ArterialPressure(mmHg)=19.999999999999662  
MeanArterialPressure(mmHg)=19.999999999999662  
SystolicArterialPressure(mmHg)=19.999999999999662  
DiastolicArterialPressure(mmHg)=19.999999999999662  
OxygenSaturation=19.999999999999662  
EndTidalCarbonDioxidePressure(mmHg)=19.999999999999662  
RespirationRate(1/min)=19.999999999999662  
SkinTemperature(degC)=19.999999999999662  
CardiacOutput(L/min)=19.999999999999662  
BloodVolume(mL)=19.999999999999662  
ECG-Lead3ElectricPotential(mV)=19.999999999999662  
Carina-CarbonDioxide-PartialPressure(mmHg)=19.999999999999662  
[20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20. 20.]  
SimulationTime(s)=29.99999999999945)  
HeartRate(1/min)=29.99999999999945  
ArterialPressure(mmHg)=29.99999999999945  
MeanArterialPressure(mmHg)=29.99999999999945  
SystolicArterialPressure(mmHg)=29.99999999999945  
DiastolicArterialPressure(mmHg)=29.99999999999945  
OxygenSaturation=29.99999999999945  
EndTidalCarbonDioxidePressure(mmHg)=29.99999999999945  
RespirationRate(1/min)=29.99999999999945  
SkinTemperature(degC)=29.99999999999945  
CardiacOutput(L/min)=29.99999999999945  
BloodVolume(mL)=29.99999999999945  
ECG-Lead3ElectricPotential(mV)=29.99999999999945  
Carina-CarbonDioxide-PartialPressure(mmHg)=29.99999999999945  
[30. 30. 30. 30. 30. 30. 30. 30. 30. 30. 30. 30. 30. 30.]

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [August 28, 2024, 2:22pm UTC](https://discourse.kitware.com/t/unexpected-results-being-returned-in-python-example-code/1351/2 "2024-08-28T14:22:58Z")

</div>

Hi @jdyreson

We are about to push out our latest release to the stable branch.  
Would you be able to pull our [latest release updates branch](https://gitlab.kitware.com/physiology/engine/-/tree/feature/release_updates/src?ref_type=heads) and test out the python capabilities there?

I think it should be a bit more well behaived  
Any feedback would be appreciated!
