Skip to content

Backwards compatible mixin like NDArrayOperatorsMixin as a separate project #9016

@shoyer

Description

@shoyer

As a follow up on #8247, I would like to write another backwards compatible mixin class like NDArrayOperatorsMixin suitable for vendoring in third-party libraries such as xarray and dask (and maybe pandas) that want to support __array_ufunc__ but aren't yet willing to require NumPy v1.13.

My intended usage pattern is as a drop-in replacement:

try:
    from numpy.lib.mixins import NDArrayOperatorsMixin
except ImportError:
    from my_library.legacy_numpy_compat import NDArrayOperatorsMixin

class MyArray(NDArrayOperatorsMixin):
    def __numpy_ufunc__(self, ufunc, method, *inputs, **kwargs):
        ...

For simplicity and ease of use (not to mention decoupling from the NumPy release cycle), I think this should be a separate repository (e.g., "legacy-ndarray-operators-mixin") in the numpy github organization. I'm happy to help put this together, but wanted to make sure this makes sense to others first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions