Merge pull request #325402 from kirillrdy/pykalman

python3Packages.pykalman: fix build
This commit is contained in:
kirillrdy 2024-07-08 21:05:47 +10:00 committed by GitHub
commit bcac529695
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 43 deletions

View File

@ -1,39 +1,33 @@
{
lib,
buildPythonPackage,
fetchPypi,
fetchFromGitHub,
numpy,
scipy,
pytestCheckHook,
nose,
setuptools,
}:
buildPythonPackage rec {
pname = "pykalman";
version = "0.9.7";
format = "setuptools";
pyproject = true;
src = fetchPypi {
inherit pname version;
hash = "sha256-E1d5IAOTxrNwIhmQ9zFnQEcvVBNG6SEdEWMOLC2PuKA=";
src = fetchFromGitHub {
owner = "pykalman";
repo = "pykalman";
rev = "aaf8c8574b0474b6f41b7b135a9a7f2dfbd0e86c"; # no tags
hash = "sha256-++YqxGMsFGv5OxicDFO9Xz89e62NG8X+6oR6M9ePUcg=";
};
patches = [
# https://github.com/pykalman/pykalman/issues/83
./fix-masked-arrays-not-supported.patch
# python 3.11 issues fix: https://github.com/pykalman/pykalman/pull/101
./fix-p311-issues.patch
];
build-system = [ setuptools ];
propagatedBuildInputs = [
numpy
scipy
];
nativeCheckInputs = [
pytestCheckHook
nose
];
nativeCheckInputs = [ pytestCheckHook ];
pythonImportsCheck = [ "pykalman" ];
meta = with lib; {

View File

@ -1,14 +0,0 @@
--- a/pykalman/utils.py
+++ b/pykalman/utils.py
@@ -70,7 +70,10 @@
cv_chol = linalg.cholesky(cv + min_covar * np.eye(n_dim),
lower=True)
cv_log_det = 2 * np.sum(np.log(np.diagonal(cv_chol)))
- cv_sol = solve_triangular(cv_chol, (X - mu).T, lower=True).T
+ try:
+ cv_sol = solve_triangular(cv_chol, (X - mu).T, lower=True).T
+ except ValueError:
+ cv_sol = np.linalg.solve(cv_chol, (X - mu).T).T
log_prob[:, c] = - .5 * (np.sum(cv_sol ** 2, axis=1) + \
n_dim * np.log(2 * np.pi) + cv_log_det)

View File

@ -1,13 +0,0 @@
--- a/pykalman/utils.py
+++ b/pykalman/utils_copy.py
@@ -40,6 +40,10 @@
from scipy import linalg
+# monkey patch
+if not hasattr(inspect, 'getargspec'):
+ inspect.getargspec = inspect.getfullargspec
+
def array1d(X, dtype=None, order=None):
"""Returns at least 1-d array with data from X"""
return np.asarray(np.atleast_1d(X), dtype=dtype, order=order)