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

spaces.Dict: Make sorted(spaces.items()) optional #1072

Open
carlocagnetta opened this issue May 29, 2024 · 2 comments
Open

spaces.Dict: Make sorted(spaces.items()) optional #1072

carlocagnetta opened this issue May 29, 2024 · 2 comments

Comments

@carlocagnetta
Copy link

carlocagnetta commented May 29, 2024

Sorting the dictionary's entries it's probably not always wanted, but unfortunately there is no way around it other than overwriting self.spaces after initializing a spaces.Dict. It would be handy to make this optional, maybe with default parameter for backwards compatibility if needed.

https://github.com/Farama-Foundation/Gymnasium/blame/0607994d37a8079945ed0e0416ff750a3ad2e26f/gymnasium/spaces/dict.py#L73

@carlocagnetta carlocagnetta changed the title Make sort() optional spaces.Dict: Make sorted(spaces.items()) optional May 29, 2024
@carlocagnetta
Copy link
Author

@MischaPanch even by resetting self.spaces after initializing the dict space, it will again brake the order when using any ObsWrapper, for example FrameStackObservation

@pseudo-rnd-thoughts
Copy link
Member

@carlocagnetta Interesting suggestions, similarly I don't like needing to sort the dictionary data as it is a product of technical debt when python dictionaries weren't insertion sorted.
I agree, that adding an argument would solve this issue.

Could you make a PR for it?

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

No branches or pull requests

2 participants