Update and rerun pre-commit hooks for better code quality (#179)

This commit is contained in:
Xuehai Pan
2022-12-04 22:24:02 +08:00
committed by GitHub
parent 9157a97c80
commit 7e88559763
185 changed files with 1425 additions and 764 deletions

View File

@@ -24,7 +24,7 @@ title: Utils
.. autoattribute:: gymnasium.Env.action_space
The Space object corresponding to valid actions, all valid actions should be contained with the space. For example, if the action space is of type `Discrete` and gives the value `Discrete(2)`, this means there are two valid discrete actions: 0 & 1.
.. code::
>>> env.action_space
@@ -33,9 +33,9 @@ title: Utils
Box(-3.4028234663852886e+38, 3.4028234663852886e+38, (4,), float32)
.. autoattribute:: gymnasium.Env.observation_space
The Space object corresponding to valid observations, all valid observations should be contained with the space. For example, if the observation space is of type :class:`Box` and the shape of the object is ``(4,)``, this denotes a valid observation will be an array of 4 numbers. We can check the box bounds as well with attributes.
.. code::
>>> env.observation_space.high
@@ -46,19 +46,19 @@ title: Utils
.. autoattribute:: gymnasium.Env.metadata
The metadata of the environment containing rendering modes, rendering fps, etc
.. autoattribute:: gymnasium.Env.render_mode
The render mode of the environment determined at initialisation
.. autoattribute:: gymnasium.Env.reward_range
A tuple corresponding to the minimum and maximum possible rewards for an agent over an episode. The default reward range is set to :math:`(-\infty,+\infty)`.
.. autoattribute:: gymnasium.Env.spec
The ``EnvSpec`` of the environment normally set during :py:meth:`gymnasium.make`
```
```
### Additional Methods

View File

@@ -14,7 +14,7 @@ experimental/vector_wrappers
## Functional Environments
The gymnasium ``Env`` provides high flexibility for the implementation of individual environments however this can complicate parallelism of environments. Therefore, we propose the :class:`gymnasium.experimental.FuncEnv` where each part of environment has its own function related to it.
The gymnasium ``Env`` provides high flexibility for the implementation of individual environments however this can complicate parallelism of environments. Therefore, we propose the :class:`gymnasium.experimental.FuncEnv` where each part of environment has its own function related to it.
## Wrappers
@@ -28,12 +28,13 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
* In v28, we aim to rewrite the VectorEnv to not inherit from Env, as a result new vectorised versions of the wrappers will be provided.
### Lambda Observation Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
.. list-table::
:header-rows: 1
* - Old name
- New name
- Vector version
@@ -71,11 +72,11 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
- VectorDtypeObservation (*)
- Yes
* - :class:`wrappers.PixelObservationWrapper`
- PixelObservation
- PixelObservation
- VectorPixelObservation
- No
* - :class:`NormalizeObservation`
- NormalizeObservation
- NormalizeObservation
- VectorNormalizeObservation
- No
* - :class:`TimeAwareObservation`
@@ -97,12 +98,13 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
```
### Lambda Action Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
.. list-table::
:header-rows: 1
* - Old name
- New name
- Vector version
@@ -130,12 +132,13 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
```
### Lambda Reward Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
.. list-table::
:header-rows: 1
* - Old name
- New name
- Vector version
@@ -154,12 +157,13 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
```
### Common Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
.. list-table::
:header-rows: 1
* - Old name
- New name
- Vector version
@@ -171,7 +175,7 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
- VectorPassiveEnvChecker
* - :class:`wrappers.OrderEnforcing`
- OrderEnforcing
- VectorOrderEnforcing (*)
- VectorOrderEnforcing (*)
* - :class:`wrappers.EnvCompatibility`
- Moved to `shimmy <https://github.com/Farama-Foundation/Shimmy/blob/main/shimmy/openai_gym_compatibility.py>`_
- Not Implemented
@@ -193,12 +197,13 @@ Gymnasium already contains a large collection of wrappers, but we believe that t
```
### Vector Only Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
.. list-table::
:header-rows: 1
* - Old name
- New name
* - :class:`wrappers.VectorListInfo`

View File

@@ -33,4 +33,4 @@ title: Functional
```{eval-rst}
... autoclass:: gymasnium.experimental.func2env.FunctionalJaxCompatibilityEnv
```
```

View File

@@ -43,4 +43,4 @@
```{eval-rst}
```
```

View File

@@ -5,7 +5,7 @@ title: Registry
# Registry
Gymnasium allows users to automatically load environments, pre-wrapped with several important wrappers.
Environments can also be created through python imports.
Environments can also be created through python imports.
## Make
@@ -30,9 +30,8 @@ This will not include environments registered only in OpenAI Gym however can be
.. autofunction:: gymnasium.spec
```
## Pretty print registry
```{eval-rst}
.. autofunction:: gymnasium.pprint_registry
```
```

View File

@@ -2,7 +2,6 @@
title: Spaces
---
# Spaces
```{toctree}
@@ -18,6 +17,7 @@ spaces/vector_utils
```
## The Base Class
```{eval-rst}
.. autoclass:: gymnasium.spaces.Space
```
@@ -42,7 +42,7 @@ Each space implements the following functions:
.. autofunction:: gymnasium.spaces.space.Space.seed
.. autofunction:: gymnasium.spaces.space.Space.to_jsonable
.. autofunction:: gymnasium.spaces.space.Space.from_jsonable
```
```
## Fundamental Spaces
@@ -55,7 +55,7 @@ Gymnasium has a number of fundamental spaces that are used as building boxes for
* :py:class:`Discrete` - Supports a single discrete number of values with an optional start for the values
* :py:class:`MultiDiscrete` - Supports single or matrices of binary values, used for holding down a button or if an agent has an object
* :py:class:`MultiBinary` - Supports multiple discrete values with multiple axes, used for controller actions
* :py:class:`Text` - Supports strings, used for passing agent messages, mission details, etc
* :py:class:`Text` - Supports strings, used for passing agent messages, mission details, etc
```
## Composite Spaces
@@ -71,7 +71,7 @@ Often environment spaces require joining fundamental spaces together for vectori
## Utils
Gymnasium contains a number of helpful utility functions for flattening and unflattening spaces.
Gymnasium contains a number of helpful utility functions for flattening and unflattening spaces.
This can be important for passing information to neural networks.
```{eval-rst}

View File

@@ -7,7 +7,7 @@
.. automethod:: gymnasium.spaces.Dict.sample
.. automethod:: gymnasium.spaces.Dict.seed
```
```
## Tuple
@@ -16,7 +16,7 @@
.. automethod:: gymnasium.spaces.Tuple.sample
.. automethod:: gymnasium.spaces.Tuple.seed
```
```
## Sequence
@@ -25,7 +25,7 @@
.. automethod:: gymnasium.spaces.Sequence.sample
.. automethod:: gymnasium.spaces.Sequence.seed
```
```
## Graph

View File

@@ -12,7 +12,7 @@ title: Fundamental Spaces
.. automethod:: gymnasium.spaces.Box.sample
.. automethod:: gymnasium.spaces.Box.seed
.. automethod:: gymnasium.spaces.Box.is_bounded
```
```
## Discrete
@@ -20,7 +20,7 @@ title: Fundamental Spaces
.. autoclass:: gymnasium.spaces.Discrete
.. automethod:: gymnasium.spaces.Discrete.sample
.. automethod:: gymnasium.spaces.Discrete.seed
```
```
## MultiBinary
@@ -28,7 +28,7 @@ title: Fundamental Spaces
.. autoclass:: gymnasium.spaces.MultiBinary
.. automethod:: gymnasium.spaces.MultiBinary.sample
.. automethod:: gymnasium.spaces.MultiBinary.seed
```
```
## MultiDiscrete
@@ -37,7 +37,7 @@ title: Fundamental Spaces
.. automethod:: gymnasium.spaces.MultiDiscrete.sample
.. automethod:: gymnasium.spaces.MultiDiscrete.seed
```
```
## Text
@@ -46,4 +46,4 @@ title: Fundamental Spaces
.. automethod:: gymnasium.spaces.Text.sample
.. automethod:: gymnasium.spaces.Text.seed
```
```

View File

@@ -9,4 +9,4 @@ title: Utils
.. autofunction:: gymnasium.spaces.utils.flatten
.. autofunction:: gymnasium.spaces.utils.flatdim
.. autofunction:: gymnasium.spaces.utils.unflatten
```
```

View File

@@ -8,7 +8,7 @@ title: Vector Utils
.. autofunction:: gymnasium.vector.utils.batch_space
.. autofunction:: gymnasium.vector.utils.concatenate
.. autofunction:: gymnasium.vector.utils.iterate
```
```
## Shared Memory Utils

View File

@@ -9,11 +9,11 @@ title: Utils
```{eval-rst}
.. autofunction:: gymnasium.utils.play.play
.. autoclass:: gymnasium.utils.play.PlayPlot
.. automethod:: callback
.. autoclass:: gymnasium.utils.play.PlayableGame
.. automethod:: process_event
```
@@ -42,4 +42,4 @@ title: Utils
```{eval-rst}
.. autofunction:: gymnasium.utils.env_checker.check_env
```
```

View File

@@ -42,9 +42,9 @@ wrappers/reward_wrappers
.. autoproperty:: gymnasium.Wrapper.np_random
.. attribute:: gymnasium.Wrapper.env
The environment (one level underneath) this wrapper.
This may itself be a wrapped environment.
The environment (one level underneath) this wrapper.
This may itself be a wrapped environment.
To obtain the environment underneath all layers of wrappers, use :attr:`gymnasium.Wrapper.unwrapped`.
.. autoproperty:: gymnasium.Wrapper.unwrapped
@@ -52,88 +52,88 @@ wrappers/reward_wrappers
## Gymnasium Wrappers
Gymnasium provides a number of commonly used wrappers listed below. More information can be found on the particular
Gymnasium provides a number of commonly used wrappers listed below. More information can be found on the particular
wrapper in the page on the wrapper type
```{eval-rst}
.. py:currentmodule:: gymnasium.wrappers
.. list-table::
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - :class:`AtariPreprocessing`
- Misc Wrapper
- Implements the common preprocessing applied tp Atari environments
* - :class:`AutoResetWrapper`
- Misc Wrapper
- The wrapped environment will automatically reset when the terminated or truncated state is reached.
* - :class:`ClipAction`
- Action Wrapper
- Clip the continuous action to the valid bound specified by the environment's `action_space`
* - :class:`EnvCompatibility`
- Misc Wrapper
- Provides compatibility for environments written in the OpenAI Gym v0.21 API to look like Gymnasium environments
* - :class:`FilterObservation`
- Observation Wrapper
- Filters a dictionary observation spaces to only requested keys
* - :class:`FlattenObservation`
- Observation Wrapper
- An Observation wrapper that flattens the observation
* - :class:`FrameStack`
- Observation Wrapper
- AnObservation wrapper that stacks the observations in a rolling manner.
* - :class:`GrayScaleObservation`
- Observation Wrapper
- Convert the image observation from RGB to gray scale.
* - :class:`HumanRendering`
- Misc Wrapper
- Allows human like rendering for environments that support "rgb_array" rendering
* - :class:`NormalizeObservation`
- Observation Wrapper
- This wrapper will normalize observations s.t. each coordinate is centered with unit variance.
* - :class:`NormalizeReward`
- Reward Wrapper
- This wrapper will normalize immediate rewards s.t. their exponential moving average has a fixed variance.
* - :class:`OrderEnforcing`
- Misc Wrapper
- This will produce an error if `step` or `render` is called before `reset`
* - :class:`PixelObservationWrapper`
- Observation Wrapper
- Augment observations by pixel values obtained via `render` that can be added to or replaces the environments observation.
* - :class:`RecordEpisodeStatistics`
- Misc Wrapper
- This will keep track of cumulative rewards and episode lengths returning them at the end.
* - :class:`RecordVideo`
- Misc Wrapper
- This wrapper will record videos of rollouts.
* - :class:`RenderCollection`
- Misc Wrapper
- Enable list versions of render modes, i.e. "rgb_array_list" for "rgb_array" such that the rendering for each step are saved in a list until `render` is called.
* - :class:`RescaleAction`
- Action Wrapper
- Rescales the continuous action space of the environment to a range \[`min_action`, `max_action`], where `min_action` and `max_action` are numpy arrays or floats.
* - :class:`ResizeObservation`
- Observation Wrapper
- This wrapper works on environments with image observations (or more generally observations of shape AxBxC) and resizes the observation to the shape given by the tuple `shape`.
* - :class:`StepAPICompatibility`
- Misc Wrapper
- Modifies an environment step function from (old) done to the (new) termination / truncation API.
* - :class:`TimeAwareObservation`
- Observation Wrapper
- Augment the observation with current time step in the trajectory (by appending it to the observation).
* - :class:`TimeLimit`
- Misc Wrapper
- This wrapper will emit a truncated signal if the specified number of steps is exceeded in an episode.
* - :class:`TransformObservation`
- Observation Wrapper
- This wrapper will apply function to observations
* - :class:`TransformReward`
- Reward Wrapper
- This wrapper will apply function to rewards
* - :class:`VectorListInfo`
- Misc Wrapper
- This wrapper will convert the info of a vectorized environment from the `dict` format to a `list` of dictionaries where the i-th dictionary contains info of the i-th environment.
```
* - :class:`AtariPreprocessing`
- Misc Wrapper
- Implements the common preprocessing applied tp Atari environments
* - :class:`AutoResetWrapper`
- Misc Wrapper
- The wrapped environment will automatically reset when the terminated or truncated state is reached.
* - :class:`ClipAction`
- Action Wrapper
- Clip the continuous action to the valid bound specified by the environment's `action_space`
* - :class:`EnvCompatibility`
- Misc Wrapper
- Provides compatibility for environments written in the OpenAI Gym v0.21 API to look like Gymnasium environments
* - :class:`FilterObservation`
- Observation Wrapper
- Filters a dictionary observation spaces to only requested keys
* - :class:`FlattenObservation`
- Observation Wrapper
- An Observation wrapper that flattens the observation
* - :class:`FrameStack`
- Observation Wrapper
- AnObservation wrapper that stacks the observations in a rolling manner.
* - :class:`GrayScaleObservation`
- Observation Wrapper
- Convert the image observation from RGB to gray scale.
* - :class:`HumanRendering`
- Misc Wrapper
- Allows human like rendering for environments that support "rgb_array" rendering
* - :class:`NormalizeObservation`
- Observation Wrapper
- This wrapper will normalize observations s.t. each coordinate is centered with unit variance.
* - :class:`NormalizeReward`
- Reward Wrapper
- This wrapper will normalize immediate rewards s.t. their exponential moving average has a fixed variance.
* - :class:`OrderEnforcing`
- Misc Wrapper
- This will produce an error if `step` or `render` is called before `reset`
* - :class:`PixelObservationWrapper`
- Observation Wrapper
- Augment observations by pixel values obtained via `render` that can be added to or replaces the environments observation.
* - :class:`RecordEpisodeStatistics`
- Misc Wrapper
- This will keep track of cumulative rewards and episode lengths returning them at the end.
* - :class:`RecordVideo`
- Misc Wrapper
- This wrapper will record videos of rollouts.
* - :class:`RenderCollection`
- Misc Wrapper
- Enable list versions of render modes, i.e. "rgb_array_list" for "rgb_array" such that the rendering for each step are saved in a list until `render` is called.
* - :class:`RescaleAction`
- Action Wrapper
- Rescales the continuous action space of the environment to a range \[`min_action`, `max_action`], where `min_action` and `max_action` are numpy arrays or floats.
* - :class:`ResizeObservation`
- Observation Wrapper
- This wrapper works on environments with image observations (or more generally observations of shape AxBxC) and resizes the observation to the shape given by the tuple `shape`.
* - :class:`StepAPICompatibility`
- Misc Wrapper
- Modifies an environment step function from (old) done to the (new) termination / truncation API.
* - :class:`TimeAwareObservation`
- Observation Wrapper
- Augment the observation with current time step in the trajectory (by appending it to the observation).
* - :class:`TimeLimit`
- Misc Wrapper
- This wrapper will emit a truncated signal if the specified number of steps is exceeded in an episode.
* - :class:`TransformObservation`
- Observation Wrapper
- This wrapper will apply function to observations
* - :class:`TransformReward`
- Reward Wrapper
- This wrapper will apply function to rewards
* - :class:`VectorListInfo`
- Misc Wrapper
- This wrapper will convert the info of a vectorized environment from the `dict` format to a `list` of dictionaries where the i-th dictionary contains info of the i-th environment.
```

View File

@@ -9,8 +9,8 @@
```
## Available Action Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.ClipAction
.. autoclass:: gymnasium.wrappers.RescaleAction
```

View File

@@ -1,4 +1,5 @@
# Misc Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.AtariPreprocessing
.. autoclass:: gymnasium.wrappers.AutoResetWrapper