MCPcopy
hub / github.com/DLR-RM/stable-baselines3 / _check_box_obs

Function _check_box_obs

stable_baselines3/common/env_checker.py:311–328  ·  view source on GitHub ↗

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 = "")

Source from the content-addressed store, hash-verified

309
310
311def _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
331def _check_returned_values(env: gym.Env, observation_space: spaces.Space, action_space: spaces.Space) -> None:

Callers 1

check_envFunction · 0.85

Calls 2

_check_image_inputFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…