diff options
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/pykalman')
3 files changed, 71 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/pykalman/default.nix b/nixpkgs/pkgs/development/python-modules/pykalman/default.nix new file mode 100644 index 000000000000..7073e9382d3d --- /dev/null +++ b/nixpkgs/pkgs/development/python-modules/pykalman/default.nix @@ -0,0 +1,44 @@ +{ lib +, buildPythonPackage +, fetchPypi +, numpy +, scipy +, pytestCheckHook +, nose +}: + +buildPythonPackage rec { + pname = "pykalman"; + version = "0.9.5"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-gWr0dyDZJKTGAW+nS54sjCEWWgjZFpPDIqF0Ho4H+zg="; + }; + + 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 + ]; + + propagatedBuildInputs = [ + numpy + scipy + ]; + + nativeCheckInputs = [ + pytestCheckHook + nose + ]; + pythonImportsCheck = [ "pykalman" ]; + + meta = with lib; { + description = "An implementation of the Kalman Filter, Kalman Smoother, and EM algorithm in Python"; + homepage = "https://github.com/pykalman/pykalman"; + license = licenses.bsd2; + maintainers = with maintainers; [ mbalatsko ]; + }; +} diff --git a/nixpkgs/pkgs/development/python-modules/pykalman/fix-masked-arrays-not-supported.patch b/nixpkgs/pkgs/development/python-modules/pykalman/fix-masked-arrays-not-supported.patch new file mode 100644 index 000000000000..f6dc6679cc54 --- /dev/null +++ b/nixpkgs/pkgs/development/python-modules/pykalman/fix-masked-arrays-not-supported.patch @@ -0,0 +1,14 @@ +--- 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) + diff --git a/nixpkgs/pkgs/development/python-modules/pykalman/fix-p311-issues.patch b/nixpkgs/pkgs/development/python-modules/pykalman/fix-p311-issues.patch new file mode 100644 index 000000000000..002c8b893aad --- /dev/null +++ b/nixpkgs/pkgs/development/python-modules/pykalman/fix-p311-issues.patch @@ -0,0 +1,13 @@ +--- 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) |