You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ENH: seed sensor measurement noise per instance (#1052)
* ENH: seed sensor measurement noise per instance
Sensor noise (Accelerometer, Gyroscope, Barometer, GnssReceiver) was drawn from
the process-global NumPy RNG, so it could not be seeded or reproduced, and it was
unsafe under parallel or forked execution where workers share or reset the global
RNG (issue #1042).
Thread an optional seed argument through the Sensor base classes. Each sensor now
owns a numpy.random.Generator from np.random.default_rng(seed) and draws its white
noise and random walk from it instead of np.random. seed=None keeps the noise
random but per-instance, so existing behaviour is unchanged unless a seed is given.
Also adds tests/unit/sensors/test_sensor_seeding.py covering reproducibility,
decorrelation across seeds, independence from the global RNG, and the GnssReceiver
path.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
* DOC: add CHANGELOG entry for sensor noise seeding (#1052)
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
* TST: seed the noisy sensor fixtures instead of the global RNG
Sensor noise now comes from each sensor's own Generator, so the autouse
`_seed_rng` fixture that seeded the global `np.random` no longer made the noisy
assertions deterministic; they would flake on CI. Pass `seed=42` to the noisy
accelerometer, gyroscope, barometer, and gnss fixtures so their noise is
reproducible through the new per-instance seeding, and drop the now-defunct
`_seed_rng` fixture.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
* ENH: serialize the sensor seed and document it
Address review feedback: document the seed argument in every sensor __init__
(this also fills in the name entry that was missing from Gyroscope's docstring),
and carry seed through to_dict/from_dict so it survives serialization, including
GnssReceiver's custom to_dict. from_dict reads it with data.get("seed") so dicts
saved before this change still load, defaulting to None.
Add serialization tests: the seed round-trips through the JSON encoder for every
sensor type, and from_dict defaults the seed to None when the key is absent.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
* TST: cover sensor base-class validation and dunders
Add tests for the argument-validation error paths (measurement range,
orientation, vectorized inputs, export file_format) and the __repr__ / __call__
helpers on Sensor and InertialSensor. These paths were untested; with them
rocketpy/sensors reaches full statement coverage.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
---------
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
0 commit comments