Skip to content

Commit

Permalink
Added is_np_flattenable property to spaces docs (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus28 authored Dec 2, 2022
1 parent c6ee063 commit bd499ee
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
15 changes: 14 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
10 changes: 8 additions & 2 deletions docs/api/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 2 additions & 0 deletions gymnasium/spaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion gymnasium/spaces/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def shape(self) -> tuple[int, ...] | None:

@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:
Expand Down

0 comments on commit bd499ee

Please sign in to comment.