summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/ripser/default.nix
blob: 2a18ef66991b5c798078607cc99516f5f93207a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  cython,
  numpy,
  setuptools,

  persim,
  scikit-learn,
  scipy,

  # tests
  pytestCheckHook,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage rec {
  pname = "ripser";
  version = "0.6.14";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "scikit-tda";
    repo = "ripser.py";
    tag = "v${version}";
    hash = "sha256-p47vhrG8+B226/no4PD7+XFNccbNJvi45Luwu287ygI=";
  };

  build-system = [
    cython
    numpy
    setuptools
  ];

  dependencies = [
    numpy
    scipy
    scikit-learn
    persim
  ];

  pythonImportsCheck = [ "ripser" ];

  nativeCheckInputs = [
    pytestCheckHook
    writableTmpDirAsHomeHook
  ];

  preCheck = ''
    # specifically needed for darwin
    mkdir -p $HOME/.matplotlib
    echo "backend: ps" > $HOME/.matplotlib/matplotlibrc
  '';

  disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
    # AssertionError
    # assert np.isinf(h0[0, 1])
    "test_full_nonzerobirths"
    # assert np.max(np.abs(h11 - h12)) <= 2 * res2["r_cover"]
    "test_greedyperm_circlebottleneck"
    # assert np.all(dgm[:,1] >= dgm[:,0])
    "test_returns_dgm"
    # assert tuple(dgm[0]) == (0,np.inf)
    # assert (np.float64(0....float64(0.0)) == (0, inf)
    "test_single_point"
    # assert res0["num_edges"] == res1["num_edges"]
    # assert 2307 == 167
    "test_sparse"
    # assert 38 < 38
    "test_thresh"
    # assert(np.allclose(r1, r2))
    "test_zero_edge_bug"
    # assert (0, 2) == (1, 2)
    "test_verbose_true"
    # assert (0, 2) == (1, 2)
    "test_verbose_false"
  ];

  meta = {
    description = "Lean Persistent Homology Library for Python";
    homepage = "https://ripser.scikit-tda.org";
    changelog = "https://github.com/scikit-tda/ripser.py/blob/${src.tag}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = [ ];
  };
}