summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/jaxopt/default.nix
blob: 8a71974ec02f6bb2eb7da10fa432bbf7b580355d (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,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,

  # dependencies
  absl-py,
  jax,
  matplotlib,
  numpy,
  scipy,

  # tests
  cvxpy,
  optax,
  pytest-xdist,
  pytestCheckHook,
  scikit-learn,
}:

buildPythonPackage rec {
  pname = "jaxopt";
  version = "0.8.5";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "google";
    repo = "jaxopt";
    tag = "jaxopt-v${version}";
    hash = "sha256-vPXrs8J81O+27w9P/fEFr7w4xClKb8T0IASD+iNhztQ=";
  };

  build-system = [ setuptools ];

  dependencies = [
    absl-py
    jax
    matplotlib
    numpy
    scipy
  ];

  nativeCheckInputs = [
    cvxpy
    optax
    pytest-xdist
    pytestCheckHook
    scikit-learn
  ];

  pythonImportsCheck = [
    "jaxopt"
    "jaxopt.implicit_diff"
    "jaxopt.linear_solve"
    "jaxopt.loss"
    "jaxopt.tree_util"
  ];

  disabledTests = [
    # https://github.com/google/jaxopt/issues/592
    "test_solve_sparse"

    # https://github.com/google/jaxopt/issues/593
    # Makes the test suite crash
    "test_dtype_consistency"

    # AssertionError: Not equal to tolerance rtol=1e-06, atol=1e-06
    # https://github.com/google/jaxopt/issues/618
    "test_binary_logit_log_likelihood"

    # AssertionError (flaky numerical tests)
    "test_Rosenbrock2"
    "test_Rosenbrock5"
    "test_gradient1"
    "test_inv_hessian_product_pytree3"
    "test_logreg_with_intercept_manual_loop3"
    "test_multiclass_logreg6"
  ];

  meta = {
    homepage = "https://jaxopt.github.io";
    description = "Hardware accelerated, batchable and differentiable optimizers in JAX";
    changelog = "https://github.com/google/jaxopt/releases/tag/jaxopt-v${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ bcdarwin ];
  };
}