Repository navigation
Use seeded np.random.default_rng() random number generator in tests - #662
Merged
Merged
Conversation
The Cython DOP853 Lyapunov routines drew offset vectors from numpy's global RNG, so callers (and tests) could not seed them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Unseeded draws made tests nondeterministic; e.g. the chaotic forced pendulum Lyapunov test occasionally fell below its threshold in CI. - Replace legacy global np.random.* calls with local np.random.default_rng(42) generators. - Pass seeded rng/random_state to lyapunov_max, fast_lyapunov_max, and mockstream DFs, which otherwise draw from fresh entropy. - isotropic_w0 now takes an explicit RNG; TestActions passes RandomState(42) to keep the sample the Sanders reference is validated on. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
np.random.seed and RandomState are legacy APIs. All test randomness now comes from np.random.default_rng: - Add a seeded `rng` fixture in conftest.py and use it in test functions instead of constructing generators inline; remove identical local copies. - setup_method/setup_class, helpers, and the Cython _coord test helpers (which can't take fixtures) use a local default_rng(42). This also seeds _test_cyl_to_car_roundtrip, whose seed was commented out. - TestActions overrides rng with seed 5: the vendored Sanders reference code crashes (IndexError / leastsq size errors) on most other samples. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
random_state now goes through np.random.default_rng, so it defaults to a Generator and also accepts an int seed. A legacy RandomState is still used as-is but raises GalaDeprecationWarning. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Many tests used np.random without seeding, or set the global seed. This brings the tests in line with modern numpy.random recommendations.
Checklist
CHANGES.rst)