1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 cython,
9 numpy,
10 setuptools,
11
12 persim,
13 scikit-learn,
14 scipy,
15
16 # tests
17 pytestCheckHook,
18 writableTmpDirAsHomeHook,
19}:
20
21buildPythonPackage rec {
22 pname = "ripser";
23 version = "0.6.12";
24 pyproject = true;
25
26 src = fetchFromGitHub {
27 owner = "scikit-tda";
28 repo = "ripser.py";
29 tag = "v${version}";
30 hash = "sha256-AviAcpaK0UWqa6spba9bLmBQnprINCrZC/wuRLqiXVA=";
31 };
32
33 build-system = [
34 cython
35 numpy
36 setuptools
37 ];
38
39 dependencies = [
40 numpy
41 scipy
42 scikit-learn
43 persim
44 ];
45
46 pythonImportsCheck = [ "ripser" ];
47
48 nativeCheckInputs = [
49 pytestCheckHook
50 writableTmpDirAsHomeHook
51 ];
52
53 preCheck = ''
54 # specifically needed for darwin
55 mkdir -p $HOME/.matplotlib
56 echo "backend: ps" > $HOME/.matplotlib/matplotlibrc
57 '';
58
59 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
60 # AssertionError
61 # assert np.isinf(h0[0, 1])
62 "test_full_nonzerobirths"
63 # assert np.max(np.abs(h11 - h12)) <= 2 * res2["r_cover"]
64 "test_greedyperm_circlebottleneck"
65 # assert np.all(dgm[:,1] >= dgm[:,0])
66 "test_returns_dgm"
67 # assert tuple(dgm[0]) == (0,np.inf)
68 # assert (np.float64(0....float64(0.0)) == (0, inf)
69 "test_single_point"
70 # assert res0["num_edges"] == res1["num_edges"]
71 # assert 2307 == 167
72 "test_sparse"
73 # assert 38 < 38
74 "test_thresh"
75 # assert(np.allclose(r1, r2))
76 "test_zero_edge_bug"
77 ];
78
79 meta = {
80 description = "Lean Persistent Homology Library for Python";
81 homepage = "https://ripser.scikit-tda.org";
82 changelog = "https://github.com/scikit-tda/ripser.py/blob/${src.tag}/CHANGELOG.md";
83 license = lib.licenses.mit;
84 maintainers = [ ];
85 };
86}