-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: stronger typing in _box_func #46917
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
Conversation
@@ -367,19 +366,23 @@ def _wrap_results(result, dtype: np.dtype, fill_value=None): | |||
result = np.datetime64("NaT", "ns") | |||
else: | |||
result = np.int64(result).view("datetime64[ns]") | |||
# retain original unit | |||
result = result.astype(dtype, copy=False) |
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.
So do these changes make things internally More Correct and not necessarily have an external behavior change?
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.
not user-facing unless they are directly using nanops, which they shouldnt be
# expected "Union[SupportsInt, Union[str, bytes], SupportsIndex]" | ||
x = np.int64(x) # type: ignore[arg-type] | ||
ts = Timestamp(x, tz=self.tz) | ||
def _box_func(self, x: np.datetime64) -> Timestamp | NaTType: |
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.
is this guaranteed true? e.g. can the input be a Timestamp
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.
the nanops changes fix the only places where we call _box_func with incorrect scalars
Necessary for non-nano support