Skip to content

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

Open
@jbrockmendel

Description

@jbrockmendel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignIndexRelated to the Index class or subclasses

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions