Skip to content

Commit 74d39f5

Browse files
fix tests
1 parent dd80852 commit 74d39f5

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

rocketpy/plots/flight_plots.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,16 @@ def energy_data(self, *, filename=None): # pylint: disable=too-many-statements
656656
ax2.grid()
657657

658658
ax3 = plt.subplot(413)
659+
# Handle both array-based and callable-based Functions
660+
thrust_power = self.flight.thrust_power
661+
if callable(thrust_power.source):
662+
# For callable sources, discretize based on speed
663+
thrust_power = thrust_power.set_discrete_based_on_model(
664+
self.flight.speed, mutate_self=False
665+
)
659666
ax3.plot(
660-
self.flight.thrust_power[:, 0],
661-
self.flight.thrust_power[:, 1],
667+
thrust_power[:, 0],
668+
thrust_power[:, 1],
662669
label="|Thrust Power|",
663670
)
664671
ax3.set_xlim(0, self.flight.rocket.motor.burn_out_time)
@@ -670,9 +677,16 @@ def energy_data(self, *, filename=None): # pylint: disable=too-many-statements
670677
ax3.grid()
671678

672679
ax4 = plt.subplot(414)
680+
# Handle both array-based and callable-based Functions
681+
drag_power = self.flight.drag_power
682+
if callable(drag_power.source):
683+
# For callable sources, discretize based on speed
684+
drag_power = drag_power.set_discrete_based_on_model(
685+
self.flight.speed, mutate_self=False
686+
)
673687
ax4.plot(
674-
self.flight.drag_power[:, 0],
675-
-self.flight.drag_power[:, 1],
688+
drag_power[:, 0],
689+
-drag_power[:, 1],
676690
label="|Drag Power|",
677691
)
678692
ax4.set_xlim(

tests/integration/environment/test_environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def test_merra2_full_specification_compliance(merra2_file_path, example_plain_en
280280
# Input: 9806.65 m2/s2
281281
# Expected: 1000.0 m
282282
print(f"Calculated Elevation: {env.elevation} m")
283-
assert abs(env.elevation - 1000.0) < 1e-6, (
283+
assert abs(env.elevation - 1000.0) < 1e-4, (
284284
f"Failed to convert PHIS (m2/s2) to meters. Got {env.elevation}, expected 1000.0"
285285
)
286286

0 commit comments

Comments
 (0)