-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
EDIT: non-Quantity discussion of __array_function__ is in #8610
In the non-yet-merged but ready-for-review #8808, support for numpy's __array_function__ is introduced. For a number of functions, a decision still needs to be made, mostly on whether to stick exactly to the numpy docstring or to make adjustments to parameter defaults that make the function more useful for Quantity
-
np.isclose,np.allclose: these were never all that useful since internally they calculateabs(a - b) < atol + rtol * abs(a)andatolis given as a small number, which is interpreted as dimensionless. ForQuantity, we could either set it to0or assume the units ofa, but in either case it would become inconsistent with the docstring that users actually see. (Decision: units ofa- Quantity behaviour for np.isclose, np.allclose; some others #9463) -
np.broadcast_arraysandnp.broadcast_toby default return plain arrays, needingsubok=Trueto work forQuantity. We could change the default if aQuantityis present. Again, the possible issue is that the docstring will no longer be correct. (Decision: leave as is, since old code could cease working; Quantity behaviour for np.isclose, np.allclose; some others #9463)
Furthermore, a few top-level functions need an actual implementation and/or better test cases:
-
np.histogram2dandnp.histogramdd(see Quantity __array_function__ support for histograms, arraysetops functions and apply_{along, over}_axis #8900) -
np.piecewise(see Quantity __array_function__ updates #8884) -
np.apply_along_axisandnp.apply_over_axis(see Quantity __array_function__ support for histograms, arraysetops functions and apply_{along, over}_axis #8900) - The setops functions such as
np.uniquemight as well be supported (see Quantity __array_function__ support for histograms, arraysetops functions and apply_{along, over}_axis #8900)
And finally we should also cover the numpy submodules that have routines not exported to the top level. In particular:
-
np.fft(Quantity __array_function__ overrides for numpy.fft #9464) -
np.linalg(see issue Units with matrix inversion #8622; PR Quantity __array_function__ overrides for np.linalg #9494) -
np.polynomial(has no functions that can be overridden).
EDIT: And it would probably be good to add tests for Quantity subclasses:
-
LogQuantitysuch asMagnitude -
Angles such asLongitude