Skip to content

Commit 280f4e7

Browse files
authored
gh-406: support newer scipy versions (#407)
1 parent 8a89d9b commit 280f4e7

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

heracles/transforms.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
from scipy.special import lpn as legendrep
21
import numpy as np
32

3+
try:
4+
from scipy.special import legendre_p_all
5+
except ImportError:
6+
# old scipy
7+
from scipy.special import lpn
8+
9+
def legendre_p_all(n, z, *, diff_n=0):
10+
"""
11+
All Legendre polynomials of the first kind up to the specified degree n.
12+
"""
13+
assert diff_n == 1, "only diff_n=1 is supported"
14+
return lpn(n, z)
15+
16+
417
try:
518
from copy import replace
619
except ImportError:
@@ -44,7 +57,7 @@ def legendre_funcs(lmax, x, m=(0, 2), lfacs=None, lfacs2=None, lrootfacs=None):
4457
:return: :math:`(P,P'),(d_{11},d_{-1,1}), (d_{20}, d_{22}, d_{2,-2})` as requested, where P starts
4558
at :math:`\ell=0`, but spin functions start at :math:`\ell=\ell_{\rm min}`
4659
"""
47-
allP, alldP = legendrep(lmax, x)
60+
allP, alldP = legendre_p_all(lmax, x, diff_n=1)
4861
# Polarization functions all start at L=2
4962
fac1 = 1 - x
5063
fac2 = 1 + x

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies = [
2727
"healpy",
2828
"numba <= 0.61.0",
2929
"numpy",
30-
"scipy <= 1.15",
30+
"scipy",
3131
]
3232
description = "Harmonic-space statistics on the sphere"
3333
dynamic = [

0 commit comments

Comments
 (0)