Skip to content

API: Index.__array_wrap__ stop special-casing bool dtype #52676

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

Open
Tracked by #44823
jbrockmendel opened this issue Apr 14, 2023 · 0 comments
Open
Tracked by #44823

API: Index.__array_wrap__ stop special-casing bool dtype #52676

jbrockmendel opened this issue Apr 14, 2023 · 0 comments
Labels
API Design Index Related to the Index class or subclasses
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Apr 14, 2023

For the "just do in 3.0" pile. Index.__array_wrap__ reads

    def __array_wrap__(self, result, context=None):
        """
        Gets called after a ufunc and other functions e.g. np.split.
        """
        result = lib.item_from_zerodim(result)
        if is_bool_dtype(result) or lib.is_scalar(result) or np.ndim(result) > 1:
            return result

        return Index(result, name=self.name)

The is_bool_dtype check is left over from before we supported bool-dtype Indexes. Affected tests are pandas/tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_other

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 14, 2023
@jbrockmendel jbrockmendel added API Design Index Related to the Index class or subclasses and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 14, 2023
@jbrockmendel jbrockmendel added this to the 3.0 milestone May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Index Related to the Index class or subclasses
Projects
None yet
Development

No branches or pull requests

1 participant