Re: Do special functions need to have all kwargs/attributes/methods of ufuncs?

Robert Kern <[email protected]> Tue, 19 Sep 2023 11:25:31 -0400
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CAF6FJisUVPiS9P_zdfN_8UTxg+m7x2qUATVKeTCXOjVqOz8GZQ@mail.gmail.com>
On Tue, Sep 19, 2023 at 2:23 AM Matt Haberland <[email protected]>
wrote:

> Hi Team,
>
> gh-19023 <https://github.com/scipy/scipy/pull/19023> added alternative
> backend support to some SciPy special functions; e.g., when
> `scipy.special.ndtr` receives a CuPy array, it calls
> `cupyx.scipy.special.ndtr` to perform the calculation and returns the
> resulting CuPy array.
>
> Currently, this functionality is opt-in only (via the SCIPY_ARRAY_API
> environment variable) because of a backward incompatibility issue:
> Technically, many `scipy.special` functions are universal functions, and
> without special care, these functions will lose some of these features
> (e.g. `reduce`) when we wrap them. SciPy doesn't actually document any of
> these features (e.g. compare `ndtr` documentation
> <https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html>
> vs ufunc documentation
> <https://numpy.org/doc/stable/reference/ufuncs.html>), but does anyone
> know of code that relies on them and would be impacted by the change?
>

They are in fact documented to be ufuncs:
https://scipy.github.io/devdocs/reference/special.html

Almost all of the functions below accept NumPy arrays as input arguments as
well as single numbers. This means they follow broadcasting and automatic
array-looping rules. Technically, they are NumPy universal functions
<https://numpy.org/doc/stable/user/basics.ufuncs.html#ufuncs-basics>.
Functions which do not accept NumPy arrays are marked by a warning in the
section description.

-- 
Robert Kern

_______________________________________________
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]