1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 matplotlib,
12 numpy,
13 pandas,
14 pywavelets,
15 requests,
16 scikit-learn,
17 scipy,
18
19 # tests
20 astropy,
21 coverage,
22 mock,
23 plotly,
24 pytest-cov-stub,
25 pytestCheckHook,
26 writableTmpDirAsHomeHook,
27}:
28
29buildPythonPackage rec {
30 pname = "neurokit2";
31 version = "0.2.12";
32 pyproject = true;
33
34 src = fetchFromGitHub {
35 owner = "neuropsychology";
36 repo = "NeuroKit";
37 tag = "v${version}";
38 hash = "sha256-gn02l0vYl+/7hXp4gFVlgblxC4dewXckW3JL3wPC89Y=";
39 };
40
41 postPatch = ''
42 substituteInPlace setup.py \
43 --replace-fail '"pytest-runner", ' ""
44 '';
45
46 build-system = [
47 setuptools
48 ];
49
50 dependencies = [
51 matplotlib
52 numpy
53 pandas
54 pywavelets
55 requests
56 scikit-learn
57 scipy
58 ];
59
60 nativeCheckInputs = [
61 pytest-cov-stub
62 mock
63 plotly
64 astropy
65 coverage
66 pytestCheckHook
67 writableTmpDirAsHomeHook
68 ];
69
70 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
71 # Crash in matplotlib (Fatal Python error: Aborted)
72 "test_events_plot"
73 ];
74
75 disabledTestPaths = [
76 # Required dependencies not available in nixpkgs
77 "tests/tests_bio.py"
78 "tests/tests_complexity.py"
79 "tests/tests_data.py"
80 "tests/tests_ecg.py"
81 "tests/tests_ecg_delineate.py"
82 "tests/tests_ecg_findpeaks.py"
83 "tests/tests_eda.py"
84 "tests/tests_eeg.py"
85 "tests/tests_emg.py"
86 "tests/tests_eog.py"
87 "tests/tests_epochs.py"
88 "tests/tests_hrv.py"
89 "tests/tests_ppg.py"
90 "tests/tests_rsp.py"
91 "tests/tests_signal.py"
92
93 # Dependency is broken `mne-python`
94 "tests/tests_microstates.py"
95 ];
96
97 pytestFlags = [
98 # Otherwise, test collection fails with:
99 # AttributeError: module 'scipy.ndimage._delegators' has no attribute '@py_builtins_signature'. Did you mean: 'grey_dilation_signature'?
100 # https://github.com/scipy/scipy/issues/22236
101 "--assert=plain"
102 ];
103
104 pythonImportsCheck = [
105 "neurokit2"
106 ];
107
108 meta = {
109 description = "Python Toolbox for Neurophysiological Signal Processing";
110 homepage = "https://github.com/neuropsychology/NeuroKit";
111 changelog = "https://github.com/neuropsychology/NeuroKit/releases/tag/${src.tag}";
112 license = lib.licenses.mit;
113 maintainers = with lib.maintainers; [ genga898 ];
114 };
115}