Repository navigation
Conversation
This branch has not been deployed
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.
Uploading through the GitHub website. Make branch
fix/return-new-info-dictswith the first upload, then upload the rest to the same branch, one folder at a time, with these commit messages. Each upload replaces the existing files.PyFlyt/gym_envs/quadx_envs/: all 7 files:gym_envs: return a new info dict from every QuadX reset and stepPyFlyt/gym_envs/fixedwing_envs/: both files:gym_envs: return a new info dict from every Fixedwing reset and stepPyFlyt/gym_envs/rocket_envs/: both files:gym_envs: return a new info dict from every Rocket reset and steptests/test_gym_envs.py:tests: check that infos kept from an episode don't changeDescription
Every gym env returns its own
self.infofromreset()andstep(). As a result, every info a user keeps from an episode is the same dict, and the earlier ones change as the episode goes on. The usual way to hit this is a rollout buffer that stores infos. After an episode that ends out of bounds, the info kept fromreset()readsout_of_bounds=Truetoo:The script that prints this is below. The waypoint envs behave the same way.
Gymnasium 1.4.0 (released 2026-10-05) now checks for this:
check_envfails with "The infos returned byenv.reset() (call 1)andenv.step() (call 2)share an object". Onmasterwith a fresh install, this makes all 28test_check_envand all 24test_flatten_envcases fail.gym.make().This PR returns
self.info.copy()from the 11reset()/step()return sites ingym_envs. The info values are bools and ints, so a shallow copy is enough. It also addstest_infos_not_shared, which keeps the infos from an episode and checks that they are all distinct objects and that none of them changed. The test doesn't depend on the gymnasium version. The PettingZoo envs already build new info dicts each step, so they aren't changed.Testing
Run on Linux under xvfb, as in CI, with Python 3.12, gymnasium 1.4.0, numpy 1.26.4, pybullet 3.2.7, pettingzoo 1.27.0 and numba 0.68.0:
masterpytest teststest_check_env+test_flatten_envtest_render[human-*]in the full runpybullet.error: Not connected to physics server/ "Only one local in-process GUI connection allowed"test_infos_not_sharedOn
master, the human render tests pass whentest_renderruns on its own (56 passed), so their failures in the full run look like a knock-on from the earlier failures, not a separate problem. With this PR they pass in the full run.With gymnasium 1.3.0, which doesn't have the new check, the affected tests (
check_env,flatten_env,seeding,infos_not_shared) also pass on this branch: 108 passed.Pre-commit passes on the changed files except for two hooks that fail on
mastertoo:pydocstyle: D417 for the undocumentedworld_scaleargument inQuadXBaseEnv.__init__, added in Two small changes to expose more options in constructors #95.pyright:spaces.Dicttyping errors with gymnasium 1.4, in lines this PR doesn't touch.Script used for the output above:
While testing I also noticed that
PyFlyt/QuadX-Gates-v3can't reset. It loads../models/race_gate.urdfrelative togym_envs/quadx_envs/, but the model is inPyFlyt/models/. With that path fixed, its first observation failscheck_env's observation-space check. It isn't in the tests or the docs, so I've left it out of this PR. I'm happy to open an issue for it.