Repository navigation
MNT: v1.14.0 final review fixes - #1243
MateusStano wants to merge 6 commits into
Conversation
The static margin is computed from the rocket, and assigning it was never documented. Assigning it raises AttributeError again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the seed type alias, its two helpers and the type hints with one check that rejects random generator objects, and shorten the comments, the error message and the seed docstrings. NumPy rejects any other invalid seed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The out_of_rail_* docstrings say the upper rail button leaves the rail. - Remove Flight.attitude_unit; udot_rail2 computes the rail direction. - Remove _gravitational_potential_per_mass; potential_energy integrates Environment.gravity with Function.integral. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inline the height trigger check in Parachute, and have StochasticParachute build a Parachute for each trigger member instead of restating the rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rasterio, which contextily needs, now ships Python 3.14 wheels for Linux, macOS and Windows, so the background map of the Monte Carlo plots no longer needs to be skipped there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1243 +/- ##
===========================================
- Coverage 87.04% 87.02% -0.03%
===========================================
Files 130 130
Lines 18131 18089 -42
===========================================
- Hits 15783 15742 -41
+ Misses 2348 2347 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @@ -763,19 +763,6 @@ def static_margin(self): | |||
| self.evaluate_static_margin() | |||
| return self._static_margin | |||
There was a problem hiding this comment.
Important: Removing the static_margin setter makes rocket.static_margin = ... raise AttributeError in 1.14.0, although it worked as a plain attribute in 1.13.0 and #1225 restored it (with a DeprecationWarning) for exactly that reason. CHANGELOG.md line 87 still says the assignment is accepted again, and no entry announces the removal. Fix: keep the deprecated setter for one more release, or, if the removal is intended, drop the #1225 line and add a breaking "Removed" entry.
Scenario: a script that does rocket.static_margin = Function(...) runs on 1.13.0 and fails on 1.14.0 with property 'static_margin' of 'Rocket' object has no setter, with no deprecation period.
| total_mass.set_discrete_based_on_model(self.z) | ||
| potential_per_mass = self._gravitational_potential_per_mass(self.z.y_array) | ||
| gravity = self.env.gravity | ||
| potential_per_mass = [gravity.integral(0, z) for z in self.z.y_array] |
There was a problem hiding this comment.
Nit (optional): potential_energy now calls Function.integral once per node in a Python loop, where the removed helper did one vectorized definite_integral call. With a callable env.gravity, every node runs its own scipy.integrate.quad, and the test docstring at tests/unit/simulation/test_flight.py line 694 still says that case works "without falling back to a per-node numerical quadrature", which is now false. Fix: keep the vectorized call for array-sourced gravity, and reword that docstring.
Scenario: a flight with a few thousand nodes and a callable env.gravity runs thousands of adaptive quadratures when potential_energy, total_energy or all_info() is first accessed (the simulation-safety guide asks for a justification for new Python loops).
| assert np.isnan(flight._gravitational_potential_per_mass(np.nan)) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( |
There was a problem hiding this comment.
Nit (optional): The NaN-altitude test was deleted with the helper, so nothing now covers a NaN node in Flight.z. The old code returned NaN explicitly; the new code relies on Function.integral(0, nan), which has no NaN guard (np.sign(nan) is NaN, so neither early return fires). Fix: keep a small test with a NaN in z.y_array and, if the callable path does not return NaN, guard it in the loop.
Scenario: a diverged trajectory node is meant to show as a gap in potential_energy; with array gravity it still does, but for callable gravity the result depends on how quad treats a NaN limit, and a regression would go unnoticed (I did not run this, so treat the quad behavior as unchecked).
| -------- | ||
| TODO link to documentation on noise model | ||
| """ | ||
| if isinstance( |
There was a problem hiding this comment.
Nit (optional): Seed validation is now left to NumPy, so a bad seed fails with a message that does not name seed, and with different exception types: a nested list raises TypeError ("SeedSequence does not accept nested sequences."), a 2-D integer array raises ValueError ("all the input arrays must have same number of dimensions..."). The test for those two cases was deleted, so the behavior is now unspecified and follows the installed NumPy. Fix: restore a small flat-int check that raises one TypeError naming seed, or keep a test that pins NumPy's behavior.
Scenario: Barometer(sampling_rate=1, seed=np.array([[1, 2], [3, 4]])) raises a ValueError from inside default_rng, which a caller catching TypeError for a bad seed will miss.
| with pytest.raises(TypeError, match="seed"): | ||
| def test_non_integer_seeds_are_rejected(seed): | ||
| """NumPy refuses a seed that is not made of integers.""" | ||
| with pytest.raises(TypeError): |
There was a problem hiding this comment.
Nit (optional): Dropping match="seed" lets any TypeError raised while building the Barometer satisfy these tests, not only the one from the seed (same for test_float_ndarray_seed_is_rejected below). Fix: match NumPy's text instead, e.g. match="SeedSequence|integer", which covers the str, float, numpy bool, object and float-array cases here.
Scenario: an unrelated TypeError introduced in sensor construction would keep all of these green.
| - Matrix([[shift, 0, 0], [0, shift, 0], [0, 0, 0]]) | ||
| ).inverse | ||
|
|
||
| # Unit vector along the rail, in the inertial frame |
There was a problem hiding this comment.
Nit (optional): udot_rail2 rebuilds the rail unit vector (four trig calls and a Vector) on every derivative call, although inclination and heading are fixed for the flight, and the same formula now also lives in the test helper _rail_direction. The cost is small next to u_dot_generalized, but the two copies can drift. Fix: compute it once (a private method or cached property) and have the tests call that.
Scenario: a sign or axis change in one copy of the formula is not caught if the other copy is not changed too.
| # otherwise make ("time", "3.0") work by accident. | ||
| if not _is_a_height_trigger(trigger[1]): | ||
| # A number, as for a height. A string delay is refused, not converted. | ||
| if not isinstance(trigger[1], Real) or isinstance(trigger[1], bool): |
There was a problem hiding this comment.
Nit (optional): The numeric test is now written twice with opposite polarity (isinstance(x, Real) and not isinstance(x, bool) for the height, its negation here for the delay) after the shared helper was removed; the helper's docstring said the two forms had already drifted apart once. Fix: keep a one-line private helper, or reuse one expression for both branches.
Scenario: someone widens one site (for example to accept another numeric type) and ("time", x) and a bare height disagree again.
| # member, so a bad one would otherwise fail only when it is drawn. | ||
| for member in trigger: | ||
| try: | ||
| Parachute(self.parachute.name, 1.0, member, 100) |
There was a problem hiding this comment.
Nit (optional): _validate_trigger builds a throwaway Parachute per member with unnamed probe values (1.0, 100) and joins two messages, so the user reads "trigger must be a non-empty list whose members are callables, ... ('time', t_deploy). Unable to set the trigger function for parachute 'main'. Trigger must be a callable, ..." Fix: name the probe values, and raise either Parachute's message or the short one, not both.
Scenario: StochasticParachute(parachute, trigger=[("burnout", 3.0)]) prints the two overlapping messages back to back.
| "statsmodels", | ||
| "prettytable", | ||
| "contextily>=1.0.0; python_version < '3.14'", | ||
| "contextily>=1.0.0", |
There was a problem hiding this comment.
Nit (optional): Dropping the python_version < '3.14' marker turns the background map on for Python 3.14, but CHANGELOG.md has no entry for it. I checked that rasterio ships cp314 wheels and that CI already runs 3.14, so no packaging change is needed. Fix: add a changelog line for the 3.14 support of contextily.
Scenario: users on 3.14 who read the old notebook note (now removed) or the changelog have no record of when the feature became available.
Small fixes found in the final review of #1194, before v1.14.0. One commit per group.
Pull request type
Checklist
ruff check,ruff format --check,pylint) has passed locallytests/unit/simulation/test_udot_rail2_feature.pyand the energy tests intests/unit/simulation/test_flight.py) are left to CI.CHANGELOG.md: not edited here; the two lines below go in after the merge.Changes
Rocket.static_margincan no longer be assigned. The deprecated setter added in BUG: accept static_margin assignment with a DeprecationWarning #1225 is removed, so assigning it raisesAttributeError. The static margin is computed from the rocket, and assigning it was never documented.SeedLiketype alias, its two helpers and the type hints are replaced by one check that rejects random generator objects (Generator,BitGenerator,RandomState), which cannot be saved. NumPy itself rejects any other invalid seed. Comments, the error message and theseeddocstrings are shortened.Flighttip-off and energy code.out_of_rail_*docstrings now say "when the upper rail button leaves the rail"; the rocket is fully off the rail attip_off_end_time.Flight.attitude_unitis removed. It was public, undocumented and read in one place;udot_rail2now computes the rail direction itself.Flight._gravitational_potential_per_massis removed.potential_energyintegratesEnvironment.gravitywithFunction.integral; on a Calisto flight the values are identical.Parachute, andStochasticParachutebuilds aParachutefor each trigger member instead of restating the rules, so a bad member is still reported when the model is created.requirements.txt(Numpy 1.23, Scipy 1.8, Matplotlib 3.9,dilladded).contextilyon Python 3.14. rasterio, whichcontextilyneeds, now ships Python 3.14 wheels for Linux, macOS and Windows, so thepython_version < '3.14'marker and the notebook note are removed. CI now also runs the background map tests on 3.14.Breaking change
Rocket.static_marginraisesAttributeError(it raised aDeprecationWarningon develop, and was a plain attribute on v1.13.0).Changelog lines for after the merge
static_marginline with "Rocket.static_margincan no longer be assigned; it is computed from the rocket's geometry, mass and surfaces."contextilywith themonte-carloextra on Python 3.14 too, so the background map of the Monte Carlo plots is available there."🤖 Generated with Claude Code