RFC: ufunc return type for 0d array input

Albert Steppi <[email protected]> Tue, 27 Jun 2023 13:12:22 -0400
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CAPceVpU6_0jXOLnzkCVRcev+h5abmz3FfArAxcHkqmf2xnGC1g@mail.gmail.com>
Hi team,

I recently became aware of gh-18754
<https://github.com/scipy/scipy/pull/18754>, a PR to make the factorial
function in special return a 0d array when given 0d input. This brings it
in line with the behavior of factorial2, and factorialk, which was settled
down in gh-15600 <https://github.com/scipy/scipy/issues/15600>.

The longstanding behavior for ufuncs in NumPy and SciPy has been to return
a scalar when the output should otherwise be expected to be a 0d-array. All
ufuncs generated in scipy.special through the standard infrastructure will
have the expected behavior. The factorial functions are however not
implemented with the standard infrastructure in order to allow exact
calculation with arbitrary-precision integers.

I would prefer to have consistency between the factorial functions and the
other ufuncs in special. There however isn't a consensus on what the
correct behavior should be. I would appreciate any input anyone has to
offer, especially from those familiar with the reasons behind the current
default convention to convert 0d-arrays to scalar before returning an array
from the NumPy C API into Python.

Feel free to join the discussion at gh-18768
<https://github.com/scipy/scipy/issues/18768>.

Thanks everyone!
Albert

_______________________________________________
SciPy-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: [email protected]