Skip to content

Commit 6814de7

Browse files
committed
MNT: lint corrections
1 parent 485e9de commit 6814de7

File tree

3 files changed

+89
-80
lines changed

3 files changed

+89
-80
lines changed

rocketpy/rocket/parachute.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class Parachute:
4646
4747
- The string "apogee" which triggers the parachute at apogee, i.e.,
4848
when the rocket reaches its highest point and starts descending.
49-
49+
5050
- The string "launch + X" where X is a number in seconds. The parachute
5151
will be ejected X seconds after launch (t=0). This is useful for
5252
simulating delay charges that activate at a fixed time from launch.
53-
53+
5454
- The string "burnout + X" where X is a number in seconds. The parachute
5555
will be ejected X seconds after motor burnout. This is useful for
5656
simulating delay charges in motors with delay elements.
@@ -59,8 +59,8 @@ class Parachute:
5959
Trigger function created from the trigger used to evaluate the trigger
6060
condition for the parachute ejection system. It is a callable function
6161
that takes six arguments: Freestream pressure in Pa, Height above
62-
ground level in meters, the state vector of the simulation, sensors
63-
list, current time t, and rocket object. It returns ``True`` if the
62+
ground level in meters, the state vector of the simulation, sensors
63+
list, current time t, and rocket object. It returns ``True`` if the
6464
parachute ejection system should be triggered and ``False`` otherwise.
6565
6666
.. note:
@@ -252,6 +252,7 @@ def triggerfunc(p, h, y, sensors, t=None, rocket=None):
252252

253253
def triggerfunc(p, h, y, sensors, t=None, rocket=None):
254254
return trigger(p, h, y, sensors)
255+
255256
self.triggerfunc = triggerfunc
256257

257258
elif isinstance(trigger, (int, float)):
@@ -266,7 +267,7 @@ def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unuse
266267

267268
elif isinstance(trigger, str):
268269
trigger_lower = trigger.lower().strip()
269-
270+
270271
if trigger_lower == "apogee":
271272
# The parachute is deployed at apogee
272273
def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unused-argument
@@ -276,7 +277,7 @@ def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unuse
276277
return y[5] < 0
277278

278279
self.triggerfunc = triggerfunc
279-
280+
280281
elif "+" in trigger_lower:
281282
# Time-based trigger: "launch + X" or "burnout + X"
282283
parts = trigger_lower.split("+")
@@ -286,7 +287,7 @@ def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unuse
286287
+ "Expected format: 'launch + delay' or 'burnout + delay' "
287288
+ "where delay is a number in seconds."
288289
)
289-
290+
290291
event = parts[0].strip()
291292
try:
292293
delay = float(parts[1].strip())
@@ -295,32 +296,32 @@ def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unuse
295296
f"Invalid delay value in trigger '{trigger}' for parachute '{self.name}'. "
296297
+ "Delay must be a number in seconds."
297298
)
298-
299+
299300
if event == "launch":
300301
# Deploy at launch time + delay
301302
def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unused-argument
302303
if t is None:
303304
return False
304305
return t >= delay
305-
306+
306307
self.triggerfunc = triggerfunc
307-
308+
308309
elif event == "burnout":
309310
# Deploy at motor burnout time + delay
310311
def triggerfunc(p, h, y, sensors, t=None, rocket=None): # pylint: disable=unused-argument
311312
if t is None or rocket is None:
312313
return False
313314
burnout_time = rocket.motor.burn_out_time
314315
return t >= burnout_time + delay
315-
316+
316317
self.triggerfunc = triggerfunc
317-
318+
318319
else:
319320
raise ValueError(
320321
f"Invalid time-based trigger event '{event}' for parachute '{self.name}'. "
321322
+ "Supported events are 'launch' and 'burnout'."
322323
)
323-
324+
324325
else:
325326
raise ValueError(
326327
f"Unable to set the trigger function for parachute '{self.name}'. "

tests/integration/test_parachute_time_trig.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ def test_flight_with_launch_plus_delay_trigger(
1010
example_spaceport_env, calisto_motorless, cesaroni_m1670
1111
):
1212
"""Test a complete flight simulation with a 'launch + X' parachute trigger.
13-
13+
1414
This simulates a rocket with a delay charge that deploys the parachute at a
1515
fixed time after launch, similar to model rockets without avionics.
1616
"""
1717
# Use existing rocket and add motor
1818
rocket = calisto_motorless
1919
rocket.add_motor(cesaroni_m1670, position=-1.373)
20-
20+
2121
# Add a parachute with "launch + 5" trigger (5 seconds after launch)
2222
rocket.add_parachute(
2323
name="Main",
@@ -27,7 +27,7 @@ def test_flight_with_launch_plus_delay_trigger(
2727
lag=1.5,
2828
noise=(0, 8.3, 0.5),
2929
)
30-
30+
3131
# Run flight simulation
3232
flight = Flight(
3333
environment=example_spaceport_env,
@@ -37,15 +37,15 @@ def test_flight_with_launch_plus_delay_trigger(
3737
heading=0,
3838
terminate_on_apogee=False,
3939
)
40-
40+
4141
# Verify that the parachute was deployed at approximately the right time
4242
# The parachute should deploy at t=5s + lag=1.5s = 6.5s (fully deployed)
4343
assert flight.t is not None
44-
44+
4545
# Check that parachute deployment happened (should have parachute_cd_s set)
4646
# This attribute is set when parachute is deployed
4747
assert hasattr(flight, "parachute_cd_s")
48-
48+
4949
# Verify simulation completed successfully
5050
assert flight.apogee_time > 0
5151

@@ -55,17 +55,17 @@ def test_flight_with_burnout_plus_delay_trigger(
5555
example_spaceport_env, calisto_motorless, cesaroni_m1670
5656
):
5757
"""Test a complete flight simulation with a 'burnout + X' parachute trigger.
58-
58+
5959
This simulates a rocket with a motor delay charge that deploys the parachute
6060
at a fixed time after motor burnout, typical of model rocket motors.
6161
"""
6262
# Use existing rocket and add motor
6363
rocket = calisto_motorless
6464
rocket.add_motor(cesaroni_m1670, position=-1.373)
65-
65+
6666
# Get motor burnout time
6767
motor_burnout = rocket.motor.burn_out_time
68-
68+
6969
# Add a parachute with "burnout + 3" trigger (3 seconds after burnout)
7070
rocket.add_parachute(
7171
name="Main",
@@ -75,7 +75,7 @@ def test_flight_with_burnout_plus_delay_trigger(
7575
lag=1.5,
7676
noise=(0, 8.3, 0.5),
7777
)
78-
78+
7979
# Run flight simulation
8080
flight = Flight(
8181
environment=example_spaceport_env,
@@ -85,17 +85,17 @@ def test_flight_with_burnout_plus_delay_trigger(
8585
heading=0,
8686
terminate_on_apogee=False,
8787
)
88-
88+
8989
# Verify that the parachute was deployed
9090
assert flight.t is not None
91-
91+
9292
# Check that parachute deployment happened
9393
assert hasattr(flight, "parachute_cd_s")
94-
94+
9595
# The parachute should deploy after motor burnout + delay
9696
# Expected deployment at burnout_time + 3s + lag
9797
expected_deploy_time = motor_burnout + 3.0 + 1.5
98-
98+
9999
# Verify simulation completed successfully and parachute deployed after burnout
100100
assert flight.apogee_time > 0
101101
# The simulation should run past the expected deployment time
@@ -107,13 +107,13 @@ def test_flight_with_multiple_time_based_parachutes(
107107
example_spaceport_env, calisto_motorless, cesaroni_m1670
108108
):
109109
"""Test a flight with multiple time-based parachutes (drogue and main).
110-
110+
111111
This simulates a dual-deployment system using time-based triggers.
112112
"""
113113
# Use existing rocket and add motor
114114
rocket = calisto_motorless
115115
rocket.add_motor(cesaroni_m1670, position=-1.373)
116-
116+
117117
# Add drogue parachute - deploys at burnout + 2 seconds
118118
rocket.add_parachute(
119119
name="Drogue",
@@ -123,7 +123,7 @@ def test_flight_with_multiple_time_based_parachutes(
123123
lag=0.5,
124124
noise=(0, 8.3, 0.5),
125125
)
126-
126+
127127
# Add main parachute - deploys at burnout + 10 seconds
128128
rocket.add_parachute(
129129
name="Main",
@@ -133,7 +133,7 @@ def test_flight_with_multiple_time_based_parachutes(
133133
lag=1.0,
134134
noise=(0, 8.3, 0.5),
135135
)
136-
136+
137137
# Run flight simulation
138138
flight = Flight(
139139
environment=example_spaceport_env,
@@ -143,11 +143,11 @@ def test_flight_with_multiple_time_based_parachutes(
143143
heading=0,
144144
terminate_on_apogee=False,
145145
)
146-
146+
147147
# Verify simulation completed successfully
148148
assert flight.t is not None
149149
assert flight.apogee_time > 0
150-
150+
151151
# Check that parachute deployment happened
152152
assert hasattr(flight, "parachute_cd_s")
153153

@@ -157,13 +157,13 @@ def test_flight_with_mixed_trigger_types(
157157
example_spaceport_env, calisto_motorless, cesaroni_m1670
158158
):
159159
"""Test a flight with both time-based and traditional parachute triggers.
160-
160+
161161
This ensures backward compatibility when mixing trigger types.
162162
"""
163163
# Use existing rocket and add motor
164164
rocket = calisto_motorless
165165
rocket.add_motor(cesaroni_m1670, position=-1.373)
166-
166+
167167
# Add drogue parachute with traditional apogee trigger
168168
rocket.add_parachute(
169169
name="Drogue",
@@ -173,7 +173,7 @@ def test_flight_with_mixed_trigger_types(
173173
lag=0.5,
174174
noise=(0, 8.3, 0.5),
175175
)
176-
176+
177177
# Add main parachute with altitude trigger
178178
rocket.add_parachute(
179179
name="Main",
@@ -183,7 +183,7 @@ def test_flight_with_mixed_trigger_types(
183183
lag=1.0,
184184
noise=(0, 8.3, 0.5),
185185
)
186-
186+
187187
# Run flight simulation
188188
flight = Flight(
189189
environment=example_spaceport_env,
@@ -193,10 +193,10 @@ def test_flight_with_mixed_trigger_types(
193193
heading=0,
194194
terminate_on_apogee=False,
195195
)
196-
196+
197197
# Verify simulation completed successfully
198198
assert flight.t is not None
199199
assert flight.apogee_time > 0
200-
200+
201201
# Check that parachute deployment happened
202-
assert hasattr(flight, "parachute_cd_s")
202+
assert hasattr(flight, "parachute_cd_s")

0 commit comments

Comments
 (0)