Skip to content

Commit

Permalink
🗑️ special: deprecate and annotate the sph_harm ufunc
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Dec 23, 2024
1 parent 6062ea2 commit 4d7af81
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 64 deletions.
120 changes: 60 additions & 60 deletions .mypyignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,63 +39,63 @@ scipy\.special\._support_alternative_backends\..*
scipy\.stats\._qmvnt\.phi(nv)?

# https://github.com/KotlinIsland/basedmypy/issues/815
scipy.special.agm
scipy.special.be(i|r)p?
scipy.special.besselpoly
scipy.special.(log_)?wright_bessel
scipy.special.beta(ln|incc?(inv)?)?
scipy.special.binom
scipy.special.poch
scipy.special.(inv_)?boxcox(1p)?
scipy.special.cbrt(r(c|iv?)?)?
scipy.special.co(s|t)dg
scipy.special.(cos|pow)m1
scipy.special.ellip((e|k)(inc)?|km1|rc)
scipy.special.erf(c(inv|x)?|i(nv)?)?
scipy.special.eval_(cheby(c|s|t|u)|hermite(norm)?|laguerre|legendre)
scipy.special.eval_sh_(cheby(t|u)|legendre)
scipy.special.exp(10?|2|i|it|m1|n|rel)
scipy.special.xlog(1p)?y
scipy.special.(di|log|r)?gamma
scipy.special.gamma(incc?(inv)?|ln|sgn)?
scipy.special.(pseudo_)?huber
scipy.special.hyp(0f1|eru)
scipy.special.(i|k)(0|1|v)e?
scipy.special.(mod)?struve
scipy.special.it(2|mod)?struve0
scipy.special.(j|y)(0|1|n|ve?)
scipy.special.k(e(i|r)p?|n)
scipy.special.(rel_)?entr
scipy.special.kl_div
scipy.special.kolmog(i|orov)
scipy.special.log(_(expit|ndtr)|1p|it)
scipy.special.lpmv
scipy.special.mathieu_(a|b)
scipy.special.(obl|pro)_cv
scipy.special.owens_t
scipy.special.psi
scipy.special.radian
scipy.special.round
scipy.special.sindg
scipy.special.smirnovi?
scipy.special.spence
scipy.special.tandg
scipy.special.tklmbda
scipy.special.voigt_profile
scipy.special.dawsn
scipy.special.wofz
scipy.special.wrightomega
scipy.special.zetac
scipy.special.bdtr(c|i(k|n)?)?
scipy.special.btdtri(a|b)
scipy.special.chdtr(c|iv?)?
scipy.special.chndtr(i(df|nc|x))?
scipy.special.fdtr(c|i(dfd)?)?
scipy.special.gdtr(c|i(a|b|x))?
scipy.special.nbdtr(c|i(k|n)?)?
scipy.special.ncfdtr(i((nc)?|df(d|n)))?
scipy.special.nctdtr(i(df|nc|t))?
scipy.special.ndtr(i(_exp)?)?
scipy.special.nrdtri(mn|sd)
scipy.special.pdtr(c|ik?)?
scipy.special.stdtr(i(df|t))?
scipy\.special\.agm
scipy\.special\.beta(ln|incc?(inv)?)?
scipy\.special\.binom
scipy\.special\.poch
scipy\.special\.(inv_)?boxcox(1p)?
scipy\.special\.cbrt(r(c|iv?)?)?
scipy\.special\.(cos|sin|tan|cot)dg
scipy\.special\.(cos|pow|exp)m1
scipy\.special\.ellip((e|k)(inc)?|km1|rc)
scipy\.special\.erf(c(inv|x)?|i(nv)?)?
scipy\.special\.eval_(cheby(c|s|t|u)|hermite(norm)?|laguerre|legendre)
scipy\.special\.eval_sh_(cheby(t|u)|legendre)
scipy\.special\.exp(10?|2|i|n|rel)
scipy\.special\.(exp|log|log_exp)it
scipy\.special\.log1p
scipy\.special\.xlog(1p)?y
scipy\.special\.(di|log|r)?gamma
scipy\.special\.gamma(incc?(inv)?|ln|sgn)?
scipy\.special\.(pseudo_)?huber
scipy\.special\.hyp(0f1|eru)
scipy\.special\.be(i|r)p?
scipy\.special\.(i|k)(0|1|v)e?
scipy\.special\.(mod)?struve
scipy\.special\.it(2|mod)?struve0
scipy\.special\.(j|y)(0|1|n|ve?)
scipy\.special\.k(e(i|r)p?|n)
scipy\.special\.(rel_)?entr
scipy\.special\.kl_div
scipy\.special\.kolmog(i|orov)
scipy\.special\.lpmv
scipy\.special\.mathieu_(a|b)
scipy\.special\.(obl|pro)_cv
scipy\.special\.owens_t
scipy\.special\.psi
scipy\.special\.radian
scipy\.special\.round
scipy\.special\.smirnovi?
scipy\.special\.spence
scipy\.special\.sph_harm
scipy\.special\.tklmbda
scipy\.special\.voigt_profile
scipy\.special\.dawsn
scipy\.special\.wofz
scipy\.special\.besselpoly
scipy\.special\.(log_)?wright_bessel
scipy\.special\.wrightomega
scipy\.special\.zetac
scipy\.special\.bdtr(c|i(k|n)?)?
scipy\.special\.btdtri(a|b)
scipy\.special\.chdtr(c|iv?)?
scipy\.special\.chndtr(i(df|nc|x))?
scipy\.special\.fdtr(c|i(dfd)?)?
scipy\.special\.gdtr(c|i(a|b|x))?
scipy\.special\.nbdtr(c|i(k|n)?)?
scipy\.special\.ncfdtr(i((nc)?|df(d|n)))?
scipy\.special\.nctdtr(i(df|nc|t))?
scipy\.special\.(log_)?ndtr(i(_exp)?)?
scipy\.special\.nrdtri(mn|sd)
scipy\.special\.pdtr(c|ik?)?
scipy\.special\.stdtr(i(df|t))?
89 changes: 85 additions & 4 deletions scipy-stubs/special/_ufuncs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from types import EllipsisType
from typing import Any, Generic, Literal as L, TypeAlias, TypedDict, final, overload, type_check_only
from typing_extensions import LiteralString, Never, TypeVar, Unpack, override
from typing_extensions import LiteralString, Never, TypeVar, Unpack, deprecated, override

import numpy as np
import optype as op
Expand Down Expand Up @@ -297,6 +297,7 @@ _SubFloat: TypeAlias = np.float16 | np.integer[Any] | np.bool_
_ToSubFloat: TypeAlias = float | _SubFloat

_ToDType_l: TypeAlias = onp.AnyLongDType
_ToDType_q: TypeAlias = onp.AnyLongLongDType
_ToDType_f: TypeAlias = onp.AnyFloat32DType
_ToDType_d: TypeAlias = onp.AnyFloat64DType
_ToDType_g: TypeAlias = onp.AnyLongDoubleDType
Expand Down Expand Up @@ -462,6 +463,15 @@ class _Kw41f(_KwBase, TypedDict, total=False):
dtype: _ToDType_fd
signature: L["ffff->f", "dddd->d"] | _ToSignature3_fd4

@type_check_only
class _KwSphHarm(_KwBase, TypedDict, total=False):
# (qq|ff)ff->F; (qq|dd)dd->D
dtype: _ToDType_FD
signature: (
L["qqff->F", "ffff->F", "qqdd->D", "dddd->D"]
| tuple[_ToDType_q | _ToDType_fd, _ToDType_q | _ToDType_fd, _ToDType_fd, _ToDType_fd, _ToDType_FD]
)

@final
@type_check_only
class _UFunc11f(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
Expand Down Expand Up @@ -1194,6 +1204,77 @@ class _UFunc41f(_UFunc41[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identity
**kw: Unpack[_Kw41f],
) -> _OutT: ...

@final
@type_check_only
class _UFuncSphHarm(_UFunc41[L["sph_harm"], None]):
@property
@override
def ntypes(self, /) -> L[4]: ...
@property
@override
def types(self, /) -> list[L["qqff->F", "ffff->F", "qqdd->D", "dddd->D"]]: ...
#
@overload
@deprecated("This function is deprecated and will be removed in SciPy 1.17.0. Use `scipy.special.sph_harm_y` instead.")
def __call__(
self,
m: onp.ToFloat,
n: onp.ToFloat,
theta: onp.ToFloat,
phi: onp.ToFloat,
/,
out: _Out1 = None,
**kw: Unpack[_KwSphHarm],
) -> _Complex: ...
@overload
@deprecated("This function is deprecated and will be removed in SciPy 1.17.0. Use `scipy.special.sph_harm_y` instead.")
def __call__(
self,
m: _ToFloat_D,
n: _ToFloat_D,
theta: _ToFloat_D,
phi: onp.ToFloatND,
/,
out: _Out1 = None,
**kw: Unpack[_KwSphHarm],
) -> _ComplexND: ...
@overload
@deprecated("This function is deprecated and will be removed in SciPy 1.17.0. Use `scipy.special.sph_harm_y` instead.")
def __call__(
self,
m: _ToFloat_D,
n: _ToFloat_D,
theta: onp.ToFloatND,
phi: _ToFloat_D,
/,
out: _Out1 = None,
**kw: Unpack[_KwSphHarm],
) -> _ComplexND: ...
@overload
@deprecated("This function is deprecated and will be removed in SciPy 1.17.0. Use `scipy.special.sph_harm_y` instead.")
def __call__(
self,
m: _ToFloat_D,
n: onp.ToFloatND,
theta: _ToFloat_D,
phi: _ToFloat_D,
/,
out: _Out1 = None,
**kw: Unpack[_KwSphHarm],
) -> _ComplexND: ...
@overload
@deprecated("This function is deprecated and will be removed in SciPy 1.17.0. Use `scipy.special.sph_harm_y` instead.")
def __call__(
self,
m: _ToFloat_D,
n: _ToFloat_D,
theta: _ToFloat_D,
phi: _ToFloat_D,
/,
out: _Out1[_OutT],
**kw: Unpack[_KwSphHarm],
) -> _OutT: ...

###

def geterr() -> dict[str, str]: ...
Expand Down Expand Up @@ -1585,9 +1666,9 @@ hyp2f1: np.ufunc = ...
# TODO
elliprj: np.ufunc = ...

# (ll|ff)ff->F; (ll|dd)dd->D
# TODO
sph_harm: np.ufunc = ...
# NOTE: Deprecated in SciPy 1.15.0
# (qq|ff)ff->F; (qq|dd)dd->D
sph_harm: _UFuncSphHarm = ...

# ffff->ff; dddd->dd
# TODO
Expand Down

0 comments on commit 4d7af81

Please sign in to comment.