astropy: multiple functions from scipy.special do not work with quantities

I just tried to use SciPy’s error function, and Astropy politely requested that I raise this issue here:

>>> from astropy import units
>>> from scipy.special import erf, erfc
>>> r1 = 5*u.m
>>> r2 = 6*u.m
>>> erf(r1/r2)
TypeError: Unknown ufunc erf.  Please raise issue on https://github.com/astropy/astropy
>>> erfc(r1/r2)
TypeError: Unknown ufunc erfc.  Please raise issue on https://github.com/astropy/astropy
>>> erf(r1.value/r2.value)  # workaround
0.76140717068356445

In scipy.special, ufuncs that I would prioritize include:

Thanks!

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 23 (22 by maintainers)

Commits related to this issue

Most upvoted comments

I’m interested, is it still open?

What I did to quickly check this was run through all of the non-private functions in scipy.special and see if they worked with 1 * u.dimensionless_unscaled as the sole argument. The list of functions that did not work was very long, but this list would have also included any functions that require two or more arguments and any functions for which 1 is an invalid input.

from astropy import units as u
from scipy import special

dimensionless_quantity = 1 * u.dimensionless_unscaled

for key in sorted(special.__dict__):
    try:
        if key[0] != '_':
            special.__dict__[key](dimensionless_quantity)
    except Exception:
        print(key)