From df811e7d54bb4472869e963f5ff93f1ec81c20db Mon Sep 17 00:00:00 2001 From: Ephraim Date: Mon, 28 Nov 2022 14:17:49 -0800 Subject: [PATCH] Flatten space docstring note about unflattening samples (#164) --- gymnasium/spaces/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gymnasium/spaces/utils.py b/gymnasium/spaces/utils.py index 6c93479d0..954a96d68 100644 --- a/gymnasium/spaces/utils.py +++ b/gymnasium/spaces/utils.py @@ -367,8 +367,11 @@ def flatten_space(space: Space[Any]) -> Box | Dict | Sequence | Tuple | Graph: the result for graph spaces is always a `Graph` with `node_space` being a `Box` with flat boundaries and `edge_space` being a `Box` with flat boundaries or `None`. The box has exactly :func:`flatdim` dimensions. Flattening a sample - of the original space has the same effect as taking a sample of the flattenend - space. + of the original space has the same effect as taking a sample of the flattened + space. However, sampling from the flattened space is not necessarily reversible. + For example, sampling from a flattened Discrete space is the same as sampling from + a Box, and the results may not be integers or one-hot encodings. This may result in + errors or non-uniform sampling. Example:: >>> from gymnasium.spaces import Box