-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
BUG: Take method of NumpyExtensionArray now returns another extension array with the correct dtype. #62502
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
base: main
Are you sure you want to change the base?
Conversation
…take method to return correct dtype.
Several tests are currently failing due to a new version of |
fill_value=fill_value, | ||
axis=axis, | ||
) | ||
if self.dtype in [ |
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.
Do this on the NumpySemantics instead of this mixin
|
||
|
||
@pytest.mark.parametrize("dtype", [np.uint32, np.uint64, np.int32, np.int64]) | ||
def test_take_assigns_correct_dtype(dtype): |
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.
Comment pointing back to the motivating GH issue
In the edge case when called with integer arrays and asked to access non-existent entries (to be replaced with NaN), the
take
method ofNumpyExtensionArray
produces arrays whose dtypes don't match their underlying data.Specifically,
take
promotes the underlying data to a floating-point type, but doesn't promote the dtype of the extension array to match.These changes ensure that the result of this method has the correct dtype for its data.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.