-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
(fix): disallow NumpyExtensionArray
#10334
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
dcherian
merged 13 commits into
pydata:main
from
ilan-gold:ig/disallow_numpy_extension_array
Jun 11, 2025
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9312d2b
(fix): disallow `NumpyExtensionArray`
ilan-gold d09c0f5
(fix): clarify permitted extension array behavior in `as_compatible_d…
ilan-gold 88e4841
(refactor): centralize whitelist
ilan-gold 174274d
(fix): allow through other types
ilan-gold d9388f0
Merge branch 'main' into ig/disallow_numpy_extension_array
ilan-gold b87b380
Merge branch 'main' into ig/disallow_numpy_extension_array
ilan-gold 6329964
(chore): add thorough test cases
ilan-gold a29c526
Merge branch 'main' into ig/disallow_numpy_extension_array
ilan-gold c6ac491
(fix): require pyarrow
ilan-gold 50843ca
(fix): mypy
ilan-gold b959345
(fix): pyarrow check
ilan-gold 2d33aaa
(fix): remove extra ignore
ilan-gold aba2098
Merge branch 'main' into ig/disallow_numpy_extension_array
ilan-gold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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 we make this more exhaustive please? with datetime, timedelta etc.
Uh oh!
There was an error while loading. Please reload this page.
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.
Without opening a can of worms, datetime and timedelta are the two things that are currently (on
main
) whitelisted (without that, they don't roundtrip).loses the timezone, for example, without the whitelist on
from_dataframe
.So I don't think we want to add those here, which is also why I whitelisted them elsewhere. I was hoping that before adding tests, we would settle on what exactly this PR should be doing (of course
NumpyExtensionArray
but should it cover anything else).I am happy to roll back that whitelist, i.e., leave it where it was on
from_dataframe
and then allow these types through anyway via other means into aDataset
.Uh oh!
There was an error while loading. Please reload this page.
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'd simply like a test or two that exhaustively records the current behaviour (whether cast to numpy or not), so we can be sure of what is going on. Two tests (one for preserved dtype, and one for numpy casting) would work fine.
There's also two cases: ExtensionArray in a data variable, and ExtensionArray as an indexed coordinate variable.
Uh oh!
There was an error while loading. Please reload this page.
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 100% certain what this meant - could you clarify?
I think this covered here. When I check
xr.Dataset.from_dataframe(df)["arr"].variable
it's anIndexVariable
as expected when it's an index on the original objectUh oh!
There was an error while loading. Please reload this page.
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.
Also check out ilan-gold#2 for a related cleanup. As is here, the data types already round trip so that PR only cleans up the internals a bit and the tests/behavior are also a bit clearer now (better preserved date types). Other than that, no changes in terms of types or behavior, it seems