Skip to content

Commit cb70050

Browse files
committed
TST: stop the isolation test from storing one wrapper twice
stochastic_calisto already holds the stochastic_nose_cone fixture, so adding it again put the test into the state #1172 describes: one wrapper in two entries, its position overwritten, and two reseeds landing on the same object. The assertion looked at a different collection and passed anyway. It adds the deterministic nose now, so add_nose builds a wrapper of its own. Nothing pinned the body keeping the seed as given either. Reproducibility and seed uniqueness both hold with the body on a spawned child, so neither would have noticed it going back there. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent dcc0664 commit cb70050

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎rocketpy/stochastic/stochastic_rocket.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def __init__(
176176
coordinate_system_orientation=None,
177177
)
178178

179-
# Nested stochastic objects, in spawn order
179+
# Nested stochastic objects, in spawn order. Append rather than reorder:
180+
# the position of a name here addresses its collection's stream.
180181
_POSITIONED_COLLECTIONS = ("aerodynamic_surfaces", "motors", "rail_buttons")
181182
_PLAIN_COLLECTIONS = ("parachutes", "air_brakes")
182183

‎tests/unit/stochastic/test_stochastic_rocket_seeding.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def parachute_draw():
164164
return _drawn(stochastic_calisto.parachutes[0])
165165

166166
before = parachute_draw()
167-
stochastic_calisto.add_nose(stochastic_nose_cone, position=1.1)
167+
# The deterministic nose, so add_nose builds a wrapper of its own. Adding
168+
# the fixture again would store one wrapper twice, which is #1172.
169+
stochastic_calisto.add_nose(stochastic_nose_cone.obj, position=1.1)
168170

169171
assert parachute_draw() == before
170172

@@ -235,3 +237,15 @@ def drawn(seed):
235237
assert first[0] != first[1], "two air brakes drew the same value"
236238
assert drawn(808) == first
237239
assert drawn(809) != first
240+
241+
242+
def test_the_rocket_body_keeps_the_seed_as_given(monkeypatch, stochastic_calisto):
243+
"""Fixing the nested components did not need the body's stream to move.
244+
245+
Reproducibility and seed uniqueness both hold with the body on a spawned
246+
child, so neither of them would notice it going back there and taking every
247+
fixed-seed mass and radius baseline with it.
248+
"""
249+
seeds = _seeds_handed_out(monkeypatch, stochastic_calisto, 42)
250+
251+
assert seeds[0] == 42

0 commit comments

Comments
 (0)