Commit b516ace
MNT: refactor parachute implementation (#958)
* mnt: refactor parachute implementation
* ENH: introducing parachute plots in flight class and renaming abstract parachute class to BaseParachute
* mnt: making refactoring backwards compatible
* mnt: applying review suggestions
* mnt: add missing parachute.py file
* mnt: remove unnecessary file and update deprecation message
* MNT: polish parachute refactor docs and deprecation
Add changelog entry for PR #958, align Parachute trigger docstrings with the 4-argument runtime signature, and set a concrete deprecation removal target (1.14.0) for legacy add_parachute usage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* MNT: review fixes for parachute refactor
Address review findings on PR #958 (parachute abstract base + hemispherical
model):
- rocket.py: validate that the new `add_parachute(parachute=...)` object path
receives a Parachute subclass instance, raising a clear TypeError instead of
letting a wrong object fail opaquely deep inside the ODE solver.
- parachute.py: fix `__repr__` unit label — `lag` is seconds, was mislabeled
`m2` (copy-paste from the old `cd_s` repr).
- docs/reference: add a `HemisphericalParachute` autodoc page (the concrete
class users instantiate; previously only the abstract base was documented).
- docs notebooks/scripts: fix Monte Carlo examples that called
`Rocket.add_parachute(obj)` positionally — `parachute` is the last kwarg, so
the object bound to `name` and the example crashed. Use
`add_parachute(parachute=obj)`. (StochasticRocket.add_parachute(obj) is
positional and was already correct.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* BUG: save parachute drag info over accepted solution steps
The refactored parachute implementation saved each parachute's dynamic
information (``parachutes_info``, e.g. drag vs. time) from inside
``u_dot_parachute`` during the raw integration. Because the ODE solver
evaluates the derivative at internal RK stages and rejected steps, the
stored time series was non-monotonic, contained points that did not match
the accepted trajectory and even extended past ``t_final``.
Move the ``add_information_to_flight`` call to the post-processing branch,
which replays the derivatives over the accepted ``solution`` steps only, so
the recorded drag now matches the flight trajectory one-to-one.
Since post-processing is evaluated lazily, ``FlightPlots.parachutes_info``
now forces it before reading the data so the plot still works when called
standalone.
* BUG: fix parachute refactor integration issues found in review
- tests/unit/test_parachute_triggers.py (added on develop) still imported
the pre-refactor module `rocketpy.rocket.parachute` and instantiated the
now-abstract `Parachute` directly, which errored at collection time after
the merge. Point it at `HemisphericalParachute` / the new package path.
- FlightPlots.parachutes_info(name): the single-parachute branch indexed
`parachutes_info[name]` directly and raised KeyError when the named
parachute never deployed (or the name was misspelled). Unify the two
duplicated branches and print a helpful message listing the available
parachutes instead.
- Flight.to_dict serializes `parachutes_info`, but the decoder's
set_minimal_flight_attributes never restored it, so parachute drag data
was silently dropped on every .rpy/JSON round-trip. Add it to the
restored attribute list (guarded by the existing KeyError handling for
older files).
* MNT: make Parachute base serialization inheritance-safe
The abstract Parachute.to_dict/from_dict referenced model-specific
attributes (cd_s, radius, drag_coefficient, height, porosity) that the
base no longer owns, and from_dict forwarded a `parachute_type` kwarg that
concrete constructors do not accept. They worked only because
HemisphericalParachute fully overrode them; any future parachute model
inheriting them would hit AttributeError/TypeError.
Reduce the base methods to the fields the base actually owns and expose a
shared `_decode_trigger` helper. HemisphericalParachute now builds on
`super().to_dict()` (matching the repo-wide serialization convention) and
adds only its own fields, removing the verbatim duplication. Serialized
output and round-trip behavior are unchanged. Drop the now-unused imports.
* MNT: satisfy ruff/pylint for parachute changes
- ruff format: collapse the parachutes_info source comprehension to one line.
- pylint (no-value-for-parameter, fail-under=10): the base Parachute could
not offer a generic from_dict because each concrete model has different
required constructor arguments. Make from_dict abstract (mirroring u_dot
and add_information_to_flight); the shared _decode_trigger helper stays on
the base and HemisphericalParachute keeps its concrete implementation.
---------
Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent d4bd935 commit b516ace
44 files changed
Lines changed: 27596 additions & 32133 deletions
File tree
- docs
- examples
- notebooks
- monte_carlo_analysis
- reference/classes
- user
- rocket
- rocketpy
- plots
- rocket
- parachutes
- simulation
- stochastic
- tests
- acceptance
- fixtures
- monte_carlo
- parachutes
- rockets
- utilities
- integration/simulation
- unit
- rocket
- stochastic
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
281 | 284 | | |
282 | 285 | | |
283 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
| |||
258 | 265 | | |
259 | 266 | | |
260 | 267 | | |
261 | | - | |
| 268 | + | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
| |||
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
279 | | - | |
| 286 | + | |
280 | 287 | | |
281 | 288 | | |
282 | 289 | | |
283 | | - | |
| 290 | + | |
284 | 291 | | |
285 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
286 | 295 | | |
287 | 296 | | |
288 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
| |||
422 | 429 | | |
423 | 430 | | |
424 | 431 | | |
425 | | - | |
| 432 | + | |
426 | 433 | | |
427 | 434 | | |
428 | 435 | | |
429 | | - | |
| 436 | + | |
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
433 | 440 | | |
434 | 441 | | |
435 | 442 | | |
436 | | - | |
| 443 | + | |
| 444 | + | |
437 | 445 | | |
438 | 446 | | |
439 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
310 | | - | |
| 311 | + | |
311 | 312 | | |
312 | | - | |
| 313 | + | |
| 314 | + | |
313 | 315 | | |
314 | 316 | | |
315 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
225 | 227 | | |
226 | | - | |
| 228 | + | |
227 | 229 | | |
228 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
| 430 | + | |
430 | 431 | | |
431 | 432 | | |
432 | 433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
333 | 340 | | |
334 | 341 | | |
335 | 342 | | |
336 | | - | |
| 343 | + | |
337 | 344 | | |
338 | 345 | | |
339 | 346 | | |
340 | | - | |
| 347 | + | |
341 | 348 | | |
342 | 349 | | |
343 | 350 | | |
344 | 351 | | |
345 | 352 | | |
346 | 353 | | |
347 | | - | |
| 354 | + | |
| 355 | + | |
348 | 356 | | |
349 | 357 | | |
350 | 358 | | |
| |||
0 commit comments