-
-
Notifications
You must be signed in to change notification settings - Fork 141
(r)true/floor div #764
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
(r)true/floor div #764
Conversation
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.
I hit approve by mistake!
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.
I think we can fix the div by zero problem.
tests/test_indexes.py
Outdated
|
||
check(assert_type(delta / index, "pd.Index[float]"), pd.Index, float) | ||
# ZeroDivisionError | ||
# check(assert_type([delta] / index, "pd.Index[float]"), pd.Index, float) |
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.
I think if you did index = pd.Index([pd.Timedelta(days=1)], dtype="timedelta64[s]")
, then we wouldn't get the div by zero.
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.
Thank you, that made it work!
tests/test_indexes.py
Outdated
dtype: type[np.integer] = np.int64 | ||
if sys.platform == "win32": | ||
dtype = np.int32 | ||
check(assert_type([delta] // index, "pd.Index[int]"), pd.Index, dtype) |
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.
I think you can use np.intp
and it will be platform independent. Did you try that?
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.
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 you try np.integer
? Both isinstance(np.int32(8), np.integer)
and isinstance(np.int64(10), np.integer)
are True
for me on Windows and Linux.
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.
Thank you, using np.signedinteger worked as well :)
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.
Thanks @twoertwein
Focused mostly on timedelta.