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

Disallow Box low > high and low == inf and high == -inf #495

Merged
merged 16 commits into from
May 15, 2023

Conversation

jjshoots
Copy link
Member

@jjshoots jjshoots commented May 8, 2023

Description

This disallows the user from creating box spaces where the range is 0.

Fixes #493

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pseudo-rnd-thoughts pseudo-rnd-thoughts changed the title Disallow Degenerate box space Disable Box with inf lower bounds and -inf upper bounds May 8, 2023
@pseudo-rnd-thoughts pseudo-rnd-thoughts changed the title Disable Box with inf lower bounds and -inf upper bounds Disable Box low > high and low == inf and high == -inf May 8, 2023
@pseudo-rnd-thoughts
Copy link
Member

As np.random.uniform(low=0, high=0) is supported, I think we should support this case despite how weird it is to only be able to sample for a single value.

Therefore, I propose you just prevent three cases, np.any(low > high), np.any(low == np.inf) and np.any(high == -np.inf).
I think these are reasonable changes and should address the issue in #493

@pseudo-rnd-thoughts
Copy link
Member

@jjshoots Are you happy with the changes that I made? If so, I'm happy to merge

@pseudo-rnd-thoughts pseudo-rnd-thoughts changed the title Disable Box low > high and low == inf and high == -inf Disallow Box low > high and low == inf and high == -inf May 15, 2023
@jjshoots
Copy link
Member Author

@pseudo-rnd-thoughts Yep, SGTM.

@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit 1554830 into Farama-Foundation:main May 15, 2023
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

Successfully merging this pull request may close these issues.

[Bug Report] Box contains treats float(inf) unexpectedly
2 participants