From e23f4d0646a3e8d28cc146c28574359585295249 Mon Sep 17 00:00:00 2001 From: Nicolas Courty Date: Fri, 28 Feb 2020 11:44:55 +0100 Subject: solution to osx issue --- setup.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index bbcaf04..2cc3e50 100755 --- a/setup.py +++ b/setup.py @@ -8,9 +8,15 @@ from Cython.Build import cythonize import numpy import re import os +import sys +import subprocess here = path.abspath(path.dirname(__file__)) + +os.environ["CC"] = "g++" +os.environ["CXX"] = "g++" + # dirty but working __version__ = re.search( r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', # It excludes inline comment too @@ -24,12 +30,13 @@ ROOT = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(ROOT, 'README.md'), encoding="utf-8") as f: README = f.read() -# add platform dependant optional compilation argument opt_arg=["-O3"] -import platform -if platform.system()=='Darwin': - if platform.release()=='18.0.0': - opt_arg.append("-stdlib=libc++") # correspond to a compilation problem with Mojave and XCode 10 + +# add platform dependant optional compilation argument +if sys.platform.startswith('darwin'): + opt_arg.append("-stdlib=libc++") + sdk_path = subprocess.check_output(['xcrun', '--show-sdk-path']) + os.environ['CFLAGS'] = '-isysroot "{}"'.format(sdk_path.rstrip().decode("utf-8")) setup(name='POT', version=__version__, -- cgit v1.2.3 From 8df1b72d664a57bfbee085f994539a843f25c942 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 20 Apr 2020 15:32:05 +0200 Subject: bump beta version and update setup.py --- ot/__init__.py | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'setup.py') diff --git a/ot/__init__.py b/ot/__init__.py index 4fcb800..1e57b78 100644 --- a/ot/__init__.py +++ b/ot/__init__.py @@ -73,7 +73,7 @@ from .da import sinkhorn_lpl1_mm # utils functions from .utils import dist, unif, tic, toc, toq -__version__ = "0.6.0" +__version__ = "0.7.0b" __all__ = ['emd', 'emd2', 'emd_1d', 'sinkhorn', 'sinkhorn2', 'utils', 'datasets', 'bregman', 'lp', 'tic', 'toc', 'toq', 'gromov', diff --git a/setup.py b/setup.py index bb00854..e780187 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ setup(name='POT', long_description_content_type='text/markdown', author=u'Remi Flamary, Nicolas Courty', author_email='remi.flamary@gmail.com, ncourty@gmail.com', - url='https://github.com/rflamary/POT', + url='https://github.com/PythonOT/POT', packages=find_packages(), ext_modules = cythonize(Extension( "ot.lp.emd_wrap", # the extension name @@ -56,7 +56,7 @@ setup(name='POT', extra_compile_args=opt_arg )), platforms=['linux','macosx','windows'], - download_url='https://github.com/rflamary/POT/archive/{}.tar.gz'.format(__version__), + download_url='https://github.com/PythonOT/POT/archive/{}.tar.gz'.format(__version__), license = 'MIT', scripts=[], data_files=[], -- cgit v1.2.3 From 8933a84a14bfda3da66983ea35784ad90091f439 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 20 Apr 2020 15:53:40 +0200 Subject: pep8 setup.py and remove cython cpp files --- setup.py | 94 ++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 44 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index e780187..4640d00 100755 --- a/setup.py +++ b/setup.py @@ -9,12 +9,12 @@ import numpy import re import os import sys -import subprocess +import subprocess here = path.abspath(path.dirname(__file__)) -os.environ["CC"] = "g++" +os.environ["CC"] = "g++" os.environ["CXX"] = "g++" # dirty but working @@ -30,61 +30,67 @@ ROOT = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(ROOT, 'README.md'), encoding="utf-8") as f: README = f.read() -opt_arg=["-O3"] +opt_arg = ["-O3"] + +# clean cython output is clean is called +if 'clean' in sys.argv[1:]: + if os.path.isfile('ot/lp/emd_wrap.cpp'): + os.remove('ot/lp/emd_wrap.cpp') + # add platform dependant optional compilation argument if sys.platform.startswith('darwin'): - opt_arg.append("-stdlib=libc++") - sdk_path = subprocess.check_output(['xcrun', '--show-sdk-path']) - os.environ['CFLAGS'] = '-isysroot "{}"'.format(sdk_path.rstrip().decode("utf-8")) + opt_arg.append("-stdlib=libc++") + sdk_path = subprocess.check_output(['xcrun', '--show-sdk-path']) + os.environ['CFLAGS'] = '-isysroot "{}"'.format(sdk_path.rstrip().decode("utf-8")) setup(name='POT', version=__version__, description='Python Optimal Transport Library', long_description=README, - long_description_content_type='text/markdown', + long_description_content_type='text/markdown', author=u'Remi Flamary, Nicolas Courty', author_email='remi.flamary@gmail.com, ncourty@gmail.com', url='https://github.com/PythonOT/POT', packages=find_packages(), - ext_modules = cythonize(Extension( - "ot.lp.emd_wrap", # the extension name - sources=["ot/lp/emd_wrap.pyx", "ot/lp/EMD_wrapper.cpp"], # the Cython source and - # additional C++ source files - language="c++", # generate and compile C++ code, - include_dirs=[numpy.get_include(),os.path.join(ROOT,'ot/lp')], - extra_compile_args=opt_arg - )), - platforms=['linux','macosx','windows'], + ext_modules=cythonize(Extension( + "ot.lp.emd_wrap", # the extension name + sources=["ot/lp/emd_wrap.pyx", "ot/lp/EMD_wrapper.cpp"], # the Cython source and + # additional C++ source files + language="c++", # generate and compile C++ code, + include_dirs=[numpy.get_include(), os.path.join(ROOT, 'ot/lp')], + extra_compile_args=opt_arg + )), + platforms=['linux', 'macosx', 'windows'], download_url='https://github.com/PythonOT/POT/archive/{}.tar.gz'.format(__version__), - license = 'MIT', + license='MIT', scripts=[], data_files=[], - requires=["numpy","scipy","cython"], - install_requires=["numpy","scipy","cython"], + requires=["numpy", "scipy", "cython"], + install_requires=["numpy", "scipy", "cython"], classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Environment :: Console', - 'Operating System :: OS Independent', - 'Operating System :: MacOS', - 'Operating System :: POSIX', - 'Programming Language :: Python', - 'Programming Language :: C++', - 'Programming Language :: C', - 'Programming Language :: Cython', - 'Topic :: Utilities', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - ] - ) + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Environment :: Console', + 'Operating System :: OS Independent', + 'Operating System :: MacOS', + 'Operating System :: POSIX', + 'Programming Language :: Python', + 'Programming Language :: C++', + 'Programming Language :: C', + 'Programming Language :: Cython', + 'Topic :: Utilities', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ] + ) -- cgit v1.2.3 From e65c1f745cf2eacc6672727e7a3869efd8318768 Mon Sep 17 00:00:00 2001 From: Romain Tavenard Date: Mon, 4 May 2020 11:19:35 +0200 Subject: [WIP] Improved docs and changed scipy version (#163) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improved docs and changed scipy version * Fixed dependency bug in setup.py * dependencies set to minimal versions for tests * add requirements file * added minimal version build for scipy (testing 1.2) * bugfix in minimal deps build * (yet another) bugfix in minimal deps build * minimal deps now reflect README.md * minimal deps: no autograd nor pymanopt * refactored workflow names * minimal deps: no doctests * minimal deps: numpy 1.16 * trigger GH Actions on PR * better merge * re-add minimal-deps... * bugfix in yaml * enforce np>=1.16 * enforce scipy and cython versions too * requires / install_requires * requires / install_requires / requires * setup_requires Co-authored-by: Rémi Flamary --- .github/requirements_strict.txt | 7 ++ .github/workflows/build_tests.yml | 32 ++++++- README.md | 2 +- .../barycenters/plot_free_support_barycenter.py | 6 +- examples/domain-adaptation/plot_otda_d2.py | 2 +- examples/domain-adaptation/plot_otda_mapping.py | 4 +- .../plot_otda_mapping_colors_images.py | 1 + examples/gromov/plot_barycenter_fgw.py | 11 ++- examples/gromov/plot_fgw.py | 10 +- examples/plot_compute_emd.py | 4 +- examples/plot_optim_OTreg.py | 6 +- examples/plot_screenkhorn_1D.py | 7 +- examples/plot_stochastic.py | 101 +++++++++------------ requirements.txt | 2 +- setup.py | 3 +- 15 files changed, 110 insertions(+), 88 deletions(-) create mode 100644 .github/requirements_strict.txt (limited to 'setup.py') diff --git a/.github/requirements_strict.txt b/.github/requirements_strict.txt new file mode 100644 index 0000000..d7539c5 --- /dev/null +++ b/.github/requirements_strict.txt @@ -0,0 +1,7 @@ +numpy==1.16.* +scipy==1.0.* +cython==0.23.* +matplotlib +cvxopt +scikit-learn +pytest diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 652655f..41b08b3 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -2,9 +2,9 @@ name: build on: push: - branches: - - '**' + pull_request: + create: branches: - 'master' @@ -49,6 +49,34 @@ jobs: codecov + linux-minimal-deps: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.6] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r .github/requirements_strict.txt + pip install pytest + pip install -U "sklearn" + - name: Install POT + run: | + pip install -e . + - name: Run tests + run: | + python -m pytest -v test/ ot/ --ignore ot/gpu/ + + macos: runs-on: macOS-latest strategy: diff --git a/README.md b/README.md index b9b8f45..5ee4cee 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ year={2017} The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: -- Numpy (>=1.11) +- Numpy (>=1.16) - Scipy (>=1.0) - Cython (>=0.23) - Matplotlib (>=1.5) diff --git a/examples/barycenters/plot_free_support_barycenter.py b/examples/barycenters/plot_free_support_barycenter.py index 64b89e4..27ddc8e 100644 --- a/examples/barycenters/plot_free_support_barycenter.py +++ b/examples/barycenters/plot_free_support_barycenter.py @@ -4,7 +4,7 @@ 2D free support Wasserstein barycenters of distributions ==================================================== -Illustration of 2D Wasserstein barycenters if discributions that are weighted +Illustration of 2D Wasserstein barycenters if distributions are weighted sum of diracs. """ @@ -21,7 +21,7 @@ import ot ############################################################################## # Generate data # ------------- -#%% parameters and data generation + N = 3 d = 2 measures_locations = [] @@ -46,7 +46,7 @@ for i in range(N): ############################################################################## # Compute free support barycenter -# ------------- +# ------------------------------- k = 10 # number of Diracs of the barycenter X_init = np.random.normal(0., 1., (k, d)) # initial Dirac locations diff --git a/examples/domain-adaptation/plot_otda_d2.py b/examples/domain-adaptation/plot_otda_d2.py index f49a570..d8b2a93 100644 --- a/examples/domain-adaptation/plot_otda_d2.py +++ b/examples/domain-adaptation/plot_otda_d2.py @@ -25,7 +25,7 @@ import ot import ot.plot ############################################################################## -# generate data +# Generate data # ------------- n_samples_source = 150 diff --git a/examples/domain-adaptation/plot_otda_mapping.py b/examples/domain-adaptation/plot_otda_mapping.py index ded2bdf..d21d3c9 100644 --- a/examples/domain-adaptation/plot_otda_mapping.py +++ b/examples/domain-adaptation/plot_otda_mapping.py @@ -9,8 +9,8 @@ time both the coupling transport and approximate the transport map with either a linear or a kernelized mapping as introduced in [8]. [8] M. Perrot, N. Courty, R. Flamary, A. Habrard, - "Mapping estimation for discrete optimal transport", - Neural Information Processing Systems (NIPS), 2016. +"Mapping estimation for discrete optimal transport", +Neural Information Processing Systems (NIPS), 2016. """ # Authors: Remi Flamary diff --git a/examples/domain-adaptation/plot_otda_mapping_colors_images.py b/examples/domain-adaptation/plot_otda_mapping_colors_images.py index 9d3a7c7..ee5c8b0 100644 --- a/examples/domain-adaptation/plot_otda_mapping_colors_images.py +++ b/examples/domain-adaptation/plot_otda_mapping_colors_images.py @@ -9,6 +9,7 @@ estimation [8]. [6] Ferradans, S., Papadakis, N., Peyre, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882. + [8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for discrete optimal transport", Neural Information Processing Systems (NIPS), 2016. diff --git a/examples/gromov/plot_barycenter_fgw.py b/examples/gromov/plot_barycenter_fgw.py index 77b0370..3f81765 100644 --- a/examples/gromov/plot_barycenter_fgw.py +++ b/examples/gromov/plot_barycenter_fgw.py @@ -4,14 +4,15 @@ Plot graphs' barycenter using FGW ================================= -This example illustrates the computation barycenter of labeled graphs using FGW +This example illustrates the computation barycenter of labeled graphs using +FGW [18]. Requires networkx >=2 -.. [18] Vayer Titouan, Chapel Laetitia, Flamary R{\'e}mi, Tavenard Romain - and Courty Nicolas - "Optimal Transport for structured data with application on graphs" - International Conference on Machine Learning (ICML). 2019. +[18] Vayer Titouan, Chapel Laetitia, Flamary Rémi, Tavenard Romain +and Courty Nicolas +"Optimal Transport for structured data with application on graphs" +International Conference on Machine Learning (ICML). 2019. """ diff --git a/examples/gromov/plot_fgw.py b/examples/gromov/plot_fgw.py index 73e486e..97fe619 100644 --- a/examples/gromov/plot_fgw.py +++ b/examples/gromov/plot_fgw.py @@ -4,12 +4,12 @@ Plot Fused-gromov-Wasserstein ============================== -This example illustrates the computation of FGW for 1D measures[18]. +This example illustrates the computation of FGW for 1D measures [18]. -.. [18] Vayer Titouan, Chapel Laetitia, Flamary R{\'e}mi, Tavenard Romain - and Courty Nicolas - "Optimal Transport for structured data with application on graphs" - International Conference on Machine Learning (ICML). 2019. +[18] Vayer Titouan, Chapel Laetitia, Flamary Rémi, Tavenard Romain +and Courty Nicolas +"Optimal Transport for structured data with application on graphs" +International Conference on Machine Learning (ICML). 2019. """ diff --git a/examples/plot_compute_emd.py b/examples/plot_compute_emd.py index 3340115..527a847 100644 --- a/examples/plot_compute_emd.py +++ b/examples/plot_compute_emd.py @@ -4,8 +4,8 @@ Plot multiple EMD ================= -Shows how to compute multiple EMD and Sinkhorn with two differnt -ground metrics and plot their values for diffeent distributions. +Shows how to compute multiple EMD and Sinkhorn with two different +ground metrics and plot their values for different distributions. """ diff --git a/examples/plot_optim_OTreg.py b/examples/plot_optim_OTreg.py index 51e2fdc..5eb15bd 100644 --- a/examples/plot_optim_OTreg.py +++ b/examples/plot_optim_OTreg.py @@ -6,7 +6,7 @@ Regularized OT with generic solver Illustrates the use of the generic solver for regularized OT with user-designed regularization term. It uses Conditional gradient as in [6] and -generalized Conditional Gradient as proposed in [5][7]. +generalized Conditional Gradient as proposed in [5,7]. [5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, Optimal Transport for @@ -14,8 +14,8 @@ Domain Adaptation, in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1. [6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). -Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, -7(3), 1853-1882. +Regularized discrete optimal transport. SIAM Journal on Imaging +Sciences, 7(3), 1853-1882. [7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). Generalized conditional gradient: analysis of convergence and applications. diff --git a/examples/plot_screenkhorn_1D.py b/examples/plot_screenkhorn_1D.py index 840ead8..785642a 100644 --- a/examples/plot_screenkhorn_1D.py +++ b/examples/plot_screenkhorn_1D.py @@ -4,8 +4,11 @@ 1D Screened optimal transport =============================== -This example illustrates the computation of Screenkhorn: -Screening Sinkhorn Algorithm for Optimal transport. +This example illustrates the computation of Screenkhorn [26]. + +[26] Alaya M. Z., Bérar M., Gasso G., Rakotomamonjy A. (2019). +Screening Sinkhorn Algorithm for Regularized Optimal Transport, +Advances in Neural Information Processing Systems 33 (NeurIPS). """ # Author: Mokhtar Z. Alaya diff --git a/examples/plot_stochastic.py b/examples/plot_stochastic.py index 742f8d9..3a1ef31 100644 --- a/examples/plot_stochastic.py +++ b/examples/plot_stochastic.py @@ -1,10 +1,18 @@ """ -========================== +=================== Stochastic examples -========================== +=================== This example is designed to show how to use the stochatic optimization -algorithms for descrete and semicontinous measures from the POT library. +algorithms for discrete and semi-continuous measures from the POT library. + +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. +Stochastic Optimization for Large-scale Optimal Transport. +Advances in Neural Information Processing Systems (2016). + +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & +Blondel, M. Large-scale Optimal Transport and Mapping Estimation. +International Conference on Learning Representation (2018) """ @@ -19,16 +27,14 @@ import ot.plot ############################################################################# -# COMPUTE TRANSPORTATION MATRIX FOR SEMI-DUAL PROBLEM -############################################################################# -############################################################################# -# DISCRETE CASE: +# Compute the Transportation Matrix for the Semi-Dual Problem +# ----------------------------------------------------------- # -# Sample two discrete measures for the discrete case -# --------------------------------------------- +# Discrete case +# ````````````` # -# Define 2 discrete measures a and b, the points where are defined the source -# and the target measures and finally the cost matrix c. +# Sample two discrete measures for the discrete case and compute their cost +# matrix c. n_source = 7 n_target = 4 @@ -44,12 +50,7 @@ Y_target = rng.randn(n_target, 2) M = ot.dist(X_source, Y_target) ############################################################################# -# # Call the "SAG" method to find the transportation matrix in the discrete case -# --------------------------------------------- -# -# Define the method "SAG", call ot.solve_semi_dual_entropic and plot the -# results. method = "SAG" sag_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, @@ -57,14 +58,12 @@ sag_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, print(sag_pi) ############################################################################# -# SEMICONTINOUS CASE: +# Semi-Continuous Case +# ```````````````````` # # Sample one general measure a, one discrete measures b for the semicontinous -# case -# --------------------------------------------- -# -# Define one general measure a, one discrete measures b, the points where -# are defined the source and the target measures and finally the cost matrix c. +# case, the points where source and target measures are defined and compute the +# cost matrix. n_source = 7 n_target = 4 @@ -81,13 +80,8 @@ Y_target = rng.randn(n_target, 2) M = ot.dist(X_source, Y_target) ############################################################################# -# # Call the "ASGD" method to find the transportation matrix in the semicontinous -# case -# --------------------------------------------- -# -# Define the method "ASGD", call ot.solve_semi_dual_entropic and plot the -# results. +# case. method = "ASGD" asgd_pi, log_asgd = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, @@ -96,23 +90,17 @@ print(log_asgd['alpha'], log_asgd['beta']) print(asgd_pi) ############################################################################# -# # Compare the results with the Sinkhorn algorithm -# --------------------------------------------- -# -# Call the Sinkhorn algorithm from POT sinkhorn_pi = ot.sinkhorn(a, b, M, reg) print(sinkhorn_pi) ############################################################################## -# PLOT TRANSPORTATION MATRIX -############################################################################## - -############################################################################## -# Plot SAG results -# ---------------- +# Plot Transportation Matrices +# ```````````````````````````` +# +# For SAG pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sag_pi, 'semi-dual : OT matrix SAG') @@ -120,8 +108,7 @@ pl.show() ############################################################################## -# Plot ASGD results -# ----------------- +# For ASGD pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, asgd_pi, 'semi-dual : OT matrix ASGD') @@ -129,8 +116,7 @@ pl.show() ############################################################################## -# Plot Sinkhorn results -# --------------------- +# For Sinkhorn pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sinkhorn_pi, 'OT matrix Sinkhorn') @@ -138,17 +124,14 @@ pl.show() ############################################################################# -# COMPUTE TRANSPORTATION MATRIX FOR DUAL PROBLEM -############################################################################# -############################################################################# -# SEMICONTINOUS CASE: +# Compute the Transportation Matrix for the Dual Problem +# ------------------------------------------------------ # -# Sample one general measure a, one discrete measures b for the semicontinous -# case -# --------------------------------------------- +# Semi-continuous case +# ```````````````````` # -# Define one general measure a, one discrete measures b, the points where -# are defined the source and the target measures and finally the cost matrix c. +# Sample one general measure a, one discrete measures b for the semi-continuous +# case and compute the cost matrix c. n_source = 7 n_target = 4 @@ -169,10 +152,7 @@ M = ot.dist(X_source, Y_target) ############################################################################# # # Call the "SGD" dual method to find the transportation matrix in the -# semicontinous case -# --------------------------------------------- -# -# Call ot.solve_dual_entropic and plot the results. +# semi-continuous case sgd_dual_pi, log_sgd = ot.stochastic.solve_dual_entropic(a, b, M, reg, batch_size, numItermax, @@ -183,7 +163,7 @@ print(sgd_dual_pi) ############################################################################# # # Compare the results with the Sinkhorn algorithm -# --------------------------------------------- +# ``````````````````````````````````````````````` # # Call the Sinkhorn algorithm from POT @@ -191,8 +171,10 @@ sinkhorn_pi = ot.sinkhorn(a, b, M, reg) print(sinkhorn_pi) ############################################################################## -# Plot SGD results -# ----------------- +# Plot Transportation Matrices +# ```````````````````````````` +# +# For SGD pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sgd_dual_pi, 'dual : OT matrix SGD') @@ -200,8 +182,7 @@ pl.show() ############################################################################## -# Plot Sinkhorn results -# --------------------- +# For Sinkhorn pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, sinkhorn_pi, 'OT matrix Sinkhorn') diff --git a/requirements.txt b/requirements.txt index bee22f7..331dd57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ numpy -scipy>=1.0 +scipy>=1.3 cython matplotlib autograd diff --git a/setup.py b/setup.py index 4640d00..91c24d9 100755 --- a/setup.py +++ b/setup.py @@ -67,7 +67,8 @@ setup(name='POT', scripts=[], data_files=[], requires=["numpy", "scipy", "cython"], - install_requires=["numpy", "scipy", "cython"], + setup_requires=["numpy>=1.16", "scipy>=1.0", "cython>=0.23"], + install_requires=["numpy>=1.16", "scipy>=1.0", "cython>=0.23"], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', -- cgit v1.2.3