Skip to content

BUG: give each CustomSampler its own stream instead of the model's seed - #1102

Closed
thc1006 wants to merge 8 commits into
RocketPy-Team:developfrom
thc1006:bug/custom-sampler-seed-groups
Closed

thc1006 wants to merge 8 commits into
RocketPy-Team:developfrom
thc1006:bug/custom-sampler-seed-groups

Conversation

@thc1006

@thc1006 thc1006 commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Addresses #1093. Not Closes, because the keyword only fires when a pull request targets the default branch and this targets develop.

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added
  • Docs have been reviewed and added / updated
  • Lint (ruff check / ruff format --check / pylint rocketpy/ tests/ docs/) has passed locally
  • All tests have passed locally

pylint exits 0, pytest tests/unit tests/integration is 2049 passed, 44 skipped.

Current behavior

_validate_custom_sampler ended in sampler.reset_seed(seed), and seed was the model's own, handed unchanged to every sampler on it. A sampler written the way the documentation teaches builds np.random.default_rng(seed), so two of them started from identical state and drew identical values. Not nearly identical, the same to every digit:

mass    14.659110385288670  ->  0.466220770577340
radius   0.063966220770577  ->  0.466220770577341

Those are the standard normal deviates behind each draw; the last digit is the scaling. A study varying both parameters was varying one, and any correlation it reported between them was an artefact of the seeding.

New behavior

Each sampler, or each group of samplers that share a generator, gets a child derived from the model's seed and the input names:

def _sampler_seed(seed, input_names):
    root = np.random.SeedSequence(
        entropy=seed, spawn_key=_names_as_spawn_key(tuple(sorted(input_names)))
    )
    words = root.generate_state(4, dtype=np.uint32)
    return sum(int(word) << (32 * position) for position, word in enumerate(words))

Keyed by name rather than position, so declaring another parameter does not move the streams already there. The name is length-prefixed into spawn-key words, which no two names share, rather than hashed: a collision would put two samplers back on one stream, which is the bug this exists to prevent. wd4s4xka50 and p56cjcee10 are both valid identifiers whose CRC32 is 1560575156, and an earlier version of this gave them the same seed.

The child keeps its full 128 bits, matching the width the Monte Carlo seeding uses rather than being cut to 64.

Samplers that share a generator

docs/user/custom_sampler.rst documents two wrappers over one bivariate generator, so that wind X and wind Y stay correlated. CustomSampler gains a seed_group property, self by default, and those wrappers return the generator they share. A group is seeded once between its members, from a seed derived from all their names.

Resetting each member in turn discarded every seed but the last and left the group's stream decided by whichever member went last, so adding a third wrapper moved the first two. The group is reset directly when it knows how, rather than through one member, since the member cannot be assumed to reset identically or to hold nothing of its own.

The correlation is untouched by any of this. It comes from sharing one samples_list, not from sharing a seed:

theoretical, 0.171/sqrt(0.2*0.3)   0.6981
measured                           0.6986

That is the documented pattern executed out of the .rst rather than retyped.

The example also filled a 1000-pair cache inside reset_seed. With per-index seeding that reset happens once per simulation, so it built a thousand pairs to use one, every time. The cache starts empty now and top_up fills the shortfall on first use.

Tests

Sixteen in tests/unit/stochastic/test_custom_sampler.py. Each fix has a mutation that fails a named test and takes nothing else:

mutation fails
one seed for every sampler two_samplers_do_not_draw_the_same_deviate
fresh entropy per reseed the reproducibility and ordering tests
name key back to CRC32 two_names_that_a_hash_would_collide
seed cut to 64 bits the_sampler_seed_keeps_the_full_width
seeding in declaration order a_shared_generator_lands_on_the_same_seed
group keyed by sampler a_shared_group_is_seeded_once
reset through a member a_group_that_can_reset_itself_is_reset_directly
helper stops sorting a_group_key_does_not_depend_on_the_order
RuntimeError only the legacy RandomState test

The fresh-entropy one is the one worth having. Independence is easy to get by throwing the seed away, and that passes the first test while losing the property the class exists for.

Breaking change

  • Yes

Sampled values change for any study using a CustomSampler, since each now receives a different seed. Anything leaning on the accidental correlation will see the parameters move apart, which is the fix rather than a regression, but a baselined study will notice.

A sampler built on the legacy numpy.random.RandomState will now fail: it refuses seeds above 2**32-1 and these are 128 bits. The error names the input it belongs to and keeps the original as its cause, rather than surfacing as a bare ValueError.

Additional information

Found while reviewing #1054. The two overlap in rocketpy/stochastic/stochastic_model.py: that PR changes the base model's list sampling and nominal snapshot, this one changes the sampler lifecycle. They merge cleanly today and I ran the merged tree rather than assuming, 291 passed and 4 skipped, but whichever lands second wants a rebase rather than a trust in that.

Related: #1096, whose eager cache this takes a bite out of.

@thc1006
thc1006 requested a review from a team as a code owner August 8, 2026 02:59
@codecov

codecov Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.59%. Comparing base (e0ff281) to head (e775846).
⚠️ Report is 27 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/stochastic/stochastic_model.py 96.96% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1102      +/-   ##
===========================================
+ Coverage    82.18%   82.59%   +0.41%     
===========================================
  Files          122      128       +6     
  Lines        16355    16583     +228     
===========================================
+ Hits         13441    13697     +256     
+ Misses        2914     2886      -28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thc1006

thc1006 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Both of these were right and both are fixed in 4a1b6ac.

CRC32 collides. 32 bits is not enough for a stream domain, and a collision puts two samplers back on one stream, which is exactly what this PR exists to prevent. The reproducer holds:

crc32("wd4s4xka50") == crc32("p56cjcee10") == 1560575156
_sampler_seed(4242, ...) == 9598975395077455406   for both

My "107 built-in names, no collisions" was the wrong test. It says nothing about a subclass, a future field, or a name a user picks. The name is length-prefixed into spawn-key words now, which no two names can share, and the child keeps its full 128 bits instead of being cut to 64. That also lines it up with the width #1054 uses rather than having the two disagree.

The shared generator was order-coupled, and that one I introduced. Before this branch both wrappers got the same seed, so order did not matter. One seed per name made whichever wrapper reset last decide the stream:

declared x then y   (0.63119306, 0.61655487)
declared y then x   (0.61655487, 0.63119306)

Seeding is its own pass over sorted names now, so the shared generator lands on the same seed whichever way the model was written.

Where I did not follow the suggestion

You proposed a seed_group property on CustomSampler, with grouping and a per-group reset. I did the sorted pass instead, which is two lines against about forty and needs no change to the ABC or the documented wrappers.

It fixes what I broke. What it leaves is that two wrappers reading one generator take successive values, so swapping the declaration swaps which wrapper gets which number. That is inherent to sharing a generator rather than a seeding property, it is true on develop today, and the seed contract holds either way. If you would rather have the group abstraction anyway, say so and I will send it, but I would rather not add the API on my own initiative for a case that already behaves.

One thing worth flagging

My first attempt at the order fix was to sort the main validation loop, which looked like a one-word change. It is not: that loop's order sets __dict__, and dict_generator walks __dict__, so sorting it moved the draw order of every tuple in every model. A three-input model went from zulu, alpha, mike to alphabetical, with different values. The seeding pass is separate for that reason, and there is a test pinning it.

Local: ruff clean, pylint rocketpy/ tests/ docs/ exit 0, 2041 passed and 44 skipped. Three mutations, one per fix, each taking only its own test.

@thc1006

thc1006 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

You were right and I was wrong to argue it away. 1defe34 adds the group semantics.

My case for the sorted pass was that it fixed what I had broken and the rest was inherent. It did fix the order coupling, but it left something I had also introduced, and I did not go looking for it:

shared group of wind_x, wind_y      x=0.63119306  y=0.61655487   generator reset 4x
add wind_z to the same generator    x=-0.6761184  y=0.49262482   generator reset 6x

Before this branch every sampler took the model's seed, so adding a member to a shared group changed nothing for the others. Keying by name protects independent samplers from exactly that, and left the shared group unprotected, because its stream was whatever the last-sorted member's seed made it. So the inconsistency was mine, not inherent.

CustomSampler now has a seed_group property, self by default, and a group is seeded once between its members with a seed derived from all their names. The documented wind wrappers return their shared generator. The generator is reset once rather than once per wrapper, which also stops the 1000-sample cache in that example being rebuilt and thrown away, so it takes a bite out of #1096 as well.

shared group                     reset 1x
independent sampler added        group unmoved
X.seed_group is Y.seed_group     True
correlation                      0.6986 against 0.6981

Adding a member to a group still moves that group's stream. That one does look inherent to me: the group is keyed by its members, and a different set of members is a different group. Say if you disagree.

One thing I did and then undid

Grouping keys on id, which is unique only among live objects, so I went looking for whether a seed_group that builds its answer could be freed and have its address reused. In a tight loop it certainly can: five successive temporaries all came back with the same id. I held a reference and wrote a test.

The test passed with the fix removed. In this loop's actual shape the temporaries do not collide, so the test proved nothing and I have taken it out. The reference is still held, because keying on an id you have not retained is fragile whether or not I could make it bite today, but the comment now says it is defensive rather than pretending it fixes something I observed.

Local: ruff clean, pylint rocketpy/ tests/ docs/ exit 0, 2043 passed and 44 skipped, and the documented example still executes out of the .rst.

@thc1006

thc1006 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Three more in 7fb0133, and the description is rewritten, since it still described the first version of this.

The documented example filled a cache it threw away. reset_seed generated 1000 pairs, and with per-index seeding that reset happens once per simulation, so a study built on this example produced a thousand pairs and used one, every time:

after construction       1000 pairs generated, none asked for
5 reseeds                5000 more generated, 0 used
                         0.099 ms each, about 10 s over 100k simulations

The cache starts empty now and top_up fills the shortfall on first use. Executed out of the .rst: 0 pairs after construction, 4000 after 4000 draws, correlation 0.6986 against the covariance's 0.6981.

The group reset went through a member. It dispatched to the first sampler in the group rather than to the group, which assumes every member resets identically and holds nothing of its own. The group owns the shared generator, so it is reset directly when it knows how, with the member as the fallback.

_sampler_seed sorts the names itself. The caller sorts today; a future one that forgets would hand a single group two different seeds.

I have also removed an earlier comment of mine here that said the conflict with #1054 was one line of imports. That was true of bffa1fac and stopped being true once this grew a seed_group contract and two signature changes, and it named a zlib import that no longer exists. The accurate version is in the description: the two overlap in the sampler lifecycle, they merge cleanly today, and I ran the merged tree rather than trusting that.

Local: ruff clean, pylint rocketpy/ tests/ docs/ exit 0, 2049 passed and 44 skipped, sixteen tests with a mutation each.

@thc1006

thc1006 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 74a6ba02 with the ownership rules on seed_group, which you asked for and which I had left implicit.

Two ways to break it, both silent, both measured:

Identity has to be stable across calls. Returning from a property makes it easy to build the answer each time, and then every member has a different identity and goes back into a group of its own. A two-member group drops from one reset to two:

stable identity, 2 members   -> group reset 1 time
unstable identity, 2 members -> group reset 2 times

A group belongs to one model. Declaring the same generator on two models has them both seed it and the later one wins, which is the overwrite the grouping is here to prevent.

I did not add tests for either. The first is a consequence of test_a_shared_group_is_seeded_once_between_its_members, which already fails if grouping stops working. The second is a caveat rather than a behaviour worth freezing, and a test asserting the last model wins would fail on anyone who later makes cross-model groups work properly.

I also considered detecting an unstable group and warning, and decided against it. It degrades to per-member seeding, which is the default anyway, so nothing goes wrong that would not have gone wrong without the property.

The wind pair in the docs returns a stored attribute, so the example already teaches the stable form.

Local: ruff clean, pylint 10.00/10 exit 0, stochastic unit suite 39 passed.

@thc1006

thc1006 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Added the changelog entry directly here, as you suggested, since the automation cannot run on a fork pull request until #1101 is fixed. Head is 10a0eeec.

It records both migrations: fixed-seed CustomSampler baselines move, and a sampler built on the legacy RandomState has to move to default_rng because the seed it now receives is 128 bits wide.

On the merge order, that matches what I found independently: #1104 first, then this branch updated so the Sphinx warnings-as-errors job actually runs against the custom_sampler.rst change. I will rebase once #1104 lands rather than now, so the run is against the real merge candidate.

On StochasticModel(seed=SeedSequence(...)): agreed it is not a blocker, and agreed the half-accepting behaviour is the part worth avoiding. The docstring says int, and _sampler_seed builds SeedSequence(entropy=seed, spawn_key=...), so a SeedSequence passed in would be rejected there while default_rng would have taken it. I would rather reject it early with a clear message than extend the state, since accepting it means deciding what a caller-supplied spawn_key composes with. Happy to add that guard here if you want it in scope, otherwise it belongs with the same question in #1054's root seed handling.

thc1006 added 7 commits August 8, 2026 10:02
Every sampler on a model was reset with the model's seed, so two backed by
default_rng started from identical state and drew identical underlying values.
Not nearly identical, the same to every digit: two Gaussians with different
means and spreads both produced the deviate 0.466220770577340.

A study varying two parameters that way is varying one, and the correlation it
reports between them is an artefact of the seeding.

Each sampler now gets a child derived from the model's seed and the input's
name. Keyed by name rather than position so declaring another parameter does
not move the streams of the ones already there, and crc32 rather than hash
because hash is not stable across processes.

The documented wind X/Y wrappers are unaffected. Their correlation comes from
sharing one samples_list, not from sharing a seed, so handing them separate
children leaves it intact: measured 0.7010 against the covariance's 0.6981.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Two problems with the first version of this, both found in review.

CRC32 is 32 bits, and a collision puts two samplers back on one stream, which
is the bug the keying exists to prevent. `wd4s4xka50` and `p56cjcee10` are both
valid identifiers with CRC32 1560575156, and both derived the same seed. The
name is length-prefixed into spawn-key words now, which no two names share, and
the child is kept at its full 128 bits to match the Monte Carlo seeding rather
than being cut to 64.

Samplers can also share one generator on purpose, as the documented wind pair
does, and each reset overwrites the last. With one seed per name, whichever was
reset last decided the stream, so the same seed meant different runs depending
on the order the model was declared in. Seeding is its own pass over sorted
names now.

The pass is separate from the validation loop deliberately. That loop's order
sets __dict__, and so the order every other input is drawn in, so sorting it
would have moved the samples of every model with a tuple in it.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Two wrappers can share one generator on purpose, as the documented wind pair
do. One seed per name reset that generator once per wrapper, so every seed but
the last was discarded and the group's stream was decided by whichever member
sorted last. Adding a third wrapper to the same generator therefore moved the
first two, which name keying is meant to prevent.

CustomSampler gains a `seed_group` property, `self` by default, so a wrapper
can say which generator it shares. Members of a group are seeded once between
them, with the seed derived from all their names rather than from whichever
went last. The documented wind wrappers declare it.

Before, resetting six times for three wrappers and moving the pair when a third
arrived. After, once, and adding an independent sampler leaves the group where
it was.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Only RuntimeError was caught, and the seed handed over is now 128 bits, which
the legacy numpy.random.RandomState refuses:

    ValueError: Seed must be between 0 and 2**32 - 1

Before this branch a sampler received the model's seed, usually a small int,
so RandomState took it. A sampler built on RandomState therefore breaks here,
and used to break with a bare ValueError that named nothing.

The seed stays 128 bits, since that is what keeps the streams apart and what
default_rng, the documented choice, takes. The error now says which input the
sampler belongs to and keeps the original as its cause.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
…discards

Three things from review, all small.

The documented bivariate generator filled a 1000-pair cache inside reset_seed.
With per-index seeding that reset happens once per simulation, so a study built
on this example generated a thousand pairs and used one, every time. 0.099 ms
each, about 10 s over 100k simulations. `top_up` already fills the shortfall on
first use, so the eager fill is gone and the cache starts empty.

The group reset went through the first member rather than the group, which
assumes every member resets identically and keeps nothing of its own. The group
holds the shared state, so it is reset directly when it knows how, and the
member is the fallback.

`_sampler_seed` now sorts the names itself. The caller does today, and a future
one that forgets would hand a single group two different seeds.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Two rules the property invites breaking, both silent.

Identity has to be stable. Building the answer on each call, which returning
from a property makes easy, gives every member a different identity and puts
each back in a group of its own: a two-member group goes from one reset to two.

A group belongs to one model. Declaring the same generator on two models has
them both seed it, and the later one wins, which is the overwrite the grouping
exists to prevent.

The documented wind pair already returns a stored attribute, so the example
teaches the stable form.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
The automation that normally writes it cannot run on a pull request from a
fork, which is RocketPy-Team#1101, so this one is by hand.

It is a breaking change and the entry says so: fixed-seed CustomSampler
baselines move, and a sampler built on the legacy RandomState has to move to
default_rng because the seed it now receives is 128 bits wide.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@Gui-FernandesBR
Gui-FernandesBR force-pushed the bug/custom-sampler-seed-groups branch from 10a0eee to e775846 Compare August 8, 2026 13:02
resetter = group if hasattr(group, "reset_seed") else sampler
try:
resetter.reset_seed(_sampler_seed(seed, names))
except Exception as error:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broad exception handler. We should avoid it

            except Exception as error:

Comment thread rocketpy/stochastic/stochastic_model.py Outdated
f"An error occurred in the 'reset_seed' method of {input_name} CustomSampler"
) from e

assert isinstance(sampler, CustomSampler), (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should avoid using "assert" in production code. The assert operator was created meaning for tests only

Gui's point on the review. `python -O` strips an assert, and this is what keeps
a non-sampler out of the model, so it has to be a raise. Same shape as RocketPy-Team#1103,
which took the identical route for the parachute triggers.

AssertionError is kept rather than swapped for TypeError, because the docstring
on develop already documents it and a caller catching it should keep working.

Two tests. One is the behaviour; the other runs a child interpreter under -O,
since that is the mechanism and the plain test passes either way.

Note this module carries thirteen more asserts on develop, none of them mine.
Happy to send them separately if you want the same treatment there.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR added a commit that referenced this pull request Aug 8, 2026
BUG: give each CustomSampler its own stream instead of the model's seed

Every CustomSampler on a model was reset with the model's own seed, so two
samplers backed by default_rng started from the same state and drew the same
underlying deviate. Each input now gets a stream keyed by its name, and
samplers that share one generator declare a seed_group so the group is seeded
once between them.

Merged manually rather than through the button: the CHANGELOG conflicted with
#1103, and the resolution keeps both entries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Gui-FernandesBR

Copy link
Copy Markdown
Member

Merged into develop as 9593b1d, with your commits and authorship intact.

Done by hand rather than through the button, and worth saying why: the CHANGELOG.md entry conflicted with #1103, which landed a few minutes earlier. GitHub's Update branch refuses a conflicted head (422 merge conflict between base and head), and resolving it on my side means pushing to your fork, which I would rather not do uninvited. So the resolution — both entries kept, yours above #1103's — went in on the merge commit instead. Nothing else was touched: git diff against the previous develop is exactly your five files, 469 insertions.

What I checked before pushing:

  • pytest tests/unit on the merge result — 1891 passed, 16 skipped
  • The scoping question I had, since seeding moved out of the validation loop into its own pass: exception_list is initial_solution, terminate_on_apogee, date, ensemble_member, none of which can be a sampler, so _reset_custom_samplers walking the whole __stochastic_dict covers the same set the old loop did and no more.
  • _sampler_seed keyed by sorted names, so the two-wrapper wind pair in the docs lands on one seed whichever order it is declared in — your test_a_shared_generator_lands_on_the_same_seed_whatever_the_order is the one that would have caught me if I had gotten this wrong.

The behaviour change is real and the changelog says so: fixed-seed CustomSampler baselines move, and a sampler built on the legacy RandomState now has to move to default_rng because the seed carries 128 bits. That is the right trade for two samplers no longer drawing the same deviate.

This PR will show as closed rather than merged, since the merge commit does not come from your branch. It is in develop regardless.

@thc1006
thc1006 deleted the bug/custom-sampler-seed-groups branch August 8, 2026 13:33
@Gui-FernandesBR

Copy link
Copy Markdown
Member

Correction, and the miss was mine.

I merged e7758461 — the head as of when I fetched your branch. You pushed 23be0bab sixteen seconds before my own push landed, and I did not re-check the head before closing. So the merge went in one commit short: develop had the assert isinstance(sampler, CustomSampler) you had just replaced, which is the exact python -O point I had raised on the review and you had already fixed.

Now applied as cbafd728, cherry-picked with your authorship intact. Content identical to 23be0bab; only the SHA differs.

Verified rather than assumed, since the whole point of that commit is a failure mode the plain test does not see:

  • test_the_refusal_survives_python_dash_o against the old assert — fails, as it should. Against your raise — passes. It tests what it claims.
  • pytest tests/unit — 1897 passed, 16 skipped. Six more than before, which is your two new tests plus the four the earlier merge had already brought in.
  • ruff check and ruff format --check clean.

Two things worth saying plainly. Landing this by hand is what let a stale head through; the button would have refused, and that would have been the better outcome. And on the thirteen other asserts in stochastic_model.py — yes, send them separately. Same treatment, and there is a module-level TODO already asking for it.

Nothing was lost, and there was nothing wrong on your end.

@thc1006

thc1006 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging it by hand, and for saying why. The scoping check you did on exception_list is the one I would have wanted someone to make.

On your two review points, I went to fix the assert and found something that changes what is worth doing.

The one you flagged is inert. Both call sites guard the type immediately before calling:

elif isinstance(input_value, CustomSampler):
    attr_value = self._validate_custom_sampler(input_name, input_value)   # line 141
...
elif isinstance(input_value, CustomSampler):
    return self._validate_custom_sampler(input_name, input_value)         # line 358

So it can only fire if the private method is called directly, which is what my own test was doing. Under python -O it disappears and nothing changes. I had told myself it was the last thing keeping a non-sampler out of the model; that was wrong, and I only noticed when I went looking for what it protected.

Thirteen others in the same file are not inert. They validate what the user passes in, and they do vanish:

StochasticModel(obj, mass=("not a number", 0.5))

  python      AssertionError
  python -O   accepted, mass = ('not a number', 0.5, <bound method Generator.normal>)

That is a malformed model that will fail somewhere much later with something unhelpful. rocketpy/ has 22 of these, all in stochastic/: 14 in stochastic_model.py, 3 each in stochastic_environment.py and stochastic_flight.py, 1 in stochastic_aero_surfaces.py, and 1 left in stochastic_parachute.py that #1103 did not reach.

Happy to send all 22 as one pull request, keeping AssertionError so nothing that catches it today breaks. That seems more useful than converting the one that cannot fire. Say if you would rather have it split per file, or scoped to stochastic_model.py first.

On the broad handler. That one I would defend, and I want to give you the reason rather than just leave it. It catches to name the sampler and re-raises with from error, so nothing is swallowed and the original stays as __cause__. It was RuntimeError before, and the reason for widening is in the tests: a sampler built on the legacy RandomState raises ValueError on a 128-bit seed, and a bare one of those says nothing about which of the model's inputs produced it.

If the convention is firm regardless, the narrow version is except (RuntimeError, ValueError, TypeError), which covers the cases I know about and loses the name for anything else a user's reset_seed does. I will send whichever you prefer.

Gui-FernandesBR pushed a commit to thc1006/RocketPy that referenced this pull request Aug 8, 2026
`Populate Changelog` fails for every pull request opened from a fork, and only
those. GitHub withholds secrets from a `pull_request` run whose head is a fork,
so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds:

    ##[error]Input required and not supplied: token

The effect is that no outside contribution gets a changelog entry. RocketPy-Team#1102, RocketPy-Team#1103
and RocketPy-Team#1108 all landed without one and had to be added by hand.

`pull_request_target` receives secrets because it runs in the context of the
base repository. That is also why it needs care, and why this belongs on master
rather than develop: the workflow definition is read from the default branch,
so a copy that only exists on develop would never be loaded.

Nothing from the pull request is executed here. The checkout is `ref: develop`,
the updater is inline in the workflow rather than a script from the tree, and
the title and labels reach Python through the environment instead of the shell.

`permissions` drops to `contents: read`. The job's writes go through
RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write
and should not have it now that the trigger runs with secrets available.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit to thc1006/RocketPy that referenced this pull request Aug 12, 2026
`Populate Changelog` fails for every pull request opened from a fork, and only
those. GitHub withholds secrets from a `pull_request` run whose head is a fork,
so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds:

    ##[error]Input required and not supplied: token

The effect is that no outside contribution gets a changelog entry. RocketPy-Team#1102, RocketPy-Team#1103
and RocketPy-Team#1108 all landed without one and had to be added by hand.

`pull_request_target` receives secrets because it runs in the context of the
base repository. That is also why it needs care, and why this belongs on master
rather than develop: the workflow definition is read from the default branch,
so a copy that only exists on develop would never be loaded.

Nothing from the pull request is executed here. The checkout is `ref: develop`,
the updater is inline in the workflow rather than a script from the tree, and
the title and labels reach Python through the environment instead of the shell.

`permissions` drops to `contents: read`. The job's writes go through
RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write
and should not have it now that the trigger runs with secrets available.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit to thc1006/RocketPy that referenced this pull request Aug 13, 2026
`Populate Changelog` fails for every pull request opened from a fork, and only
those. GitHub withholds secrets from a `pull_request` run whose head is a fork,
so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds:

    ##[error]Input required and not supplied: token

The effect is that no outside contribution gets a changelog entry. RocketPy-Team#1102, RocketPy-Team#1103
and RocketPy-Team#1108 all landed without one and had to be added by hand.

`pull_request_target` receives secrets because it runs in the context of the
base repository. That is also why it needs care, and why this belongs on master
rather than develop: the workflow definition is read from the default branch,
so a copy that only exists on develop would never be loaded.

Nothing from the pull request is executed here. The checkout is `ref: develop`,
the updater is inline in the workflow rather than a script from the tree, and
the title and labels reach Python through the environment instead of the shell.

`permissions` drops to `contents: read`. The job's writes go through
RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write
and should not have it now that the trigger runs with secrets available.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
thc1006 added a commit to thc1006/RocketPy that referenced this pull request Aug 14, 2026
The prose added in RocketPy-Team#1102 restates itself across three places and narrates how
each rule was arrived at. Keep the caller-visible rules, drop the retelling,
and let a shared group's contract live on seed_group rather than being
repeated at each call site. Comments only, no change to executable code.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit to thc1006/RocketPy that referenced this pull request Aug 14, 2026
`Populate Changelog` fails for every pull request opened from a fork, and only
those. GitHub withholds secrets from a `pull_request` run whose head is a fork,
so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds:

    ##[error]Input required and not supplied: token

The effect is that no outside contribution gets a changelog entry. RocketPy-Team#1102, RocketPy-Team#1103
and RocketPy-Team#1108 all landed without one and had to be added by hand.

`pull_request_target` receives secrets because it runs in the context of the
base repository. That is also why it needs care, and why this belongs on master
rather than develop: the workflow definition is read from the default branch,
so a copy that only exists on develop would never be loaded.

Nothing from the pull request is executed here. The checkout is `ref: develop`,
the updater is inline in the workflow rather than a script from the tree, and
the title and labels reach Python through the environment instead of the shell.

`permissions` drops to `contents: read`. The job's writes go through
RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write
and should not have it now that the trigger runs with secrets available.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit that referenced this pull request Aug 14, 2026
`Populate Changelog` fails for every pull request opened from a fork, and only
those. GitHub withholds secrets from a `pull_request` run whose head is a fork,
so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds:

    ##[error]Input required and not supplied: token

The effect is that no outside contribution gets a changelog entry. #1102, #1103
and #1108 all landed without one and had to be added by hand.

`pull_request_target` receives secrets because it runs in the context of the
base repository. That is also why it needs care, and why this belongs on master
rather than develop: the workflow definition is read from the default branch,
so a copy that only exists on develop would never be loaded.

Nothing from the pull request is executed here. The checkout is `ref: develop`,
the updater is inline in the workflow rather than a script from the tree, and
the title and labels reach Python through the environment instead of the shell.

`permissions` drops to `contents: read`. The job's writes go through
RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write
and should not have it now that the trigger runs with secrets available.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit to thc1006/RocketPy that referenced this pull request Aug 14, 2026
The prose added in RocketPy-Team#1102 restates itself across three places and narrates how
each rule was arrived at. Keep the caller-visible rules, drop the retelling,
and let a shared group's contract live on seed_group rather than being
repeated at each call site. Comments only, no change to executable code.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Gui-FernandesBR pushed a commit that referenced this pull request Aug 14, 2026
The prose added in #1102 restates itself across three places and narrates how
each rule was arrived at. Keep the caller-visible rules, drop the retelling,
and let a shared group's contract live on seed_group rather than being
repeated at each call site. Comments only, no change to executable code.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
MateusStano added a commit that referenced this pull request Dec 2, 2026
* DOC: Update Changelog for PR #1081

* Merge pull request #1082 from RocketPy-Team/enh/llm-changelog-automation

CI: make changelog automation LLM-based (Gemini) and race-safe

* DOC: update changelog for PR #1082

* ENH: Resolve pressure_ISA discretization bounds TODO (#1056)

* ENH: Resolve pressure_ISA discretization bounds TODO (#1056)

* TST: Fix test_flight and environment interpolation due to new ISA bounds

* MNT: self-document pressure_ISA bounds and strengthen discretization test

Derive the pressure_ISA discretization bounds from the standard-atmosphere
layer table (geopotential_height[0]/[-1]) instead of hardcoding -2000/80000,
and document why the grid is split around sea level. Strengthen the
discretization test with physical-sanity assertions (strictly increasing
altitude, strictly decreasing pressure, sea level sampled). No change in
numeric output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* TST: update density doctest for new pressure_ISA discretization

The finer spline knots shift density at 1000 m by ~1e-4 (density at sea
level is unchanged since 0 m is still sampled exactly). Update the
calculate_density_profile doctest expected value accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* TST: relax noisy stream_velocity_z apogee tolerance

stream_velocity_z at apogee is a residual of the apogee-time estimation:
it is physically ~0 but swings by ~1e-4 m/s across platforms/NumPy
versions and atmosphere discretizations (e.g. -8.9e-8 on py3.10 with the
new ISA grid, -2.0e-4 with the old grid, +2.6e-4 on py3.14). The previous
atol=1e-5 was tighter than this numerical noise, making the assertion
flaky. Use atol=1e-3, which is physically negligible (vertical speed
peaks above 200 m/s) while still catching real regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* STY: apply ruff markdown formatting to README code blocks

CI installs ruff unpinned; ruff 0.16 formats fenced Python blocks in
Markdown by default, so `ruff format --check .` now flags README.md on
every PR. Reformat the affected snippets (indentation, quotes, call
wrapping) to unblock the lint check. No semantic changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* MNT: satisfy pylint on the pressure_ISA discretization changes

CI runs pylint unpinned; three messages were attributable to this PR:
- C0415 import-outside-toplevel: move the tools import to the test module
  top level.
- R0915 too-many-statements: keep the discretization block compact so
  pressure_ISA stays within the 25-statement limit.
- C0302 too-many-lines: the terser block keeps environment.py under the
  3050-line module limit.

np.append over two linspaces yields the same grid as the previous
np.concatenate, so all numeric results are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* ENH: Add native Meteomatics API support to the Environment class (#1079)

* ENH: Add native Meteomatics API support to the Environment class

Adds a new "meteomatics" atmospheric model to Environment.set_atmospheric_model,
porting and generalizing the implementation from the EuRoC-Dev repository.

- fetchers.py: fetch_meteomatics_token + fetch_atmospheric_data_from_meteomatics
  authenticate with username/password (short-lived token), query temperature,
  pressure and wind components by height above ground level, grouping the
  parameters to respect the account's per-request limit.
- environment.py: process_meteomatics_atmosphere converts the height-AGL data to
  above-sea-level profiles using the Environment elevation; set_atmospheric_model
  gains username/password kwargs (falling back to METEOMATICS_USERNAME /
  METEOMATICS_PASSWORD env vars); save/load handles the new model type.
- Network requests use timeouts, do not retry deterministic 4xx failures, and
  surface actionable RuntimeError messages.
- Tests fully mock the API (no real requests, no charges); docs and changelog
  updated.

Closes #545

* MNT: simplify Meteomatics fetcher and profile assembly

Follow-up cleanups from the code review of the Meteomatics support:

- Collapse the duplicated request/error ladder of the login and data
  endpoints into a single `_meteomatics_request_json` helper.
- Have `_build_meteomatics_parameters` return a {parameter: (profile,
  height)} mapping so the response parser no longer regex-parses back
  the strings this module just built. Drops the regex constant and the
  variable-to-profile table.
- Generalize `to_profile_array` to several profiles at once, so the
  wind u/v grid intersection reuses it instead of repeating it inline.
- Reuse the existing `__validate_datetime` helper for the launch-date
  check, and simplify the model default to `model or "mix"`.
- Normalize `atmospheric_model_type` once in `from_dict`. The type is
  stored as the user spelled it, so the previously case-sensitive
  `match` and `== "ensemble"` branches silently dropped the ensemble
  arrays for an Environment built with `type="Ensemble"`.
- Trim the elevation warning and raise it before the API call, so it is
  shown even when the request later fails.

* MNT: address Meteomatics review comments

Two points raised in the PR review:

- `fetch_atmospheric_data_from_meteomatics` stamped the instant with a
  trailing "Z" without normalizing the timezone, so an aware datetime in
  a non-UTC zone was sent as the wrong instant. Aware datetimes are now
  converted to UTC; naive ones are documented as assumed UTC.
- Degenerate sampling arguments (`query_limit=0`, resolutions below 2)
  reached `range()`/`linspace()` and failed with an opaque low-level
  error after the login had already been paid for. They are now
  validated up front by `_validate_meteomatics_sampling`.
- `process_meteomatics_atmosphere` silently coerced any non-string model
  to "mix", hiding a mistake such as passing a Dataset or a path as
  `file` and querying the wrong model. It now accepts None (default) or
  a string, and raises otherwise.


* ENH: Refactor Meteomatics integration into MeteomaticsFetcher class and clean up environment method

* ENH: Decompose fetchers.py into rocketpy/environment/fetchers package with dedicated submodules

* DOC: make the CustomSampler examples answer to their seed (#1097)

Both examples build a generator with np.random.default_rng(seed) and drop it,
then sample from the process-global np.random. reset_seed is a no-op, so a
sampler written by following this page ignores random_seed. The study runs and
the numbers look reasonable; only a second run with the same seed shows they
were never reproducible.

The bivariate generator needs two more things. It caches 1000 samples, so
reset_seed has to discard them or the first 1000 draws after a reseed still
come from the generator that was replaced. And its refill test compares
samples_generated against used_samples, which only becomes true after the
cache has run out, so a study longer than the cache silently got short lists:
sample(n_samples=1) returns [] at simulation 1001 and dict_generator raises
IndexError on [0].

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* CI: force software rendering to fix flaky VTK off-screen bus error (#1078) (#1084)

Isolates the three VTK/PyVista off-screen animation tests into their own workflow step so a native crash in one of them no longer kills the whole integration run, adds a bounded retry for the crash, forces Mesa software rendering on Linux, and sets fail-fast: false so one platform no longer cancels the rest of the matrix.

Closes #1078

* BUG: rocket with a late-starting thrust curve never leaves the rail (#411) (#1085)

A motor whose thrust curve starts at t > 0 never left the rail: the rail phase's only time nodes were [t=0, max_time], so LSODA (max_step defaults to inf) took one huge step over the entire burn and the rocket never accelerated. __setup_phase_time_nodes now forces solver stops at ignition and burn-out when burn_start_time > 0, leaving ordinary motors byte-for-byte unchanged.

Also moves Codecov's coverage config out of .github/workflows/codecov.yml (where Actions was trying to execute it as a workflow, failing on every run) to .codecov.yml.

Closes #411

* BUG: fly the parachute the simulation sampled (#1098)

StochasticRocket.create_object built a Parachute from the full sampled draw, then discarded it and built a second one from six of its ten fields. radius, height, porosity and drag_coefficient never reached the rocket: the second Parachute re-derived radius from cd_s and the default drag coefficient, and height fell back to that radius. Attaching the sampled object itself fixes it and stops Parachute.__init__ running twice per parachute per simulation.

Breaking: radius and height feed the parachute added-mass term in flight.py, so descent dynamics and landing points change for any study whose parachute carries geometry.

Closes #1094

* MNT: do not let one Python version cancel the other in the slow matrix (#1100)

* MNT: do not let one Python version cancel the other in the slow matrix

#1084 added fail-fast: false to the main test matrix while this was open, so
the only half left is the slow one. Same reason: 3.10 failing says nothing
about 3.14, so cancelling it costs a result and saves nothing worth having.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* MNT: retry the VTK tests on SIGSEGV, not only on macOS SIGBUS

#1084 retries the animation tests when they die on 138, which is SIGBUS on
macOS. Counting the last 40 Tests runs, the crash was 139 eight times and 138
twice, so the common case fell straight through the retry. Linux SIGBUS is 135
rather than 138, so that missed as well.

Also sets fail-fast: false on the slow matrix, which #1084 left out. 3.10
failing says nothing about 3.14, so cancelling it costs a result and saves
nothing worth having.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

---------

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>

* ENH: Add Qodo PR-Agent workflow using Google Gemini (#1089)

* ENH: Add Qodo PR-Agent workflow using Google Gemini

* FIX: point PR Agent workflow at the renamed action repo

Codium-ai/pr-agent-action no longer exists (the project moved to
the-pr-agent/pr-agent), which made the "Run PR Agent" check fail with
"Unable to resolve action". Updates the action reference, grants the
contents: write permission it now requires, and sets the Gemini key
via the GOOGLE_AI_STUDIO.GEMINI_API_KEY env var per the new action's docs.

* DOC: update changelog for PR #1089

* CI: build the docs for pull requests into develop as well (#1104)

* CI: build the docs for pull requests into develop as well

`branches` filters on a pull request's base, and almost every PR here is opened
against develop: 25 of the last 30, with 3 against master. So the build that
runs with -W --keep-going saw a docs change for the first time in a release
batch, well away from whatever caused it.

The path filter already keeps this off PRs that cannot affect the docs, and
`rocketpy/**` is in it because docstrings feed the autodoc reference, so a
docstring edit merged into develop could break the API pages unnoticed too.

`push` is left on master alone. The pull request check is where the feedback is
worth having, and running both would double the cost for a second opinion on
the same commit.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* Apply suggestion from @Gui-FernandesBR

---------

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>

* BUG: give each CustomSampler its own stream instead of the model's seed

Every sampler on a model was reset with the model's seed, so two backed by
default_rng started from identical state and drew identical underlying values.
Not nearly identical, the same to every digit: two Gaussians with different
means and spreads both produced the deviate 0.466220770577340.

A study varying two parameters that way is varying one, and the correlation it
reports between them is an artefact of the seeding.

Each sampler now gets a child derived from the model's seed and the input's
name. Keyed by name rather than position so declaring another parameter does
not move the streams of the ones already there, and crc32 rather than hash
because hash is not stable across processes.

The documented wind X/Y wrappers are unaffected. Their correlation comes from
sharing one samples_list, not from sharing a seed, so handing them separate
children leaves it intact: measured 0.7010 against the covariance's 0.6981.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: make the sampler key collision-free and the shared case order-free

Two problems with the first version of this, both found in review.

CRC32 is 32 bits, and a collision puts two samplers back on one stream, which
is the bug the keying exists to prevent. `wd4s4xka50` and `p56cjcee10` are both
valid identifiers with CRC32 1560575156, and both derived the same seed. The
name is length-prefixed into spawn-key words now, which no two names share, and
the child is kept at its full 128 bits to match the Monte Carlo seeding rather
than being cut to 64.

Samplers can also share one generator on purpose, as the documented wind pair
does, and each reset overwrites the last. With one seed per name, whichever was
reset last decided the stream, so the same seed meant different runs depending
on the order the model was declared in. Seeding is its own pass over sorted
names now.

The pass is separate from the validation loop deliberately. That loop's order
sets __dict__, and so the order every other input is drawn in, so sorting it
would have moved the samples of every model with a tuple in it.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: seed a shared generator once between its samplers, not once each

Two wrappers can share one generator on purpose, as the documented wind pair
do. One seed per name reset that generator once per wrapper, so every seed but
the last was discarded and the group's stream was decided by whichever member
sorted last. Adding a third wrapper to the same generator therefore moved the
first two, which name keying is meant to prevent.

CustomSampler gains a `seed_group` property, `self` by default, so a wrapper
can say which generator it shares. Members of a group are seeded once between
them, with the seed derived from all their names rather than from whichever
went last. The documented wind wrappers declare it.

Before, resetting six times for three wrappers and moving the pair when a third
arrived. After, once, and adding an independent sampler leaves the group where
it was.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: name the sampler when its generator refuses the seed

Only RuntimeError was caught, and the seed handed over is now 128 bits, which
the legacy numpy.random.RandomState refuses:

    ValueError: Seed must be between 0 and 2**32 - 1

Before this branch a sampler received the model's seed, usually a small int,
so RandomState took it. A sampler built on RandomState therefore breaks here,
and used to break with a bare ValueError that named nothing.

The seed stays 128 bits, since that is what keeps the streams apart and what
default_rng, the documented choice, takes. The error now says which input the
sampler belongs to and keeps the original as its cause.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* MNT: reset the group itself, and stop the example filling a cache it discards

Three things from review, all small.

The documented bivariate generator filled a 1000-pair cache inside reset_seed.
With per-index seeding that reset happens once per simulation, so a study built
on this example generated a thousand pairs and used one, every time. 0.099 ms
each, about 10 s over 100k simulations. `top_up` already fills the shortfall on
first use, so the eager fill is gone and the cache starts empty.

The group reset went through the first member rather than the group, which
assumes every member resets identically and keeps nothing of its own. The group
holds the shared state, so it is reset directly when it knows how, and the
member is the fallback.

`_sampler_seed` now sorts the names itself. The caller does today, and a future
one that forgets would hand a single group two different seeds.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: say what owning a seed group means

Two rules the property invites breaking, both silent.

Identity has to be stable. Building the answer on each call, which returning
from a property makes easy, gives every member a different identity and puts
each back in a group of its own: a two-member group goes from one reset to two.

A group belongs to one model. Declaring the same generator on two models has
them both seed it, and the later one wins, which is the overwrite the grouping
exists to prevent.

The documented wind pair already returns a stored attribute, so the example
teaches the stable form.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: add the changelog entry for this branch

The automation that normally writes it cannot run on a pull request from a
fork, which is #1101, so this one is by hand.

It is a breaking change and the entry says so: fixed-seed CustomSampler
baselines move, and a sampler built on the legacy RandomState has to move to
default_rng because the seed it now receives is 128 bits wide.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* MNT: declare dependency floors the package can actually run on (#1108)

`scipy>=1.0` is not true. `monte_carlo.py` imports `scipy.stats.bootstrap` at
module level, and the SciPy 1.7.0 release notes are where that arrives, so
anything from 1.0 to 1.6 satisfies the floor and then fails on `import
rocketpy`.

`numpy>=1.13` is not true either, and the binding constraint turned out to be a
sibling rather than NumPy itself: `matplotlib>=3.9.0` requires `numpy>=1.23`.
SciPy then has to be new enough to allow that, and 1.7.2 caps NumPy at
`<1.23.0`, so 1.8 is the first that composes.

Verified rather than reasoned. On Python 3.10 with numpy 1.23.0 and scipy
1.8.0 pinned and everything else current, `import rocketpy` works and
`tests/unit/simulation` with `tests/unit/stochastic` is 162 passed, 5 skipped.
At numpy 1.21.3, which is where NumPy's own cp310 wheels start, matplotlib
refuses to import.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: accept the callable parachute triggers the docstring promises (#1103)

* BUG: accept the callable parachute triggers the docstring promises

The `or` sat inside the isinstance call rather than beside it:

    isinstance(member, (str, int, float) or callable(member))

A non-empty type tuple is truthy, so the expression short-circuited to the
tuple and callable(member) was never evaluated. The check reduced to
isinstance(member, (str, int, float)), and a callable is none of those.

Parachute takes a callable trigger and Flight calls it, and the docstring three
lines above says "a list of callables, string 'apogee' or ints/floats". Only
the stochastic wrapper refused one. The two non-callable forms passed
throughout, which is why the tests never caught it.

Left as an assert to match the other fourteen in these two modules, and because
raising a different type would break anyone catching AssertionError.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: refuse the trigger forms Parachute cannot use

Moving the `or` let callables through, but left four things the check should
never have accepted.

`["banana"]` passed here and then `Parachute` raised ValueError, so the wrapper
only moved the failure to create time. `[True]` is worse: bool is an int, so it
went through as a height of one metre. `[]` passed because `all([])` is True.
And `numbers.Real` replaces `(int, float)`, which took numpy.float64 because it
subclasses float and refused numpy.int64 because it subclasses neither.

The check is raised rather than asserted. `python -O` strips an assert outright,
and this is the only thing between those triggers and a Parachute that either
refuses them later or misreads them. Still an AssertionError, so nothing that
catches it has to change.

The docstring claimed a tuple form that was never implemented; it now describes
what the code does.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: do not accept numpy integers the Parachute will refuse

Widening the height check to numbers.Real was the same mistake as accepting
"banana": Parachute checks isinstance(trigger, (int, float)), so numpy.float64
passes because it subclasses float and numpy.int64 raises ValueError because it
subclasses neither. Letting them through here only moved the failure to
create_object.

Back to (int, float), matching that check rather than improving on it, and the
test that asserted numpy.int64 was accepted now asserts both ends refuse it.

The asymmetry is Parachute's rather than this wrapper's and is worth fixing
there, where widening the check would not strand anything downstream.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* TST: use the state length Flight actually passes

The trigger tests built a 14-element state. Flight passes 13:
x y z vx vy vz e0 e1 e2 e3 wx wy wz. Only y[5] is read, so both worked, but
the test is there to document the contract and was documenting it wrongly.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: add the changelog entry for this branch

By hand, because the automation cannot run on a pull request from a fork
(#1101).

No documented API breaks, but the observable behaviour does: an invalid string,
an empty list or a boolean trigger now fails during StochasticParachute
validation rather than later in Parachute construction, or silently becoming a
one-metre height trigger.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

---------

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* ENH: Add simplified opening shock force estimation (#1092)

* ENH: Add opening shock force estimation to Parachute class (#1050)

Adds an opening_shock_coefficient parameter and a
calculate_opening_shock_force method to estimate the peak transient
force during parachute inflation, following the simplified model in
Knacke's Parachute Recovery Systems Design Manual (1992, Section 5.5).

Closes #161

Co-authored-by: ArthurJWH <167456467+ArthurJWH@users.noreply.github.com>

* ENH: Moving opening shock force function to utilities

* DOC: Updated the CHANGELOG

* DOC: Removed cross-reference from previous Parachute method

---------

Co-authored-by: Matanski <Matangrod@outlook.co.il>

* DOC: add the changelog entries the fork-PR bug dropped

#1104 and #1108 both came from a fork, so `Populate Changelog` failed on
`RELEASE_TOKEN` being withheld and neither got an entry. #1101 tracks the
workflow bug; these two lines are the entries it would have written.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Raise the sampler type check rather than asserting it

Gui's point on the review. `python -O` strips an assert, and this is what keeps
a non-sampler out of the model, so it has to be a raise. Same shape as #1103,
which took the identical route for the parachute triggers.

AssertionError is kept rather than swapped for TypeError, because the docstring
on develop already documents it and a caller catching it should keep working.

Two tests. One is the behaviour; the other runs a child interpreter under -O,
since that is the mechanism and the plain test passes either way.

Note this module carries thirteen more asserts on develop, none of them mine.
Happy to send them separately if you want the same treatment there.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* Validation in stochastic/ that survives python -O (#1111)

`stochastic_model.py` has carried this as a TODO:

    # TODO: Stop using assert in production code. Use exceptions instead.

The reason it matters is that the optimiser removes them, so the checks stop
running and malformed input reaches the model:

    StochasticModel(obj, mass=("not a number", 0.5))

    python      AssertionError
    python -O   accepted, mass = ('not a number', 0.5, <Generator.normal>)

That model then fails somewhere later with something that does not point back
at the tuple that caused it.

Twenty one of them, all in stochastic/: thirteen in stochastic_model.py, three
each in stochastic_environment.py and stochastic_flight.py, one in
stochastic_aero_surfaces.py, and the one in stochastic_parachute.py that #1103
did not reach. Converted mechanically through the AST, so the condition and the
message are the ones that were there.

AssertionError is kept rather than swapped for TypeError or ValueError. The
docstrings document it, and callers catching it should keep working. Changing
the type is a separate decision from making the check run at all.

Two kinds of test. One reads each module and fails on a reintroduced `assert`,
which is the mechanism. The other runs a child interpreter under -O, because in
process the assert is still compiled in and the check would pass either way.

Also moves two imports in test_custom_sampler.py to the top of the file, which
pylint flags as C0415 on develop today.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* ENH: Support for Open-Meteo API in the `Environment` class (#1119)

* ENH: add Open-Meteo API fetchers for forecast, history and ensemble

Wraps the three Open-Meteo endpoints RocketPy needs to build atmospheric
profiles: the forecast API, the historical-forecast API (for past launch
dates) and the ensemble API. All of them serve pressure-level data as plain
JSON over HTTPS, with no API key and no netCDF/OPeNDAP dependency.

Note that Open-Meteo's ERA5 archive endpoint is deliberately not used: it
serves surface variables only and answers with nulls at every pressure
level, so the historical-forecast API (available from 2021 onwards) is the
only archive that can feed a vertical profile.

Ensemble models are restricted to the ones that actually publish
pressure-level data (gfs05, ecmwf_ifs025, gem_global); the others return
HTTP 200 with null values, which would otherwise surface as an opaque
failure much later in the parsing step.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* ENH: support Open-Meteo atmospheric models in the Environment class

Adds two new atmospheric model types to set_atmospheric_model:

  env.set_atmospheric_model("open_meteo")                        # best_match
  env.set_atmospheric_model("open_meteo", file="ecmwf_ifs025")
  env.set_atmospheric_model("open_meteo_ensemble", file="gfs05")

Both build the usual pressure, temperature and wind profiles from
Open-Meteo pressure-level data, so no external files and no netCDF/OPeNDAP
libraries are involved. When the launch date is in the past, "open_meteo"
transparently queries Open-Meteo's historical-forecast archive instead of
the live forecast, which is what makes past-launch reconstruction work
without downloading reanalysis files by hand.

The ensemble processor stores every member, so select_ensemble_member() and
plots.ensemble_member_comparison() work exactly as they do for GEFS. The
unsuffixed control run is kept as member 0, matching the documented
convention that member 0 is the unperturbed control.

Open-Meteo reports wind as speed/direction rather than u/v components, so
convert_wind_speed_direction_to_components is added to environment.tools;
it converts the meteorological blows-from convention into RocketPy's
East/North components. Temperatures are converted from Celsius to Kelvin
and pressure levels from hPa to Pa.

The model-type gates in the prints and plots classes were comparing
capitalised literals ("Ensemble"), which never matched a lower-case type
even though set_atmospheric_model documents the argument as
case-insensitive. They now compare case-insensitively, so both the new
Open-Meteo types and a lower-case "ensemble" report their time period and
member count.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* TST: cover the Open-Meteo atmospheric models

Adds 44 offline unit tests (tests/unit/environment/test_open_meteo.py) and 6
live integration tests marked slow.

The unit tests patch the fetchers, so the whole module runs without network
access: verified by re-running the suite with socket.connect blocked, where
all 44 still pass. They cover the unit conversions (hPa to Pa, Celsius to
Kelvin, speed/direction to u/v), the nearest-hour selection, skipping levels
a model does not resolve, altitude sorting, the ensemble member layout with
the control run as member 0, the endpoint routing for past versus future
dates, error payload handling, and to_dict/from_dict round trips.

The wind-component conversion is tested against the four cardinal directions
and round-tripped through calculate_wind_heading, since getting that
convention wrong would silently flip the wind by 180 degrees.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* FIX: drop gem_global from the usable Open-Meteo ensemble models

Verifying the ensemble models against the live API showed gem_global cannot
feed a RocketPy profile: it publishes temperature and geopotential height at
pressure levels but no pressure-level winds at all (168/168 hours null for
wind_speed and wind_direction at every level, at three different launch
sites). The earlier check only probed temperature, which is why it looked
usable.

Accepting it meant "Open-Meteo returned fewer than two usable pressure
levels" at profile-build time instead of an actionable message naming the
model, so it is now rejected up front alongside gfs025, icon_global and
bom_access_global_ensemble. gfs05 (31 members) and ecmwf_ifs025 (51
members) are the two that publish the full set; both member counts are
confirmed against the API.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* DOC: document the Open-Meteo atmospheric models

Adds docs/user/environment/1-atm-models/open_meteo.rst, covering the
forecast, past-launch and ensemble workflows, the model tables, and the
caveats worth knowing: coverage of pressure levels varies per model, the
historical archive only reaches back to 2021, and Open-Meteo's ERA5 endpoint
cannot be used because it serves no pressure-level data.

Cross-references were added from the forecast, reanalysis and ensemble pages,
since Open-Meteo is the lighter alternative in each of those cases -- notably
for ensembles, where the GEFS shortcut is currently unavailable.

Every code block in the new page runs as part of the docs build; all five
were executed against the live API to confirm they work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* ENH: warn when a launch date predates the Open-Meteo archive

Open-Meteo answers historical requests for unsupported dates with HTTP 200
and null values at every pressure level, so a pre-archive launch date used to
surface only as a generic "fewer than two usable pressure levels" error, with
no hint that the date itself was the problem. Such dates now raise a warning
naming the archive start and pointing at the reanalysis and sounding models.

The cutoff was probed against the live API rather than assumed: 2021-03-15
comes back empty while 2021-03-23 is complete, so the archive starts in March
2021 and not in January as the previous constant implied. The constant is now
a date instead of a year, and the docs state March 2021.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* MNT: satisfy pylint on the Open-Meteo code paths

The CI lint job runs pylint, not just ruff, and flagged the new code:

- process_open_meteo_atmosphere and process_open_meteo_ensemble exceeded the
  statement limit. Rather than suppress it, the profile-storing and
  member-stacking blocks were extracted into helpers, mirroring the existing
  _store_meteomatics_* pattern. The two processors now read as a sequence of
  named steps.
- set_atmospheric_model exceeded the branch limit, since the two new model
  cases added to an already long match. The self-contained
  pressure_conversion_factor validation moved to a private validator next to
  the other validators, which also flattens its nested ifs.
- Unused-argument and missing-docstring warnings in the new tests, from fakes
  that deliberately accept the real signature.

Behaviour is unchanged: the pressure_conversion_factor error messages and the
Open-Meteo profiles were re-verified against the original, and the full unit
suite still passes (1954 passed, 16 skipped).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* DOC: update changelog for PR #1119

* MNT: the docker/ files still use the paths they had before the 2024 move (#1139)

* docker: mount the repository root in compose, not the docker folder

#732 moved docker-compose.yml into docker/. Compose resolves relative
host paths against the compose file's own directory, so `- .:/app`
mounts docker/, which has no pyproject.toml and no requirements-tests.txt
for the services to install.

* docker: raise the compose service to the python floor the package declares

#857 moved requires-python to >=3.10; pip declines the install on 3.9.
Renamed the service key so it does not outlive the version again.

* docker: pin the base image to python:3.14

python:latest and python:3.14 are the same digest today, so the image
does not change. 3.14 is the ceiling of the test matrix, and a pinned
tag is one renovate can see and bump.

* docs: describe the docker layout as it is after #732

The build command needs a repository-root context to find
requirements.txt, compose runs from inside docker/, and the file
tests 3.10 and 3.12 rather than 3.9 and 3.12.

* Fix operating_temperature init values (#1118)

Docstring states that the sensor default operating_temperature in K is assumed to be 25 C = 25+273.15 = 298.15 K. The initialization value, however, was set to "25" and never converted from C to K creating a contradiction.

Set new operating_temperature init values to 298.15 across Sensor classes.

* CI: make the Gemini PR reviewer actually review (#1140)

The job has never posted a review. It passed the Gemini API key but never
set a model, so PR-Agent kept its OpenAI defaults (`gpt-5.6`, falling back
to `gpt-5.6-terra`) and every call failed with

    AuthenticationError - Incorrect API key provided: dummy_key

PR-Agent swallows that error, so the run still went green and the failure
was invisible. Setting `config.model` / `config.fallback_models` to Gemini
models is the actual fix.

Three other reasons it never worked:

- `pull_request` gives no secrets to fork PRs, and most contributions are
  fork PRs (23 of the 27 currently open). Those runs sat in `action_required`
  (22 of the last 60) and would have had an empty key even once approved.
  `pull_request_target` is safe here because the job never checks the PR out.
- `synchronize` is not in PR-Agent's `pr_actions`, so every push logged
  "Skipping action: synchronize" after a ~30 s image build - 38 of the last
  60 runs were that no-op.
- `issue_comment` runs the workflow from the default branch, and this file
  only exists on `develop`, so `/review` and `/ask` never fired once: all
  74 recorded runs were `pull_request`.

Also raise the token ceiling off the 32k default, since Gemini takes 1M and
larger diffs were being truncated; leave the human-written PR description
alone by turning `auto_describe` off; and drop the unused `contents: write`.

The action ref moves from `@main` to a release tag. Note that this pins the
action definition only: `Dockerfile.github_action_dockerhub` is a one-liner
that pulls `pragent/pr-agent:github_action`, a floating tag, so the agent
itself is still whatever that image currently holds.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* DOC: update changelog for PR #1140

* ENH: StochasticFreeFormFins for Monte Carlo simulations (#1117)

* BUG: accept a deterministic aerodynamic surface in StochasticRocket

`_add_surfaces` wrapped a plain surface with `stochastic_type(component=...)`,
but none of the stochastic aero-surface classes take a `component` keyword:
each names its first parameter after its own surface (`nosecone`, `tail`,
`trapezoidal_fins`, ...). Passing anything other than an already-stochastic
surface to `add_nose`, `add_trapezoidal_fins`, `add_elliptical_fins` or
`add_tail` therefore raised a TypeError, even though all four document the
deterministic type as accepted.

Passed positionally instead, which reaches every class regardless of what it
calls that parameter.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* ENH: StochasticFreeFormFins for Monte Carlo simulations

Closes #953. Free-form fin sets were the only aerodynamic surface without a
stochastic counterpart, so a rocket using them could not be varied in a Monte
Carlo run.

`shape_points` does not fit the one-number-per-input assumption the base class
makes, and a fin shape is only meaningful as a complete set of points, so the
outline is randomized as a block: one sampled deviation applied to every
coordinate. Two formats needed handling before reaching the base class, both of
them the natural thing to write:

- a bare outline is a `list`, which the base class reads as a list of candidate
  values and would have sampled a single (x, y) point from. It is wrapped as the
  one candidate outline it is, and a list of outlines still means a choice
  between shapes.
- `(nominal outline, standard deviation)` has a list where `_validate_tuple`
  requires a number. Only that first item is special-cased; the deviation and
  the distribution name still go through the base class, so the distribution is
  drawn from this model's generator like every other input.

An outline that cannot mean a fin shape - empty, ragged, fewer than three
points, three-dimensional - now fails during validation rather than reaching
FreeFormFins.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: seed the choice between the candidate values of a list input

`dict_generator` and `StochasticRocket._randomize_position` picked from a
list with `random.choice`, which draws from the interpreter-wide stream.
`_set_stochastic` only rebuilds the model's own numpy generator, so that
stream was never reseeded: a fixed-seed run did not reproduce the values
chosen from a list, and Monte Carlo workers forked from one process
inherited a single `random` state and walked the same choice sequence
instead of sampling independently.

The choice now comes from a generator of the model's own, derived from the
same seed through `_sampler_seed` but kept apart from the one the
distributions draw from, so that declaring a list input does not shift the
numbers every other input gets and existing fixed-seed baselines that use
no list input stay where they are.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* MNT: let a stochastic input hold an array as its nominal value

`StochasticFreeFormFins` needed a whole fin outline where the base class
reads a single number, and got there by overriding `_validate_tuple`,
comparing the input name against the literal `"shape_points"` and
smuggling a `0.0` placeholder through `super()`. The rest of the machinery
was never told, so `_validate_scalar`, `dict_generator` and
`visualize_attributes` all still believed the value was a number: the
public `visualize_attributes` raised a `TypeError` formatting an outline
with `:.5f`, and the next array-valued input would have had to rediscover
the same workaround.

`array_valued_inputs` declares those inputs by name on the class instead,
so validation, sampling and the report agree on which ones they are.
`_nominal_value` converts them where the nominal value is looked up, and
the report prints the array's shape rather than trying to format its
coordinates as one number.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: fix which shape_points StochasticFreeFormFins accepts and rejects

The `shape_points` contract did not hold up to the formats the docstring
and the user guide advertise:

- `_is_outline` caught only `IndexError`, but `np.shape` raises a
  `ValueError` on a ragged sequence. A list of candidate outlines with
  different numbers of points -- choosing between a three-point and a
  four-point fin, the plainest form of choosing between shapes -- died
  with an opaque numpy error, and a ragged outline did not fail during
  validation as claimed. Each candidate is now converted on its own.
- Every distribution name was accepted, but the deviation is applied as
  `dist_func(nominal_outline, std_dev)`, so only the ones that read the
  first argument as the centre of the draw can work. `uniform` read the
  outline as its lower bound and `wald` rejected the zeros of a root
  point, both raising in the middle of a Monte Carlo run. The four that
  can are accepted and the rest are rejected up front.
- An outline of non-numbers passed validation and died inside
  `_FreeFormGeometry.infer_dimensions`; a numpy array was rejected even
  though `create_object` produces one and `FreeFormFins` takes one; and
  `shape_points=[]` raised where an empty list means "use the nominal
  value" for every other input.

The fin root is also held on the body line now. `FreeFormFins` measures
the span from y = 0 and slices the chords over that interval, so
perturbing every y drove most samples off the line -- 227 of 300 outlines
had a point inside the airframe -- and the interference factors were
computed from the inflated span that followed. Points nominally on the
line stay there and none is allowed to cross it, which is what the root
edge of a fin does anyway.

The docstring and the user guide said a single outline "must be wrapped in
a list" while the code auto-detects a bare one, and that one deviation is
shared by every coordinate while each is in fact drawn on its own. Both
now describe what the code does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* DOC: update changelog for PR #1117

* BUG: Restore UTC fallback without timezonefinder (#1143)

* ENH: add tube-fin aerodynamic surface (#1144)

* CI: keep per-matrix coverage artifacts and fail Codecov errors (#1088) (#1123)

* CI: keep per-matrix coverage artifacts and fail Codecov errors (#1088)

* CI: address review on the per-matrix coverage upload (#1088)

The artifact renaming was the right diagnosis, but review turned up eight
follow-ups:

- fail_ci_if_error was unconditional, and forks get no secrets, so an
  external contributor would see red whenever the tokenless upload got
  rate limited. Tie it to the token, as #1088 prescribed.
- overwrite: true was dropped. Artifacts are keyed by (run, name) and
  survive across attempts, so every leg of a re-run failed with 409
  Conflict. The flaky VTK tests make re-runs routine.
- needs: Pytest with no if: guard skipped CodecovUpload entirely when a
  single leg failed, sending Codecov nothing at all for the commit while
  .codecov.yml resolves that as an error. Run on !cancelled() and upload
  whatever legs did finish.
- download-artifact exits 0 when pattern matches fewer artifacts than
  expected, so five of six reports looked like a clean run. Verify the
  count against the matrix size and refuse the silently-partial case.
- Both .codecov.yml statuses were scoped to a `unit` flag that no upload
  has ever tagged, so the gate resolved over an empty flag set and
  measured nothing. The reports are unit + doctest + integration +
  acceptance combined, so drop the flag rather than mislabel them.
- --cov-report=xml:<name> writes the per-leg filename directly, so the
  extra mv step goes away and if-no-files-found: error is reachable again
  instead of being masked by the mv failing first.
- retention-days: 1, since artifacts per run went from 1 to 6 and
  CodecovUpload consumes them minutes later.
- env: OS/PYTHON and .github/workflows/upload-to-codecov.yml were dead.
  The reusable workflow was called by nothing and was the only consumer
  of those two variables, while holding a second, diverging copy of the
  Codecov settings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: seed parachute pressure noise with per-instance RNG (#1091) (#1134)

* CI: run the changelog job for pull requests from forks (#1112)

`Populate Changelog` fails for every pull request opened from a fork, and only
those. GitHub withholds secrets from a `pull_request` run whose head is a fork,
so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds:

    ##[error]Input required and not supplied: token

The effect is that no outside contribution gets a changelog entry. #1102, #1103
and #1108 all landed without one and had to be added by hand.

`pull_request_target` receives secrets because it runs in the context of the
base repository. That is also why it needs care, and why this belongs on master
rather than develop: the workflow definition is read from the default branch,
so a copy that only exists on develop would never be loaded.

Nothing from the pull request is executed here. The checkout is `ref: develop`,
the updater is inline in the workflow rather than a script from the tree, and
the title and labels reach Python through the environment instead of the shell.

`permissions` drops to `contents: read`. The job's writes go through
RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write
and should not have it now that the trigger runs with secrets available.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: correct Flight aerodynamic moment units (#1149)

* DOC: tighten the comments that came with the sampler seed groups (#1154)

The prose added in #1102 restates itself across three places and narrates how
each rule was arrived at. Keep the caller-visible rules, drop the retelling,
and let a shared group's contract live on seed_group rather than being
repeated at each call site. Comments only, no change to executable code.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* TST: use UTC for the HRRR forecast date (#1153)

* BUG: report missing impact roots explicitly (#1147) (#1148)

* TST: cover controller behavior and reporting (#1152)

* TST: cover Function unit conversions (#1157)

* TST: cover geospatial extent conversions (#1158)

* MNT: let pylint use every core it is given (#1163)

jobs=1 pins the run to one process. Measured on eight cores over rocketpy/,
tests/ and docs/: 36.4s at jobs=1 against 14.0s at jobs=0, and the two produce
the same messages, so the gate is unchanged and only the wait is shorter.

0 asks pylint to count the processors itself, which is what the comment above
the setting already describes, and it caps the count on Windows on pylint's own
side.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: stop dict_generator from sampling initial_solution (#1109) (#1122)

Generate stochastic samples from declared constructor inputs only, and
validate StochasticFlight.initial_solution on construct.

* TST: cover attitude conversion helpers (#1159)

* CI: measure coverage on develop, not only on pull requests (#1162)

The tests workflow is the only one that uploads to Codecov and it runs on
pull_request alone, so no commit on develop ever gets a report. Codecov then
compares each pull request against the nearest older report it holds and prints
how far behind that has fallen; the banner read 53 commits one day and 61 the
next, and it grows with every merge.

.codecov.yml already names master and develop under branches for both the
project and the patch status, so the configuration expects these to be
measured. docs.yml pairs pull_request with push the same way.

Nothing in the jobs reads pull_request context, so the same matrix runs
unchanged on a push.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: fix RST indentation in dict_generator notes

The nested a./b. list was indented deeper than the body of item 1 with no
blank line in between, which docutils reports as "Unexpected indentation".
Since #1122 landed this broke `build-docs` for every pull request opened
against develop, including PRs that do not touch this file.

Aligns the sublist with the parent item's body, adds the required blank
line, and drops the now-unneeded line continuations.

* BUG: evaluate parachute triggers once per time node (#1086) (#1121)

Remove the duplicate inline parachute loop in Flight.__simulate; keep
only __check_and_handle_parachute_triggers.

* ENH: Create ensembles from user-defined profiles (#1141)

* ENH: create ensembles from user-defined profiles

* MNT: split custom ensemble creation into helpers

* TST: cover custom ensemble validation

* BUG: skip scalar statistics for structured Monte Carlo results (#1145) (#1146)

* BUG: apply wind factors to the ensemble member that was selected (#1160)

select_ensemble_member() rebuilds the wind functions from the chosen member's
own profile, and create_object() reached it after the factors because that is
where __dict__ happened to put it. The factor was scaled into the previous
member's wind and then thrown away, so the run flew the raw member wind while
the input record still reported a factor.

Factors are now applied once the loop is done, so the order of __dict__ stops
mattering, and the baseline is the member just loaded rather than the value
cached at construction.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: build Monte Carlo flights with the configuration they were given (#1164)

__run_single_simulation writes the Flight constructor out by hand and stops at
time_overshoot. StochasticFlight.create_object passes nine more: max_time, the
two time steps, rtol, atol, name, equations_of_motion, ode_solver and
simulation_mode.

So a Monte Carlo run ignored the max time, the tolerances, the solver and the
equations of motion the caller had set, and reset the simulation mode to the
constructor default. The same rocket, environment and flight therefore flew
differently under MonteCarlo than under StochasticFlight.create_object. #1070
added StochasticFlight's handling of these; this path never picked it up.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: document multivariable drag inputs (#1142)

* TST: add Defiance example flight acceptance test (#1156)

* TST: add Defiance example acceptance test

* TST: cover Defiance peak and impact metrics

* TST: allow cross-platform impact variation

* BUG: serialize numpy SeedSequence for sensor seeds (#1087) (#1124)

* BUG: serialize numpy SeedSequence for sensor seeds (#1087)

* MNT: split rebuild_minimal_flight out of object_hook

The SeedSequence branch pushed object_hook to 26 statements, one over
pylint's max-statements, failing the Linters job. Extract the Flight
rebuild into a module-level helper next to set_minimal_flight_attributes,
matching how that path is already factored. Pure code move.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* TST: cover confidence ellipse helpers (#1165)

* BUG: draw the eccentricities again, whichever way they were added (#1167)

#1122 made dict_generator walk the inputs a model declared instead of every
attribute on it, which is the right shape for #1109. add_cp_eccentricity and
add_thrust_eccentricity run after __init__ has built that list, so their
distributions stopped being drawn from: the value was set on the instance and
every simulation used the same one, with nothing to say so.

Bisected: at 3e16c9fc all four eccentricities appear in the generated
dictionary, at 5a71eb93 none of them do.

An add_* method now declares what it installed, with the argument as given
rather than the validated form, so _set_stochastic validates it again on each
reseed and binds the distribution to the generator that is live then.
ensemble_member was already fine, since StochasticEnvironment passes it through
the constructor and the hasattr guard covers it not being set yet.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* ENH: compute rocket static margin lazily (#780) (#1135)

* ENH: compute rocket static margin lazily (#780)

* MNT: satisfy ruff format on the lazy static margin changes

Reformat the static margin source lambda. No behaviour change: the
_csys factor stays inside the lambda body, applied to the result.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: write MonteCarlo input and output rows atomically (#1110) (#1125)

* BUG: write MonteCarlo input and output rows atomically (#1110)

* TST: fix pylint W1113 in MonteCarlo append rollback mock (#1110)

* ENH: add Flight post-step callback across all phases (#758) (#1128)

* ENH: model unbonded solid-motor grain CM shift (#340) (#1138)

* ENH: model unbonded solid-motor grain CM shift (#340)

* MNT: satisfy ruff format on the unbonded-grain changes

Blank line before evaluate_geometry, wrap the propellant_I_11 assignment
that ran past 88 columns, and let the expected_cm expression in the test
break the way the formatter wants. No behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: refuse to run a Monte Carlo over a results file it cannot write (#1161)

* BUG: refuse to run a Monte Carlo over a results file it cannot write

import_outputs() accepts .csv and .json, points output_file at the file, and
offers continuing a simulation from it. simulate() only writes JSONL, and
__setup_files opens with w+ when append is False, so the imported file was
truncated and then filled with records its own extension does not describe.

Checked before any file is opened, and named per path so the message says which
one has to change.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* DOC: stop offering CSV and JSON results as something to resume from

The note under import_outputs said any previously saved file could be used to
continue a simulation, which is what led a .csv into output_file in the first
place. Say which format that holds for.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* BUG: refuse working logs that are one file, and options that split a row

import_results points input_file, output_file and error_file at one path, and a
run then appends input rows and output rows into it. Compared by inode once the
files exist, so a symlink, a hard link, a/../run.txt and a case-insensitive
filesystem are all the same file rather than three names.

json.dumps kwargs reach the writer, so indent=2 wrote records across several
lines while every reader here takes one line at a time. The run finished and the
completeness check then called the file it had just written damaged. indent of
0 and "" do the same, as does a newline inside separators.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* TST: cover the branch a first run actually takes

samefile needs both files to exist, and every case here wrote one first, so the
resolved-path fallback that a run with no logs yet goes through was never
exercised. Replacing it with False leaves the new test red.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

---------

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* ENH: list NOAA atmosphere datasets and fetch latest (#660) (#1136)

* ENH: list NOAA atmosphere datasets and fetch latest (#660)

* MNT: satisfy ruff format on the NOAA catalog helpers

Collapse the RuntimeError message and the test assertion the formatter
wants on one line. No behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* DOC: add SIL parachute ejection integration example (#524) (#1131)

* DOC: add SIL parachute ejection integration example (#524)

* DOC: make the SIL mechanism table render as a table

RST has no pipe-table syntax. A line starting with "|" is parsed as a
line block, so the "Dual path: trigger vs controller callback" section
rendered as a column of ragged lines with the pipes and the "---------"
separator showing through, rather than as a table.

Sphinx does not warn about this, which is why the docs job stayed green
and it went unnoticed.

Converted to a list-table, matching the two-column explanatory tables
already used in docs/user/flight.rst (:header-rows: 1, :widths: 30 70).

Verified by building the page with Sphinx 8.1.3 under -W --keep-going:
the section now emits one <table class="docutils"> with a real header
row, where before it emitted zero tables and one line-block. No new
warnings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: accept numpy integer types as Parachute trigger (#1116)

* fix: accept numpy integer types as Parachute trigger

isinstance(trigger, (int, float)) rejects numpy integer types
(np.int64, np.int32) because they don't subclass Python's int or float.
Replace with isinstance(trigger, numbers.Real) which covers all numeric
types (int, float, numpy scalars) while excluding bool.

Fixes #1106

* BUG: accept a NumPy integer height in stochastic/ as well

This PR widened Parachute's height check from `(int, float)` to
`numbers.Real`, so a height read out of a NumPy array is accepted.
StochasticParachute validates the same triggers before a Parachute is ever
built, and its copy of the check was still spelled `(int, float)`. A
`numpy.int64` height was therefore still refused there, even though the
Parachute it would have built accepts it.

That mismatch is what turned all six Pytest legs red:
`test_a_numpy_integer_is_refused_here_because_parachute_refuses_it` pinned
the old asymmetry, and its own docstring said the fix belonged in Parachute.

Rather than restate the predicate a second time, Parachute now exposes it as
`_is_a_height_trigger` and stochastic/ calls that. The two spellings drifted
apart once already; sharing one definition is what stops it happening again.

Tests:

- the NumPy integers move into
  `test_what_this_accepts_is_what_a_parachute_accepts`, where they now
  belong, joined by `numpy.float32`
- the refusal test is rewritten around what is still refused by both:
  `numpy.bool_` and the complex types, none of which are `Real`
- a new test asserts the agreement itself over the whole boundary, so
  changing one side alone fails with both verdicts printed
- Parachute gains boundary tests of its own, including that `True` is still
  refused rather than read as a height of one metre

Verified: reverting either side alone turns these red (the drift guard
reports `np.float32(800.0): stochastic/ says False, Parachute says True`);
ruff check and format clean; pylint 10.00/10; tests/unit 2098 passed,
16 skipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: abhi-0203 <abhi-0203@users.noreply.github.com>
Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: draw each declared eccentricity once per simulation (#1168)

#1167 declared the eccentricities that add_cp_eccentricity and
add_thrust_eccentricity install, so dict_generator draws them.
_create_eccentricities then drew them a second time and overwrote the first
value. The exported inputs matched the applied ones only because the second
write wins, and the extra draw moved every component position create_object
places after it.

Read what has been drawn already, and draw only a half the caller left out,
which is not a declared input and so never reaches dict_generator.

The docstring correction is the explanation #1167 landed with, which named
the wrong symptom: the value did vary between simulations, what a fixed seed
failed to do was reproduce it.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>

* ENH: support fixed-time parachute deployment triggers (#437) (#1133)

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Fix spurious ValueError from floating-point roundoff at exact tank depletion (#1166)

* Fix spurious ValueError from floating-point roundoff at exact tank depletion

* MNT: make _compose_clipped a real drop-in for compose, and format

Retargeted this PR from master to develop, which is where RocketPy takes
contributions. That also clears most of the lint failure by itself: master's
own README.md currently fails `ruff format --check`, so the job was red for a
reason outside this diff. Merged develop in as well, since the branch was cut
from the v1.13.0 tag.

Two changes:

- `ruff format` on the two touched files. Two `_compose_clipped(...)` call
  sites were over 88 columns and the new test needed the surrounding blank
  lines.

- `_compose_clipped` now defers to `outer.compose(inner)` unless both sides
  are array-sourced. Clipping reads `x_array` / `y_array` and the domain
  bounds, which only exist for array sources, so a callable source raised
  `AttributeError: 'Function' object has no attribute 'x_array'` where plain
  `compose` had worked. `Function.compose` already handles that case with a
  lambda and performs no bounds check there, so there is no spurious error to
  absorb and nothing to clip. Uses the public `is_array_source()`, as
  motors/motor.py and environment/ already do.

Tests: three parametrized cases pinning the deferral (array/callable,
callable/array, callable/callable) and one that the array/array path still
pulls in a value a roundoff below the domain. Removing the guard turns them
red with the AttributeError above.

I also checked the thing that worried me most about clipping, since
`UllageBasedTank.liquid_height` has no bounds check of its own and previously
depended on `compose` raising: a gross overfill is still refused. Measured on
develop and on this branch, an ullage 1.5x the tank volume and an ullage of
-0.5x both raise the same ValueError from Tank's own overfill/underfill
checks, which fire independently of the composition. So the clipping really
does only absorb boundary noise.

Verified: tests/unit 2161 passed, 17 skipped; tests/unit/motors plus
tests/integration/motors 116 passed; ruff check and format clean; pylint
10.00/10.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: x <x@y>
Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* BUG: sample StochasticFlight inputs once per simulation (#1090) (#1126)

* BUG: sample StochasticFlight inputs once per simulation (#1090)

* MNT: satisfy ruff format on MonteCarlo.__sim_producer (#1090)

---------

Co-authored-by: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* DOC: backfill the Unreleased changelog entries the automation missed (#1180)

* DOC: backfill the Unreleased changelog entries the automation missed

The last commit to CHANGELOG.md is 5eae273b on 12 August, and the highest
pull request it records is #1140. Thirty-nine commits have landed on
develop since, and none of them is in the file, so [Unreleased] no longer
describes the branch.

Add the thirty-two that belong there, taken from the merge list and
following the file's own rules: Added for new features, Changed for
changes to existing behavior, Fixed for bug fixes, and tests left out. The
seven TST commits in the gap are therefore not listed.

Entries use the pull request title and link, with the issue linked
alongside where the commit names one. One entry is a direct commit t…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants