Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
BUG: Casting tz-aware DatetimeIndex to object-dtype ndarray/Index #23524
BUG: Casting tz-aware DatetimeIndex to object-dtype ndarray/Index #23524
Changes from all commits
61ad510
937541e
ca9e8af
9d0fbd7
dbf145f
ec696e5
8853b6a
9add480
cfd8e71
bc06a61
c9a2c22
b4ecfbb
756574f
ebada17
bf1677a
0a5dbed
cc7f5cd
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 remove this elif branch. Numpy will afterwards convert the M8[ns] data to int, and in that way ensure the semantics of
np.asarray
regarding copy/no copy is followed.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.
@jbrockmendel I opened #23593, a PR doing the
__array__
for all datetimelike EAs, not only DatetimeArray (but so there is a bit of overlap with this PR)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.
Great, I'll take a look at 23593.
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.
Other question: what is the
.view(np.ndarray)
part doing if it is already an array? Can we remove it?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.
It can probably be removed; this is taken directly from the
Index.__array__
implementation, so I think the maybe-removing this should be done at the same time those methods are overhauled (ill be opening an Issue shortly)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.
It think it would be good to add such a test to the base extension tests 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.
I don't know those tests well enough to have an informed opinion. AFAIK ExtensionArray doesn't implement
__array__
, so it isn't clear that this is supported in the general case.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.
EA implements
__iter__
, which should be sufficient.This test would be slightly opinionated for a base test, in case an EA wants to be converted to a specific NumPy type, but I think it's OK.
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 guess we have
base.interface.BaseInterfaceTests.test_array_interface
which checksThere 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.
Ah, yes, that's already a generic test. OK, since that does not actually test the return dtype, it's good to have more explicit tests here.
Should we expect from EA that
np.array(EA, dtype=object)
always works (returns an object array of scalars)?That seems like an OK assumption to me, since this already happens if you don't implement
__array__
, so we can expect this as well if the EA author implements a custom__array__
I think.