-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Backwards compatible mixin like NDArrayOperatorsMixin as a separate project #9016
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
Comments
Makes sense to me. Can I nudge you to consider bumping |
This might actually be a better idea. These days, upgrading numpy is easier than ever :). So after some contemplation, I'm no longer convinced this is essential. It also occurs to me that many existing projects will just add a @mrocklin would you find such a mixin useful for dask? |
What reusable logic would this mixin have? I think that the competition to this idea is just to rebuild this logic each time in each codebase. Hopefully this logic isn't that complex. I haven't yet looked at the full spec though so I don't know if this is overly naive. My initial inclination (again without heavy research) would be to build the |
Mostly this is pretty routine: defining every special operator in terms of it's matching numpy ufunc: https://github.com/numpy/numpy/blob/master/numpy/lib/mixins.py
Sounds good. We'll probably defer for this now, then. |
@mrocklin: it's mostly that the logic is a bit tiresome (defining all the binop special methods), has a few gotchas if you want to correctly interoperate with arbitrary third-party classes, and is exactly the same for every object that wants to quack like an ndarray, so it makes sense to have a standard implementation everyone shares. But the standard implementation that ships with numpy assumes that you have a recent numpy (both to have the mixin, and because that implementation assumes that it's being used with a numpy that supports |
OK, if there is a great deal of boiler plate then yes, I'd probably appreciate having it around. I guess my general answer is "I'm not able to answer this without better understanding the costs." |
I never got around to this and at this point it isn't worth the trouble -- NumPy 1.13 was released almost 5 years ago! |
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:
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.
The text was updated successfully, but these errors were encountered: