Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/envs/test_auto_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_native_auto_reset_step_and_maybe_reset(self):
)

assert tensordict["next", "done"].all()
assert (tensordict["next", "observation"] == 0).all()
assert (tensordict["next", "observation"] == tensordict["observation"]).all()
assert not tensordict_["done"].any()
assert tensordict_["is_init"].all()

Expand Down
3 changes: 2 additions & 1 deletion torchrl/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3693,8 +3693,9 @@ def _native_autoreset_set_invalid_next_observation(
if obs is None or not isinstance(obs, torch.Tensor):
continue
reset_observations[obs_key] = obs.clone()
current_obs = tensordict.get(obs_key, None)
if obs.is_floating_point():
obs[done] = torch.nan
obs[done] = current_obs[done]
else:
obs[done] = 0
return reset_observations
Expand Down
4 changes: 2 additions & 2 deletions torchrl/envs/libs/gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ class GymWrapper(GymLikeEnv, metaclass=_GymAsyncMeta):
observation returned by the environment as the next root observation
instead of calling reset from
:meth:`~torchrl.envs.EnvBase.step_and_maybe_reset`. The terminal
``"next"`` observation is still invalid and filled with ``NaN`` for
floating point observations. Defaults to ``False``.
``"next"`` observation is replaced with the current (root)
observation. Defaults to ``False``.

Attributes:
available_envs (List[str]): a list of environments to build.
Expand Down
4 changes: 2 additions & 2 deletions torchrl/envs/transforms/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ class VecGymEnvTransform(Transform):
native_autoreset (bool, optional): if ``True``, leaves the native
auto-reset observation available to the environment wrapper so it
can be cloned into the next root observation, while the terminal
floating point ``"next"`` observation is marked with ``NaN``.
Defaults to ``False``.
``"next"`` observation is replaced with the current (root)
observation. Defaults to ``False``.

.. note:: In general, this class should not be handled directly. It is
created whenever a vectorized environment is placed within a :class:`GymWrapper`.
Expand Down
Loading