-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPS: Update reprs with numpy NEP51 scalar repr #54268
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from typing import ( | ||
TYPE_CHECKING, | ||
Any, | ||
Callable, | ||
Literal, | ||
overload, | ||
) | ||
|
@@ -160,6 +161,9 @@ def _empty(cls, shape: Shape, dtype: ExtensionDtype): | |
) | ||
return result | ||
|
||
def _formatter(self, boxed: bool = False) -> Callable[[Any], str | None]: | ||
return super()._formatter(boxed=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're ignoring the boxed keyword? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah since I think we'll need to always return str given the NEP 51 change. Actually probably just simpler to |
||
|
||
@property | ||
def dtype(self) -> BaseMaskedDtype: | ||
raise AbstractMethodError(self) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5250,7 +5250,8 @@ def _raise_scalar_data_error(cls, data): | |
# in order to keep mypy happy | ||
raise TypeError( | ||
f"{cls.__name__}(...) must be called with a collection of some " | ||
f"kind, {repr(data)} was passed" | ||
f"kind, {repr(data) if not isinstance(data, np.generic) else str(data)} " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does str work unconditionally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah according to the linked PR seems so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the can we simplify this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh sorry, str works unconditionally for numpy scalars but |
||
"was passed" | ||
) | ||
|
||
def _validate_fill_value(self, value): | ||
|
@@ -6974,7 +6975,7 @@ def drop( | |
mask = indexer == -1 | ||
if mask.any(): | ||
if errors != "ignore": | ||
raise KeyError(f"{list(labels[mask])} not found in axis") | ||
raise KeyError(f"{labels[mask].tolist()} not found in axis") | ||
indexer = indexer[~mask] | ||
return self.delete(indexer) | ||
|
||
|
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.
maybe the thing to do is unpack numpy scalars at an earlier stage?
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.
But we should still store numpy scalars for left/right on Interval right?
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 was thinking store native scalars
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.
Hmm might make sense, not sure if there's any larger ramifications of that chance. Might be better to experiment in a follow up?
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.
sure