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

Matt Haberland <[email protected]> Tue, 19 Sep 2023 08:56:09 -0700
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CADuxUiww50tOki3L==JNwGMQFx1qGbxhxUvhjsiyyA1N=mb8jA@mail.gmail.com>
Yes, the documentation mentions that they are "technically" ufuncs. My
comment was about documentation of the features of ufuncs - the
documentation seems to intentionally hide all ufunc parameters from the
signature. Please see
https://github.com/scipy/scipy/pull/19023#issuecomment-1711949107
for further context.

It looks like my link to gh-19252
<https://github.com/scipy/scipy/pull/19252> was broken before. If you have
thoughts about which ufunc features need to be preserved, please comment
there.

Matt.

On Tue, Sep 19, 2023 at 8:26 AM Robert Kern <[email protected]> wrote:

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

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