Download tests/test_simulator.py from sroecker/seal-cell: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/sroecker/seal-cell/resolve/main/tests/test_simulator.py
- Command line
-
hf download hf://spaces/sroecker/seal-cell/tests/test_simulator.py
-
curl -L -o test_simulator.py https://huggingface.co/spaces/sroecker/seal-cell/resolve/main/tests/test_simulator.py
2.17 kB
| import pytest | |
| from sealcell.config import config | |
| from sealcell.contracts import Action, Stage | |
| from sealcell.policies import RulePolicy | |
| from sealcell.simulator import Simulator | |
| from sealcell.supervisor import Supervisor | |
| def test_scenarios_bounded_and_causal(scenario, seed): | |
| sup = Supervisor(Simulator(scenario, seed), RulePolicy()).run() | |
| s = sup.simulator | |
| assert s.done and s.decisions <= 12 and s.time <= 300 and s.corrections <= 3 | |
| assert s.truth.released_bad == 0 | |
| assert (s.stage == Stage.DONE) == config("scenarios")[scenario]["recoverable"] | |
| def test_seeded_replay_independent_of_observation_calls(): | |
| a, b = Simulator("low-pressure", 99), Simulator("low-pressure", 99) | |
| for _ in range(19): | |
| b.observe() | |
| a.execute(Action.RESTORE_PRESSURE) | |
| b.execute(Action.RESTORE_PRESSURE) | |
| assert a.observe() == b.observe() | |
| assert a.quality("event") == b.quality("event") | |
| def test_oracle_physics_recovery_and_failure(): | |
| # Oracle is confined to validation and never enters policy inputs. | |
| for scenario in config("scenarios"): | |
| s = Simulator(scenario) | |
| p = s._plant | |
| if abs(p.temperature - s.recipe.temperature) > 5: | |
| s.execute(Action.CONDITION_TO_RECIPE) | |
| if abs(p.pressure - s.recipe.pressure) > 0.3: | |
| s.execute(Action.RESTORE_PRESSURE) | |
| if p.dwell < s.recipe.profiles["standard"].limits[0]: | |
| s.execute(Action.USE_LONGER_DWELL) | |
| if p.contamination: | |
| s.execute(Action.CLEAN_JAWS) | |
| if s.truth.recoverable: | |
| assert s.quality("oracle") >= s.physics["quality_pass"] | |
| if scenario in {"pressure-actuator-failure", "ineffective-cleaning"}: | |
| assert s.quality("oracle") < s.physics["quality_pass"] | |
| def test_distinct_recipe_and_profile_change(): | |
| s = Simulator("short-dwell", recipe_name="B") | |
| s.passing_samples = 2 | |
| s.execute(Action.USE_LONGER_DWELL) | |
| assert s.profile == "longer" and s.passing_samples == 0 | |
| assert s.observe().recipe.profiles["longer"].limits[0] <= s._plant.dwell | |