summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/picos/default.nix
blob: f4dac76c278dc8512e9673b7d5341bcd6a51d808 (about) (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
{
  lib,
  buildPythonPackage,
  fetchPypi,
  numpy,
  cvxopt,
  python,
  networkx,
  scipy,
  pythonOlder,
  stdenv,
}:

buildPythonPackage rec {
  pname = "picos";
  version = "2.6.0";
  format = "setuptools";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-LU5OxinhDBewQ/32cxyOSQyUexMD8xdJIkrsiaWBils=";
  };

  # Needed only for the tests
  nativeCheckInputs = [ networkx ];

  dependencies = [
    numpy
    cvxopt
    scipy
  ];

  postPatch =
    lib.optionalString (pythonOlder "3.12") ''
      substituteInPlace picos/modeling/problem.py \
        --replace-fail "mappingproxy(OrderedDict({'x': <3×1 Real Variable: x>}))" "mappingproxy(OrderedDict([('x', <3×1 Real Variable: x>)]))"
    ''
    # TypeError: '<=' not supported between instances of 'ComplexAffineExpression' and 'float'
    + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
      rm tests/ptest_quantentr.py
    '';

  checkPhase = ''
    runHook preCheck

    ${python.interpreter} test.py

    runHook postCheck
  '';

  meta = {
    description = "Python interface to conic optimization solvers";
    homepage = "https://gitlab.com/picos-api/picos";
    license = lib.licenses.gpl3;
    maintainers = with lib.maintainers; [ tobiasBora ];
  };
}