-
-
Notifications
You must be signed in to change notification settings - Fork 891
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] Box casting during init can cause invalid sampled values #768
Comments
My intuition is to raise an error within |
Sure, I can make a PR. I think raising an error makes sense, but it'd also mean that integer boxes could no longer be unbounded (since ints can't be inf). Is that what we'd want? Also, is that case, it seems like it'd have a lot of overlap with a MultiDiscrete space, so I'd wonder what the benefit of having both integer Box and MultiDiscrete would be (and the same with binary Box and MultiBinary). But, Box does also have a nice way to specify identical limits for every axis, so it has that going for it. |
We could treat |
Fixed in #774 |
Describe the bug
During init, Box bounds are captured before casting to the destination dtype, but aren't checked again after the cast.
When Box casts to a lower-precision float with a range smaller than the source dtype, for example
Box(0, 80000, dtype=np.float16)
, this can causehigh
andlow
to containnp.inf
values without the correspondingbounded_above
orbounded_below
being False. This leads to an error when callingsample()
.When Box casts
np.inf
from a float to an int, for exampleBox(255, np.inf, dtype=np.uint8)
, samples can under/overflow and be outside the Box bounds -- #328 seems to be related to this one.Code example
System info
gymnasium.__version__ == '0.29.1'
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: