Skip to content

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

Merged
merged 1 commit into from
May 2, 2022
Merged

Conversation

jbrockmendel
Copy link
Member

Necessary for non-nano support

@mroeschke mroeschke added this to the 1.5 milestone May 1, 2022
@mroeschke mroeschke added Refactor Internal refactoring of code Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels May 1, 2022
@@ -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)
Copy link
Member

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?

Copy link
Member Author

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:
Copy link
Contributor

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

Copy link
Member Author

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

@jreback jreback merged commit 8429441 into pandas-dev:main May 2, 2022
@jbrockmendel jbrockmendel deleted the ref-box_func branch May 2, 2022 15:47
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants