2021-08-22 07:53:02 +00:00
|
|
|
{ lib
|
2022-06-16 17:23:12 +00:00
|
|
|
, autograd
|
2021-08-22 07:53:02 +00:00
|
|
|
, buildPythonPackage
|
2022-06-16 17:23:12 +00:00
|
|
|
, cupy
|
|
|
|
, cvxopt
|
2021-08-22 07:53:02 +00:00
|
|
|
, cython
|
2022-06-16 17:23:12 +00:00
|
|
|
, fetchPypi
|
2021-08-22 07:53:02 +00:00
|
|
|
, matplotlib
|
2022-06-16 17:23:12 +00:00
|
|
|
, numpy
|
|
|
|
, tensorflow
|
2021-08-22 07:53:02 +00:00
|
|
|
, pymanopt
|
|
|
|
, pytestCheckHook
|
2022-06-16 17:23:12 +00:00
|
|
|
, pythonOlder
|
|
|
|
, scikit-learn
|
|
|
|
, scipy
|
2021-08-22 07:53:02 +00:00
|
|
|
, enableDimensionalityReduction ? false
|
|
|
|
, enableGPU ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pot";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "0.9.1";
|
2022-06-16 17:23:12 +00:00
|
|
|
format = "setuptools";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
pname = "POT";
|
|
|
|
inherit version;
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-gcJTJ6ABl/8Rwf5SIc8YGtHf/mFWRBUuLhFd3d9eWRs=";
|
2021-08-22 07:53:02 +00:00
|
|
|
};
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
numpy
|
|
|
|
cython
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
|
|
|
scipy
|
|
|
|
] ++ lib.optionals enableGPU [
|
|
|
|
cupy
|
|
|
|
] ++ lib.optionals enableDimensionalityReduction [
|
|
|
|
autograd
|
|
|
|
pymanopt
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-06-16 17:23:12 +00:00
|
|
|
cvxopt
|
|
|
|
matplotlib
|
|
|
|
numpy
|
|
|
|
tensorflow
|
|
|
|
scikit-learn
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.cfg \
|
2022-06-16 17:23:12 +00:00
|
|
|
--replace " --cov-report= --cov=ot" "" \
|
|
|
|
--replace " --durations=20" "" \
|
|
|
|
--replace " --junit-xml=junit-results.xml" ""
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace '"oldest-supported-numpy", ' ""
|
2021-08-22 07:53:02 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# we don't need setup.py to find the macos sdk for us
|
|
|
|
sed -i '/sdk_path/d' setup.py
|
|
|
|
'';
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
# To prevent importing of an incomplete package from the build directory
|
|
|
|
# instead of nix store (`ot` is the top-level package name).
|
|
|
|
preCheck = ''
|
|
|
|
rm -r ot
|
|
|
|
'';
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
disabledTests = [
|
|
|
|
# GPU tests are always skipped because of sandboxing
|
|
|
|
"warnings"
|
|
|
|
# Fixture is not available
|
|
|
|
"test_conditional_gradient"
|
|
|
|
"test_convert_between_backends"
|
|
|
|
"test_emd_backends"
|
|
|
|
"test_emd_emd2_types_devices"
|
|
|
|
"test_emd1d_type_devices"
|
|
|
|
"test_emd2_backends"
|
|
|
|
"test_factored_ot_backends"
|
|
|
|
"test_free_support_barycenter_backends"
|
|
|
|
"test_func_backends"
|
|
|
|
"test_generalized_conditional_gradient"
|
|
|
|
"test_line_search_armijo"
|
|
|
|
"test_loss_dual"
|
|
|
|
"test_max_sliced_backend"
|
|
|
|
"test_plan_dual"
|
|
|
|
"test_random_backends"
|
|
|
|
"test_sliced_backend"
|
|
|
|
"test_to_numpy"
|
|
|
|
"test_wasserstein_1d_type_devices"
|
|
|
|
"test_wasserstein"
|
|
|
|
"test_weak_ot_bakends"
|
|
|
|
# TypeError: Only integers, slices...
|
|
|
|
"test_emd1d_device_tf"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTestPaths = [
|
|
|
|
# AttributeError: module pytest has no attribute skip_backend
|
|
|
|
"test/test_bregman.py"
|
|
|
|
"test/test_da.py"
|
|
|
|
"test/test_utils.py"
|
|
|
|
"test/test_gromov.py"
|
|
|
|
"test/test_helpers.py"
|
|
|
|
"test/test_unbalanced.py"
|
|
|
|
] ++ lib.optionals (!enableDimensionalityReduction) [
|
|
|
|
"test/test_dr.py"
|
|
|
|
];
|
2021-08-22 07:53:02 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"ot"
|
|
|
|
"ot.lp"
|
|
|
|
];
|
2021-08-22 07:53:02 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
meta = with lib; {
|
2021-08-22 07:53:02 +00:00
|
|
|
description = "Python Optimal Transport Library";
|
|
|
|
homepage = "https://pythonot.github.io/";
|
2022-06-16 17:23:12 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ yl3dy ];
|
2021-08-22 07:53:02 +00:00
|
|
|
};
|
|
|
|
}
|