Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Equals Method of gym.spaces.Tuple does not Work Correclty #2479

Closed
maximilianreimer opened this issue Nov 3, 2021 · 1 comment · Fixed by #2491
Closed

[Bug Report] Equals Method of gym.spaces.Tuple does not Work Correclty #2479

maximilianreimer opened this issue Nov 3, 2021 · 1 comment · Fixed by #2491

Comments

@maximilianreimer
Copy link

Describe the bug
Equals methods of gym.spaces.Tuple does state that two Space instances do not equal if they contain the same Space but instance a was initialized using a list of subspaces and b using a tuple of instances.

Suggestion:

  1. Convert lists to a tuples in __init__
  2. Raise error if list is passed to __init__
  3. Change __eq__

Code example

from gym.spaces import Tuple
t1 = Tuple(tuple())
t2 = Tuple(list())

t1 == t2

System Info
Describe the characteristic of your environment:

  • pip install gym==0.15.3
  • openSUSE Leap 15.3
  • Python version: 3.6.13
@MathieuTuli
Copy link

opinion: This is a valid bug, and I think suggestion #1 makes most sense. Internally, gym.spaces.Tuple already performs promotion to tuples (See here) to account for the very issue that this issue raises (passing a list instead of a tuple). Functionally, this class should behave as a Tuple, so having an internal list representation is flawed, and should be converted to a tuple.

The fix is straightforward, have a PR on standby pending no disagreements with the above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants