Skip to content
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7a72a06
Added test to check the dtype of the result of take method. Modified …
aijams Sep 29, 2025
65511cd
Added bug info to docs.
aijams Sep 29, 2025
42898c6
Added conditional to handle integer arrays in take method as special …
aijams Oct 2, 2025
333ba45
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 2, 2025
3ca2e84
Added cases for smaller integer types to mixins take function.
aijams Oct 6, 2025
b6e45ac
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 6, 2025
e0ff0d0
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 7, 2025
eeb3d85
Added note to take method.
aijams Oct 9, 2025
cd2f2aa
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 14, 2025
468de3f
Added link to issue in test for take method.
aijams Oct 15, 2025
91442a8
Moved changes to take method to NumpyExtensionArray class.
aijams Oct 16, 2025
aa3c228
Cleaned up work comments.
aijams Oct 16, 2025
8bacb94
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 16, 2025
56a329a
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 17, 2025
040c127
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 20, 2025
1bdb1f8
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 21, 2025
3e5836c
Tests for take method check against object dtype for boolean inputs.
aijams Oct 21, 2025
b4258f2
Removed TODO comment.
aijams Oct 21, 2025
e4c3a5b
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 22, 2025
acdfb62
Updated references to numpy.bool to include underscore.
aijams Oct 22, 2025
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
Prev Previous commit
Next Next commit
Added note to take method.
  • Loading branch information
aijams committed Oct 9, 2025
commit eeb3d8569c89e03511cb4c7327ca2bc6e752de6f
16 changes: 16 additions & 0 deletions pandas/core/arrays/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,22 @@ def take(
fill_value=fill_value,
axis=axis,
)
# One of the base classes to this class: ExtensionArray, provides
# the dtype property, but abstractly, so it leaves the implementation
# of dtype storage up to its derived classes. Some of these derived
# classes don't provide a setter method for their dtype property, so
# I can't set the dtype here and expect it to work for all classes that
# inherit this take method.

# How can I produce an extension array of the same type as self,
# having a floating-point dtype if self has an integer dtype or otherwise
# the same dtype as self?

# Constructing a new object of the same type as self doesn't always
# work since the constructors of some derived classes of this class
# don't accept a dtype parameter, which I need to pass to set the
# result's dtype to a floating-point type.

if self.dtype in [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this on the NumpySemantics instead of this mixin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean by "Numpy semantics". I changed the condition to check the numpy_dtype so it can be compared to a list of bare Numpy dtypes. I'm not sure if this is what you meant. Can you clarify?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, meant to write NumpyExtensionArray. Implement a take method there along the lines of

def take(...) if self.dtype.kind in "iub": ... else: return super().take(...) 
NumpyEADtype(np.uint8),
NumpyEADtype(np.uint16),
Expand Down