mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-11-18 09:54:10 +00:00
Fix stable_baselines3/common/preprocessing.py type hints (#1217)
This commit is contained in:
parent
6d55a09f81
commit
07094c3f2e
3 changed files with 3 additions and 2 deletions
|
|
@ -45,6 +45,7 @@ Others:
|
||||||
- Fixed ``stable_baselines3/common/type_aliases.py`` type hint
|
- Fixed ``stable_baselines3/common/type_aliases.py`` type hint
|
||||||
- Fixed ``stable_baselines3/common/torch_layers.py`` type hint
|
- Fixed ``stable_baselines3/common/torch_layers.py`` type hint
|
||||||
- Fixed ``stable_baselines3/common/env_util.py`` type hint
|
- Fixed ``stable_baselines3/common/env_util.py`` type hint
|
||||||
|
- Fixed ``stable_baselines3/common/preprocessing.py`` type hints
|
||||||
- Exposed modules in ``__init__.py`` with the ``__all__`` attribute (@ZikangXiong)
|
- Exposed modules in ``__init__.py`` with the ``__all__`` attribute (@ZikangXiong)
|
||||||
- Upgraded GitHub CI/setup-python to v4 and checkout to v3
|
- Upgraded GitHub CI/setup-python to v4 and checkout to v3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ exclude = (?x)(
|
||||||
| stable_baselines3/common/off_policy_algorithm.py$
|
| stable_baselines3/common/off_policy_algorithm.py$
|
||||||
| stable_baselines3/common/on_policy_algorithm.py$
|
| stable_baselines3/common/on_policy_algorithm.py$
|
||||||
| stable_baselines3/common/policies.py$
|
| stable_baselines3/common/policies.py$
|
||||||
| stable_baselines3/common/preprocessing.py$
|
|
||||||
| stable_baselines3/common/save_util.py$
|
| stable_baselines3/common/save_util.py$
|
||||||
| stable_baselines3/common/sb2_compat/rmsprop_tf_like.py$
|
| stable_baselines3/common/sb2_compat/rmsprop_tf_like.py$
|
||||||
| stable_baselines3/common/utils.py$
|
| stable_baselines3/common/utils.py$
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ def preprocess_obs(
|
||||||
|
|
||||||
elif isinstance(observation_space, spaces.Dict):
|
elif isinstance(observation_space, spaces.Dict):
|
||||||
# Do not modify by reference the original observation
|
# Do not modify by reference the original observation
|
||||||
|
assert isinstance(obs, Dict), f"Expected dict, got {type(obs)}"
|
||||||
preprocessed_obs = {}
|
preprocessed_obs = {}
|
||||||
for key, _obs in obs.items():
|
for key, _obs in obs.items():
|
||||||
preprocessed_obs[key] = preprocess_obs(_obs, observation_space[key], normalize_images=normalize_images)
|
preprocessed_obs[key] = preprocess_obs(_obs, observation_space[key], normalize_images=normalize_images)
|
||||||
|
|
@ -155,7 +156,7 @@ def get_obs_shape(
|
||||||
else:
|
else:
|
||||||
return (int(observation_space.n),)
|
return (int(observation_space.n),)
|
||||||
elif isinstance(observation_space, spaces.Dict):
|
elif isinstance(observation_space, spaces.Dict):
|
||||||
return {key: get_obs_shape(subspace) for (key, subspace) in observation_space.spaces.items()}
|
return {key: get_obs_shape(subspace) for (key, subspace) in observation_space.spaces.items()} # type: ignore[misc]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"{observation_space} observation space is not supported")
|
raise NotImplementedError(f"{observation_space} observation space is not supported")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue