mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-12-17 01:58:32 +00:00
Removing return_info argument to env.reset() and deprecated env.seed() function (reset now always returns info) (#2962)
* removed return_info, made info dict mandatory in reset * tenatively removed deprecated seed api for environments * added more info type checks to wrapper tests * formatting/style compliance * addressed some comments * polish to address review * fixed tests after merge, and added a test of the return_info deprecation assertion if found in reset signature * some organization of env_checker tests, reverted a probably merge error * added deprecation check for seed function in env * updated docstring * removed debug prints, tweaked test_check_seed_deprecation * changed return_info deprecation check from assertion to warning * fixes to vector envs, now should be correctly structured * added some explanation and typehints for mockup depcreated return info reset function * re-removed seed function from vector envs * added explanation to _reset_return_info_type and changed the return statement
This commit is contained in:
@@ -24,7 +24,7 @@ def test_create_sync_vector_env():
|
||||
def test_reset_sync_vector_env():
|
||||
env_fns = [make_env("CartPole-v1", i) for i in range(8)]
|
||||
env = SyncVectorEnv(env_fns)
|
||||
observations = env.reset()
|
||||
observations, infos = env.reset()
|
||||
env.close()
|
||||
|
||||
assert isinstance(env.observation_space, Box)
|
||||
@@ -35,32 +35,6 @@ def test_reset_sync_vector_env():
|
||||
|
||||
del observations
|
||||
|
||||
env = SyncVectorEnv(env_fns)
|
||||
observations = env.reset(return_info=False)
|
||||
env.close()
|
||||
|
||||
assert isinstance(env.observation_space, Box)
|
||||
assert isinstance(observations, np.ndarray)
|
||||
assert observations.dtype == env.observation_space.dtype
|
||||
assert observations.shape == (8,) + env.single_observation_space.shape
|
||||
assert observations.shape == env.observation_space.shape
|
||||
|
||||
del observations
|
||||
|
||||
env_fns = [make_env("CartPole-v1", i) for i in range(8)]
|
||||
|
||||
env = SyncVectorEnv(env_fns)
|
||||
observations, infos = env.reset(return_info=True)
|
||||
env.close()
|
||||
|
||||
assert isinstance(env.observation_space, Box)
|
||||
assert isinstance(observations, np.ndarray)
|
||||
assert observations.dtype == env.observation_space.dtype
|
||||
assert observations.shape == (8,) + env.single_observation_space.shape
|
||||
assert observations.shape == env.observation_space.shape
|
||||
assert isinstance(infos, dict)
|
||||
assert all([isinstance(info, dict) for info in infos])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("use_single_action_space", [True, False])
|
||||
def test_step_sync_vector_env(use_single_action_space):
|
||||
@@ -145,7 +119,7 @@ def test_custom_space_sync_vector_env():
|
||||
env_fns = [make_custom_space_env(i) for i in range(4)]
|
||||
|
||||
env = SyncVectorEnv(env_fns)
|
||||
reset_observations = env.reset()
|
||||
reset_observations, infos = env.reset()
|
||||
|
||||
assert isinstance(env.single_action_space, CustomSpace)
|
||||
assert isinstance(env.action_space, Tuple)
|
||||
|
||||
Reference in New Issue
Block a user