summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/asteroid-filterbanks/default.nix
blob: 5eba6e0d1c42a1d87b9275ff013a934858ca04e4 (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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch2,

  # build-system
  setuptools,

  # dependencies
  numpy,
  torch,
  typing-extensions,

  # tests
  pytestCheckHook,
  scipy,
}:

buildPythonPackage {
  pname = "asteroid-filterbanks";
  version = "0.4.0-unstable-2024-12-02";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "asteroid-team";
    repo = "asteroid-filterbanks";
    # TODO: 0.4.0 is not compatible with recent torch and numpy
    rev = "74a13c69ba9858d57bd4936f18f3c3bd4b2d580c";
    hash = "sha256-iTwqq5qyTDK9f0MG2XUvYUGSOPJ2I/X/Pxrf+n7o8Mk=";
  };

  patches = [
    (fetchpatch2 {
      name = "numpy2-compat.patch";
      url = "https://github.com/asteroid-team/asteroid-filterbanks/commit/2c22e97c782f0e57e49d2beb56054c71ad5ccb08.patch";
      hash = "sha256-wBwQJzG/ET+XbV39l3UvctwhR/5TG+WgdxrPa/nyhRU=";
    })
  ];

  build-system = [ setuptools ];

  dependencies = [
    numpy
    torch
    typing-extensions
  ];

  pythonImportsCheck = [ "asteroid_filterbanks" ];

  nativeCheckInputs = [
    pytestCheckHook
    scipy
  ];

  disabledTests = [
    # RuntimeError: cannot cache function '__o_fold': no locator available for file
    # '/nix/store/d1znhn1n48z2raj0j9zbz80hhg4k2shw-python3.12-librosa-0.10.2.post1/lib/python3.12/site-packages/librosa/core/notation.py'
    "test_melgram_encoder"
    "test_melscale"

    # AssertionError: The values for attribute 'shape' do not match
    "test_torch_stft"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # Issue with JIT on darwin:
    # RuntimeError: required keyword attribute 'value' has the wrong type
    "test_jit_filterbanks"
    "test_jit_filterbanks_enc"
    "test_pcen_jit"
    "test_stateful_pcen_jit"
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    # Flaky: AssertionError: Tensor-likes are not close!
    "test_fb_def_and_forward_lowdim"
  ];

  meta = {
    description = "PyTorch-based audio source separation toolkit for researchers";
    homepage = "https://github.com/asteroid-team/asteroid-filterbanks";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ matthewcroughan ];
  };
}