From bd499eef25f99be95e06ffe826cd3c941b5cc46b Mon Sep 17 00:00:00 2001 From: Markus Krimmel Date: Fri, 2 Dec 2022 17:01:42 +0100 Subject: [PATCH] Added `is_np_flattenable` property to spaces docs (#172) --- CONTRIBUTING.md | 15 ++++++++++++++- docs/api/spaces.md | 10 ++++++++-- gymnasium/spaces/__init__.py | 2 ++ gymnasium/spaces/space.py | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f70705e01..5d15edafd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,4 +46,17 @@ In addition, new file and class require top docstrings that should outline the p For classes, code block examples can be provided in the top docstring and not the constructor arguments. To check your docstrings are correct, run `pre-commit run --all-files` or `pydocstyle --source --explain --convention=google`. -If all docstrings that fail, the source and reason for the failure is provided. \ No newline at end of file +If all docstrings that fail, the source and reason for the failure is provided. + +## Building the docs +Make sure that you have install the requirements: +```shell +cd docs +pip install -r requirements.txt +``` +Then run +``` +python scripts/gen_mds.py +make dirhtml +``` +Now, navigate to `_build/dirhtml` and open `index.html` in your browser. \ No newline at end of file diff --git a/docs/api/spaces.md b/docs/api/spaces.md index 4a0ecb391..56cbddee4 100644 --- a/docs/api/spaces.md +++ b/docs/api/spaces.md @@ -13,20 +13,26 @@ spaces/utils spaces/vector_utils ``` +```{eval-rst} +.. automodule:: gymnasium.spaces +``` + +## The Base Class ```{eval-rst} .. autoclass:: gymnasium.spaces.Space ``` -## Attributes +### Attributes ```{eval-rst} .. autoproperty:: gymnasium.spaces.space.Space.shape .. property:: Space.dtype Return the data type of this space. +.. autoproperty:: gymnasium.spaces.space.Space.is_np_flattenable ``` -## Methods +### Methods Each space implements the following functions: diff --git a/gymnasium/spaces/__init__.py b/gymnasium/spaces/__init__.py index dc539d5a6..dc9f7731b 100644 --- a/gymnasium/spaces/__init__.py +++ b/gymnasium/spaces/__init__.py @@ -7,6 +7,8 @@ are vectors in the two-dimensional unit cube, the environment code may contain t self.action_space = spaces.Discrete(3) self.observation_space = spaces.Box(0, 1, shape=(2,)) + +All spaces inherit from the :class:`Space` superclass. """ from gymnasium.spaces.box import Box from gymnasium.spaces.dict import Dict diff --git a/gymnasium/spaces/space.py b/gymnasium/spaces/space.py index 75e72411b..18862826b 100644 --- a/gymnasium/spaces/space.py +++ b/gymnasium/spaces/space.py @@ -85,7 +85,7 @@ class Space(Generic[T_cov]): @property def is_np_flattenable(self) -> bool: - """Checks whether this space can be flattened to a :class:`spaces.Box`.""" + """Checks whether this space can be flattened to a :class:`gymnasium.spaces.Box`.""" raise NotImplementedError def sample(self, mask: Any | None = None) -> T_cov: