You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two reasons to want to keep PyArray_ReduceWrapper out of the
public multiarray API:
- Its signature is likely to change if/when masked arrays are added
- It is essentially a wrapper for array->scalar transformations
(*not* just reductions as its name implies -- the whole reason it
is in multiarray.so in the first place is to support count_nonzero,
which is not actually a reduction!). It provides some nice
conveniences (like making it easy to apply such functions to
multiple axes simultaneously), but, we already have a general
mechanism for writing array->scalar transformations -- generalized
ufuncs. We do not want to have two independent, redundant
implementations of this functionality, one in multiarray and one in
umath! So in the long run we should add these nice features to the
generalized ufunc machinery. And in the short run, we shouldn't add
it to the public API and commit ourselves to supporting it.
However, simply removing it from numpy_api.py is not easy, because
this code was used in both multiarray and umath. This commit:
- Moves ReduceWrapper and supporting code to umath/, and makes
appropriate changes (e.g. renaming it to PyUFunc_ReduceWrapper and
cleaning up the header files).
- Reverts numpy.count_nonzero to its previous implementation, so that
it loses the new axis= and keepdims= arguments. This is
unfortunate, but this change isn't so urgent that it's worth tying
our APIs in knots forever. (Perhaps in the future it can become a
generalized ufunc.)
0 commit comments