Check that the observation space is correctly formatted when dealing with a ``Box()`` space. In particular, it checks: - that the dimensions are big enough when it is an image, and that the type matches - that the observation has an expected shape (warn the user if not)
(observation_space: spaces.Box, key: str = "")
| 309 | |
| 310 | |
| 311 | def _check_box_obs(observation_space: spaces.Box, key: str = "") -> None: |
| 312 | """ |
| 313 | Check that the observation space is correctly formatted |
| 314 | when dealing with a ``Box()`` space. In particular, it checks: |
| 315 | - that the dimensions are big enough when it is an image, and that the type matches |
| 316 | - that the observation has an expected shape (warn the user if not) |
| 317 | """ |
| 318 | # If image, check the low and high values, the type and the number of channels |
| 319 | # and the shape (minimal value) |
| 320 | if len(observation_space.shape) == 3: |
| 321 | _check_image_input(observation_space, key) |
| 322 | |
| 323 | if len(observation_space.shape) not in [1, 3]: |
| 324 | warnings.warn( |
| 325 | f"Your observation {key} has an unconventional shape (neither an image, nor a 1D vector). " |
| 326 | "We recommend you to flatten the observation " |
| 327 | "to have only a 1D vector or use a custom policy to properly process the data." |
| 328 | ) |
| 329 | |
| 330 | |
| 331 | def _check_returned_values(env: gym.Env, observation_space: spaces.Space, action_space: spaces.Space) -> None: |
no test coverage detected
searching dependent graphs…