Unverified Commit 6e083a90 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

python3Packages.tess: fix build failure; adopt (#501491)

parents a93bb0c6 da6c1d34
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchPypi,
  cython,
  setuptools,
  fetchPypi,
  lib,
  numpy,
  scipy,
  pytestCheckHook,
  python,
  scipy,
  setuptools,
}:

buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
  pname = "tess";
  version = "0.3.1";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    inherit (finalAttrs) pname version;
    hash = "sha256-5Ic06+K7CWRh1t2v3aJ5JlBACvHXqQyYzvU71jZJFtI=";
  };

@@ -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 ];
@@ -44,6 +48,6 @@ buildPythonPackage rec {
    description = "Module for calculating and analyzing Voronoi tessellations";
    homepage = "https://tess.readthedocs.org";
    license = lib.licenses.bsd3;
    maintainers = [ ];
    maintainers = with lib.maintainers; [ drawbu ];
  };
}
})
+20 −0
Original line number Diff line number Diff line
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))