Skip to content

unflatten always gives 0 class #1196

Description

@wadmes
from gymnasium.spaces import Dict, Box, Discrete
from gymnasium import spaces
observation_space = Dict({"position": Box(-1, 1, shape=(2,)), "color": Discrete(5)}, seed=42)
flatten = spaces.flatten_space(observation_space)
obs1 = flatten.sample()
unflat = spaces.utils.unflatten(observation_space,obs1)
print(obs1)
print(unflat)

obs1:

array([ 0.47568119,  0.64470851,  0.93992918,  0.0658021 ,  0.74573835,
        0.68031875, -0.96546865])

unflat:

OrderedDict({'color': 0, 'position': array([ 0.6803188 , -0.96546865], dtype=float32)})

The result of unflat will always gives color = 0, even though it is not in obs1`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions