-
-
Notifications
You must be signed in to change notification settings - Fork 873
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
Change discrete dtype to np.int64 #141
Change discrete dtype to np.int64 #141
Conversation
Side question: do we need I don't have an example in mind where you need int64 for Discrete; while usually int32 is used |
Agree, this was my initial thoughts as well but the numpy random |
If we want to do this, we can change it by passing |
@younik I have decided not to change it for three reasons
Therefore, Im going to keep it to |
gymnasium/spaces/discrete.py
Outdated
@@ -21,9 +21,9 @@ class Discrete(Space[int]): | |||
|
|||
def __init__( | |||
self, | |||
n: int, | |||
n: int | np.int64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use one of the general numpy dtypes to allow int/int64/int32/whatever other int? The annotation could be int | np.integer
, then I think it would accept int
, int64
, int32
, uint8
and all of that stuff. While it does make sense to narrow down the return type, this would throw redundant errors (since all of those can be cast to int64
anyways)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can edit to use np.integer[Any]
and this should cover all of the cases mentioned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in L24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
The
Discrete
class definition return type isint
while the spacedtype
isnp.int64
.This PR makes the
Discrete
type consistent withnp.int64
.