From 4d44b60f04e9aaa6712cdcef2aee082e609ee10f Mon Sep 17 00:00:00 2001 From: pseudo-rnd-thoughts Date: Tue, 3 Sep 2024 11:55:47 +0100 Subject: [PATCH] Update doctest --- gymnasium/spaces/dict.py | 2 +- gymnasium/spaces/discrete.py | 4 ++-- gymnasium/spaces/oneof.py | 4 ++-- gymnasium/spaces/tuple.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gymnasium/spaces/dict.py b/gymnasium/spaces/dict.py index 128cf8c71..49ff4c907 100644 --- a/gymnasium/spaces/dict.py +++ b/gymnasium/spaces/dict.py @@ -20,7 +20,7 @@ class Dict(Space[typing.Dict[str, Any]], typing.Mapping[str, Space[Any]]): >>> from gymnasium.spaces import Dict, Box, Discrete >>> observation_space = Dict({"position": Box(-1, 1, shape=(2,)), "color": Discrete(3)}, seed=42) >>> observation_space.sample() - {'color': 0, 'position': array([-0.3991573 , 0.21649833], dtype=float32)} + {'color': np.int64(0), 'position': array([-0.3991573 , 0.21649833], dtype=float32)} With a nested dict: diff --git a/gymnasium/spaces/discrete.py b/gymnasium/spaces/discrete.py index 41b9c356a..9a4575252 100644 --- a/gymnasium/spaces/discrete.py +++ b/gymnasium/spaces/discrete.py @@ -18,10 +18,10 @@ class Discrete(Space[np.int64]): >>> from gymnasium.spaces import Discrete >>> observation_space = Discrete(2, seed=42) # {0, 1} >>> observation_space.sample() - 0 + np.int64(0) >>> observation_space = Discrete(3, start=-1, seed=42) # {-1, 0, 1} >>> observation_space.sample() - -1 + np.int64(-1) """ def __init__( diff --git a/gymnasium/spaces/oneof.py b/gymnasium/spaces/oneof.py index 08aa50a5a..50e463be4 100644 --- a/gymnasium/spaces/oneof.py +++ b/gymnasium/spaces/oneof.py @@ -19,9 +19,9 @@ class OneOf(Space[Any]): >>> from gymnasium.spaces import OneOf, Box, Discrete >>> observation_space = OneOf((Discrete(2), Box(-1, 1, shape=(2,))), seed=123) >>> observation_space.sample() # the first element is the space index (Box in this case) and the second element is the sample from Box - (0, 0) + (np.int64(0), np.int64(0)) >>> observation_space.sample() # this time the Discrete space was sampled as index=0 - (1, array([-0.00711833, -0.7257502 ], dtype=float32)) + (np.int64(1), array([-0.00711833, -0.7257502 ], dtype=float32)) >>> observation_space[0] Discrete(2) >>> observation_space[1] diff --git a/gymnasium/spaces/tuple.py b/gymnasium/spaces/tuple.py index b14527650..05a1f652a 100644 --- a/gymnasium/spaces/tuple.py +++ b/gymnasium/spaces/tuple.py @@ -19,7 +19,7 @@ class Tuple(Space[typing.Tuple[Any, ...]], typing.Sequence[Any]): >>> from gymnasium.spaces import Tuple, Box, Discrete >>> observation_space = Tuple((Discrete(2), Box(-1, 1, shape=(2,))), seed=42) >>> observation_space.sample() - (0, array([-0.3991573 , 0.21649833], dtype=float32)) + (np.int64(0), array([-0.3991573 , 0.21649833], dtype=float32)) """ def __init__(