From 1b43b7fc5c73fcff212706c138c555213b931b2e Mon Sep 17 00:00:00 2001 From: Nicolas Tessore Date: Tue, 16 Jun 2026 14:33:11 +0100 Subject: [PATCH 1/4] support newer scipy versions --- heracles/transforms.py | 7 ++++++- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/heracles/transforms.py b/heracles/transforms.py index cdd63b0d..9c4a4828 100644 --- a/heracles/transforms.py +++ b/heracles/transforms.py @@ -1,6 +1,11 @@ -from scipy.special import lpn as legendrep import numpy as np +try: + from scipy.special import lpn as legendrep +except ImportError: + # scipy > 1.15 + from scipy.special import legendre_p_all as legendrep + try: from copy import replace except ImportError: diff --git a/pyproject.toml b/pyproject.toml index 0ab52988..a29cbf91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ "healpy", "numba <= 0.61.0", "numpy", - "scipy <= 1.15", + "scipy", ] description = "Harmonic-space statistics on the sphere" dynamic = [ From 10e81ed73cc3444aa13a72c2fa3ef50c827de0ce Mon Sep 17 00:00:00 2001 From: Nicolas Tessore Date: Tue, 16 Jun 2026 14:45:08 +0100 Subject: [PATCH 2/4] return derivatives --- heracles/transforms.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/heracles/transforms.py b/heracles/transforms.py index 9c4a4828..32dd6ded 100644 --- a/heracles/transforms.py +++ b/heracles/transforms.py @@ -4,7 +4,15 @@ from scipy.special import lpn as legendrep except ImportError: # scipy > 1.15 - from scipy.special import legendre_p_all as legendrep + from scipy.special import legendre_p_all + + def legendrep(n, z): + """ + Legendre function of the first kind. Compatibility function for + ``scipy.special.lpn()``. + """ + return legendre_p_all(n, z, diff_n=1) + try: from copy import replace From d8b9303926a169a395bc8238e30a68715dbf14b4 Mon Sep 17 00:00:00 2001 From: Nicolas Tessore Date: Tue, 16 Jun 2026 14:54:23 +0100 Subject: [PATCH 3/4] proper fix --- heracles/transforms.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/heracles/transforms.py b/heracles/transforms.py index 32dd6ded..97e4f570 100644 --- a/heracles/transforms.py +++ b/heracles/transforms.py @@ -1,18 +1,5 @@ import numpy as np - -try: - from scipy.special import lpn as legendrep -except ImportError: - # scipy > 1.15 - from scipy.special import legendre_p_all - - def legendrep(n, z): - """ - Legendre function of the first kind. Compatibility function for - ``scipy.special.lpn()``. - """ - return legendre_p_all(n, z, diff_n=1) - +from scipy.special import legendre_p_all try: from copy import replace @@ -57,7 +44,7 @@ def legendre_funcs(lmax, x, m=(0, 2), lfacs=None, lfacs2=None, lrootfacs=None): :return: :math:`(P,P'),(d_{11},d_{-1,1}), (d_{20}, d_{22}, d_{2,-2})` as requested, where P starts at :math:`\ell=0`, but spin functions start at :math:`\ell=\ell_{\rm min}` """ - allP, alldP = legendrep(lmax, x) + allP, alldP = legendre_p_all(lmax, x, diff_n=1) # Polarization functions all start at L=2 fac1 = 1 - x fac2 = 1 + x From 189794f2229d71c62031de2f2843273cecb39ebb Mon Sep 17 00:00:00 2001 From: Nicolas Tessore Date: Thu, 18 Jun 2026 19:43:27 +0100 Subject: [PATCH 4/4] fix for Python 3.9 --- heracles/transforms.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/heracles/transforms.py b/heracles/transforms.py index 97e4f570..67be0d6b 100644 --- a/heracles/transforms.py +++ b/heracles/transforms.py @@ -1,5 +1,18 @@ import numpy as np -from scipy.special import legendre_p_all + +try: + from scipy.special import legendre_p_all +except ImportError: + # old scipy + from scipy.special import lpn + + def legendre_p_all(n, z, *, diff_n=0): + """ + All Legendre polynomials of the first kind up to the specified degree n. + """ + assert diff_n == 1, "only diff_n=1 is supported" + return lpn(n, z) + try: from copy import replace