Skip to content

Commit bc1628d

Browse files
committed
DEP: deprecation warnings for special.lpn and [c]lpmn
1 parent 2b73948 commit bc1628d

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

scipy/special/_basic.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from ._comb import _comb_int
2222
from ._multiufuncs import (assoc_legendre_p_all,
2323
legendre_p_all)
24+
from scipy._lib.deprecation import _deprecated
2425

2526

2627
__all__ = [
@@ -87,6 +88,11 @@
8788
]
8889

8990

91+
__DEPRECATION_MSG_1_15 = (
92+
"`scipy.special.{}` is deprecated as of SciPy 1.15.0 and will be "
93+
"removed in SciPy 1.17.0. Please use `scipy.special.{}` instead."
94+
)
95+
9096
# mapping k to last n such that factorialk(n, k) < np.iinfo(np.int64).max
9197
_FACTORIALK_LIMITS_64BITS = {1: 20, 2: 33, 3: 44, 4: 54, 5: 65,
9298
6: 74, 7: 84, 8: 93, 9: 101}
@@ -1703,6 +1709,7 @@ def mathieu_odd_coef(m, q):
17031709
return fc[:km]
17041710

17051711

1712+
@_deprecated(__DEPRECATION_MSG_1_15.format("lpmn", "assoc_legendre_p_all"))
17061713
def lpmn(m, n, z):
17071714
"""Sequence of associated Legendre functions of the first kind.
17081715
@@ -1715,8 +1722,8 @@ def lpmn(m, n, z):
17151722
use clpmn instead.
17161723
17171724
.. deprecated:: 1.15.0
1718-
This function is deprecated and will be removed in a future version.
1719-
Use `scipy.special.assoc_legendre_p_all` instead.
1725+
This function is deprecated and will be removed in SciPy 1.17.0.
1726+
Please `scipy.special.assoc_legendre_p_all` instead.
17201727
17211728
Parameters
17221729
----------
@@ -1782,6 +1789,7 @@ def lpmn(m, n, z):
17821789
return p, pd
17831790

17841791

1792+
@_deprecated(__DEPRECATION_MSG_1_15.format("clpmn", "assoc_legendre_p_all"))
17851793
def clpmn(m, n, z, type=3):
17861794
"""Associated Legendre function of the first kind for complex arguments.
17871795
@@ -1791,8 +1799,8 @@ def clpmn(m, n, z, type=3):
17911799
``Pmn'(z)`` for all orders from ``0..m`` and degrees from ``0..n``.
17921800
17931801
.. deprecated:: 1.15.0
1794-
This function is deprecated and will be removed in a future version.
1795-
Use `scipy.special.assoc_legendre_p_all` instead.
1802+
This function is deprecated and will be removed in SciPy 1.17.0.
1803+
Please use `scipy.special.assoc_legendre_p_all` instead.
17961804
17971805
Parameters
17981806
----------
@@ -2033,6 +2041,7 @@ def euler(n):
20332041
return _specfun.eulerb(n1)[:(n+1)]
20342042

20352043

2044+
@_deprecated(__DEPRECATION_MSG_1_15.format("lpn", "legendre_p_all"))
20362045
def lpn(n, z):
20372046
"""Legendre function of the first kind.
20382047
@@ -2042,8 +2051,8 @@ def lpn(n, z):
20422051
See also special.legendre for polynomial class.
20432052
20442053
.. deprecated:: 1.15.0
2045-
This function is deprecated and will be removed in a future version.
2046-
Use `scipy.special.legendre_p_all` instead.
2054+
This function is deprecated and will be removed in SciPy 1.17.0.
2055+
Please use `scipy.special.legendre_p_all` instead.
20472056
20482057
References
20492058
----------
@@ -3464,7 +3473,7 @@ def zeta(x, q=None, out=None):
34643473
``None``, complex inputs `x` are supported. If `q` is not ``None``,
34653474
then currently only real inputs `x` with ``x >= 1`` are supported,
34663475
even when ``q = 1.0`` (corresponding to the Riemann zeta function).
3467-
3476+
34683477
out : ndarray, optional
34693478
Output array for the computed values.
34703479
@@ -3530,7 +3539,7 @@ def zeta(x, q=None, out=None):
35303539
else:
35313540
return _ufuncs._zeta(x, q, out)
35323541

3533-
3542+
35343543
def softplus(x, **kwargs):
35353544
r"""
35363545
Compute the softplus function element-wise.
@@ -3554,7 +3563,7 @@ def softplus(x, **kwargs):
35543563
Examples
35553564
--------
35563565
>>> from scipy import special
3557-
3566+
35583567
>>> special.softplus(0)
35593568
0.6931471805599453
35603569

scipy/special/tests/test_basic.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from scipy.special import elliprc, elliprd, elliprf, elliprg, elliprj
4242
from scipy.special import softplus
4343
from scipy.special import mathieu_odd_coef, mathieu_even_coef, stirling2
44+
from scipy.special import lpn, lpmn, clpmn
4445
from scipy._lib._util import np_long, np_ulong
4546
from scipy._lib._array_api import xp_assert_close, xp_assert_equal, SCIPY_ARRAY_API
4647

@@ -4633,3 +4634,17 @@ def test_temme_rel_max_error(self):
46334634
denom = stirling2([n], k_entries, exact=True)
46344635
num = denom - stirling2([n], k_entries, exact=False)
46354636
assert np.max(np.abs(num / denom)) < 2e-5
4637+
4638+
4639+
class TestLegendreDeprecation:
4640+
4641+
def test_warn_lpn(self):
4642+
msg = "`scipy.special.lpn` is deprecated..."
4643+
with pytest.deprecated_call(match=msg):
4644+
_ = lpn(1, 0)
4645+
4646+
@pytest.mark.parametrize("xlpmn", [lpmn, clpmn])
4647+
def test_warn_xlpmn(self, xlpmn):
4648+
message = f"`scipy.special.{xlpmn.__name__}` is deprecated..."
4649+
with pytest.deprecated_call(match=message):
4650+
_ = xlpmn(1, 1, 0)

0 commit comments

Comments
 (0)