summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/neurokit2/default.nix
blob: 6a7e2c71fb6f3c049da5131eb36c4a6eb9d4dcb1 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  matplotlib,
  numpy,
  pandas,
  pywavelets,
  requests,
  scikit-learn,
  scipy,

  # tests
  astropy,
  coverage,
  mock,
  plotly,
  pytest-cov-stub,
  pytestCheckHook,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage rec {
  pname = "neurokit2";
  version = "0.2.12";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "neuropsychology";
    repo = "NeuroKit";
    tag = "v${version}";
    hash = "sha256-gn02l0vYl+/7hXp4gFVlgblxC4dewXckW3JL3wPC89Y=";
  };

  postPatch = ''
    substituteInPlace setup.py \
      --replace-fail '"pytest-runner", ' ""
  '';

  build-system = [
    setuptools
  ];

  dependencies = [
    matplotlib
    numpy
    pandas
    pywavelets
    requests
    scikit-learn
    scipy
  ];

  nativeCheckInputs = [
    pytest-cov-stub
    mock
    plotly
    astropy
    coverage
    pytestCheckHook
    writableTmpDirAsHomeHook
  ];

  disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
    # Crash in matplotlib (Fatal Python error: Aborted)
    "test_events_plot"
  ];

  disabledTestPaths = [
    # Required dependencies not available in nixpkgs
    "tests/tests_bio.py"
    "tests/tests_complexity.py"
    "tests/tests_data.py"
    "tests/tests_ecg.py"
    "tests/tests_ecg_delineate.py"
    "tests/tests_ecg_findpeaks.py"
    "tests/tests_eda.py"
    "tests/tests_eeg.py"
    "tests/tests_emg.py"
    "tests/tests_eog.py"
    "tests/tests_epochs.py"
    "tests/tests_hrv.py"
    "tests/tests_ppg.py"
    "tests/tests_rsp.py"
    "tests/tests_signal.py"

    # Dependency is broken `mne-python`
    "tests/tests_microstates.py"
  ];

  pytestFlags = [
    # Otherwise, test collection fails with:
    # AttributeError: module 'scipy.ndimage._delegators' has no attribute '@py_builtins_signature'. Did you mean: 'grey_dilation_signature'?
    # https://github.com/scipy/scipy/issues/22236
    "--assert=plain"
  ];

  pythonImportsCheck = [
    "neurokit2"
  ];

  meta = {
    description = "Python Toolbox for Neurophysiological Signal Processing";
    homepage = "https://github.com/neuropsychology/NeuroKit";
    changelog = "https://github.com/neuropsychology/NeuroKit/releases/tag/${src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ genga898 ];
  };
}