at 23.11-beta 2.8 kB view raw
1{ lib 2, autograd 3, buildPythonPackage 4, cupy 5, cvxopt 6, cython 7, fetchPypi 8, matplotlib 9, numpy 10, tensorflow 11, pymanopt 12, pytestCheckHook 13, pythonOlder 14, scikit-learn 15, scipy 16, enableDimensionalityReduction ? false 17, enableGPU ? false 18}: 19 20buildPythonPackage rec { 21 pname = "pot"; 22 version = "0.9.1"; 23 format = "setuptools"; 24 25 disabled = pythonOlder "3.6"; 26 27 src = fetchPypi { 28 pname = "POT"; 29 inherit version; 30 hash = "sha256-gcJTJ6ABl/8Rwf5SIc8YGtHf/mFWRBUuLhFd3d9eWRs="; 31 }; 32 33 nativeBuildInputs = [ 34 numpy 35 cython 36 ]; 37 38 propagatedBuildInputs = [ 39 numpy 40 scipy 41 ] ++ lib.optionals enableGPU [ 42 cupy 43 ] ++ lib.optionals enableDimensionalityReduction [ 44 autograd 45 pymanopt 46 ]; 47 48 nativeCheckInputs = [ 49 cvxopt 50 matplotlib 51 numpy 52 tensorflow 53 scikit-learn 54 pytestCheckHook 55 ]; 56 57 postPatch = '' 58 substituteInPlace setup.cfg \ 59 --replace " --cov-report= --cov=ot" "" \ 60 --replace " --durations=20" "" \ 61 --replace " --junit-xml=junit-results.xml" "" 62 substituteInPlace setup.py \ 63 --replace '"oldest-supported-numpy", ' "" 64 65 # we don't need setup.py to find the macos sdk for us 66 sed -i '/sdk_path/d' setup.py 67 ''; 68 69 # To prevent importing of an incomplete package from the build directory 70 # instead of nix store (`ot` is the top-level package name). 71 preCheck = '' 72 rm -r ot 73 ''; 74 75 disabledTests = [ 76 # GPU tests are always skipped because of sandboxing 77 "warnings" 78 # Fixture is not available 79 "test_conditional_gradient" 80 "test_convert_between_backends" 81 "test_emd_backends" 82 "test_emd_emd2_types_devices" 83 "test_emd1d_type_devices" 84 "test_emd2_backends" 85 "test_factored_ot_backends" 86 "test_free_support_barycenter_backends" 87 "test_func_backends" 88 "test_generalized_conditional_gradient" 89 "test_line_search_armijo" 90 "test_loss_dual" 91 "test_max_sliced_backend" 92 "test_plan_dual" 93 "test_random_backends" 94 "test_sliced_backend" 95 "test_to_numpy" 96 "test_wasserstein_1d_type_devices" 97 "test_wasserstein" 98 "test_weak_ot_bakends" 99 # TypeError: Only integers, slices... 100 "test_emd1d_device_tf" 101 ]; 102 103 disabledTestPaths = [ 104 # AttributeError: module pytest has no attribute skip_backend 105 "test/test_bregman.py" 106 "test/test_da.py" 107 "test/test_utils.py" 108 "test/test_gromov.py" 109 "test/test_helpers.py" 110 "test/test_unbalanced.py" 111 ] ++ lib.optionals (!enableDimensionalityReduction) [ 112 "test/test_dr.py" 113 ]; 114 115 pythonImportsCheck = [ 116 "ot" 117 "ot.lp" 118 ]; 119 120 meta = with lib; { 121 description = "Python Optimal Transport Library"; 122 homepage = "https://pythonot.github.io/"; 123 license = licenses.mit; 124 maintainers = with maintainers; [ yl3dy ]; 125 }; 126}