From 2fe7c8f7dc5924b939770a5ec3576235e6ea39ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Thu, 19 Mar 2026 18:13:28 -0700 Subject: [PATCH] python3Packages.tess: fix build failure scipy has depecrated since version 1.15.0 the function `sph_harm`, and has been removed in 1.17.0 in favor of `sph_harm_y` https://docs.scipy.org/doc/scipy-1.16.2/reference/generated/scipy.special.sph_harm.html --- .../python-modules/tess/default.nix | 4 ++++ .../python-modules/tess/scipy_sph_harm.patch | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 pkgs/development/python-modules/tess/scipy_sph_harm.patch diff --git a/pkgs/development/python-modules/tess/default.nix b/pkgs/development/python-modules/tess/default.nix index d28de79e9d91..703e70d3ee8e 100644 --- a/pkgs/development/python-modules/tess/default.nix +++ b/pkgs/development/python-modules/tess/default.nix @@ -30,6 +30,10 @@ buildPythonPackage rec { scipy ]; + # scipy has depecrated since version 1.15.0 the function `sph_harm`, and has + # been removed in 1.17.0 in favor of `sph_harm_y` + patches = [ ./scipy_sph_harm.patch ]; + pythonImportsCheck = [ "tess" ]; nativeCheckInputs = [ pytestCheckHook ]; diff --git a/pkgs/development/python-modules/tess/scipy_sph_harm.patch b/pkgs/development/python-modules/tess/scipy_sph_harm.patch new file mode 100644 index 000000000000..0d9830cff7f3 --- /dev/null +++ b/pkgs/development/python-modules/tess/scipy_sph_harm.patch @@ -0,0 +1,20 @@ +diff --git a/tess/__init__.py b/tess/__init__.py +index b7f8f80..91c518f 100644 +--- a/tess/__init__.py ++++ b/tess/__init__.py +@@ -374,13 +374,13 @@ def orderQ(l, xyz, weights=1): + :math:`w_i` are the `weights`, defaulting to uniform: (:math:`\frac{1}{N_b}`) + """ + import numpy as np +- from scipy.special import sph_harm ++ from scipy.special import sph_harm_y + + theta, phi = cart_to_spher(xyz).T + weights = np.ones(xyz.shape[0]) * weights + weights /= np.sum(weights) + mmeans = np.zeros(2 * l + 1, dtype=float) + for m in range(-l, l + 1): +- sph_weighted = sph_harm(m, l, phi, theta).dot(weights) # Average of Y_{6m} ++ sph_weighted = sph_harm_y(l, m, theta, phi).dot(weights) # Average of Y_{6m} + mmeans[m] = abs(sph_weighted) ** 2 + return np.sqrt(4 * np.pi / (2 * l + 1) * np.sum(mmeans))