Quantity.__array_function__ follow up for Quantity
See original GitHub issueEDIT: 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)
andatol
is given as a small number, which is interpreted as dimensionless. ForQuantity
, we could either set it to0
or assume the units ofa
, but in either case it would become inconsistent with the docstring that users actually see. (Decision: units ofa
- #9463) -
np.broadcast_arrays
andnp.broadcast_to
by default return plain arrays, needingsubok=True
to work forQuantity
. We could change the default if aQuantity
is present. Again, the possible issue is that the docstring will no longer be correct. (Decision: leave as is, since old code could cease working; #9463)
Furthermore, a few top-level functions need an actual implementation and/or better test cases:
-
np.histogram2d
andnp.histogramdd
(see #8900) -
np.piecewise
(see #8884) -
np.apply_along_axis
andnp.apply_over_axis
(see #8900) - The setops functions such as
np.unique
might as well be supported (see #8900)
And finally we should also cover the numpy submodules that have routines not exported to the top level. In particular:
-
np.fft
(#9464) -
np.linalg
(see issue #8622; PR #9494) -
np.polynomial
(has no functions that can be overridden).
EDIT: And it would probably be good to add tests for Quantity
subclasses:
-
LogQuantity
such asMagnitude
-
Angle
s such asLongitude
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Guidelines and examples of array formulas - Microsoft Support
An array formula (one that spans multiple cells) can do calculations on rows and columns of cells where you might otherwise need to...
Read more >Array formulas and functions in Excel - examples and guidelines
The tutorial explains what is an array formula in Excel and provides examples of using Excel array functions and constants.
Read more >sum up quantity in occured products inside an array of objects
Use reduce and in the accumulator array check if there exist a object with a name ... quantity: 10 }, ] let sum...
Read more >Product of Array except itself - GeeksforGeeks
Given an array arr[] of n integers, construct a Product Array prod[] (of same size) such that prod[i] is equal to the product...
Read more >Number of array elements - MATLAB numel - MathWorks
This MATLAB function returns the number of elements, n, in array A, equivalent to prod(size(A)).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mhvk - I’m removing the milestone from here as there are no more open PRs ready for 4.0 that are related.
Since this is mostly done, closing - leftovers at #10575.