From e65606ae498bd611f6a994868c2a66dfbea403cd Mon Sep 17 00:00:00 2001 From: RĂ©mi Flamary Date: Mon, 20 Apr 2020 15:19:09 +0200 Subject: big update examples --- docs/source/auto_examples/plot_OT_2D_samples.rst | 121 +++++++++++++++-------- 1 file changed, 79 insertions(+), 42 deletions(-) (limited to 'docs/source/auto_examples/plot_OT_2D_samples.rst') diff --git a/docs/source/auto_examples/plot_OT_2D_samples.rst b/docs/source/auto_examples/plot_OT_2D_samples.rst index 1f1d713..460bb95 100644 --- a/docs/source/auto_examples/plot_OT_2D_samples.rst +++ b/docs/source/auto_examples/plot_OT_2D_samples.rst @@ -1,6 +1,12 @@ +.. only:: html + + .. note:: + :class: sphx-glr-download-link-note + Click :ref:`here ` to download the full example code + .. rst-class:: sphx-glr-example-title -.. _sphx_glr_auto_examples_plot_OT_2D_samples.py: + .. _sphx_glr_auto_examples_plot_OT_2D_samples.py: ==================================================== @@ -12,8 +18,7 @@ sum of diracs. The OT matrix is plotted with the samples. - -.. code-block:: python +.. code-block:: default # Author: Remi Flamary @@ -32,15 +37,13 @@ sum of diracs. The OT matrix is plotted with the samples. + Generate data ------------- +.. code-block:: default -.. code-block:: python - - - #%% parameters and data generation n = 50 # nb samples @@ -65,15 +68,13 @@ Generate data + Plot data --------- +.. code-block:: default -.. code-block:: python - - - #%% plot samples pl.figure(1) pl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples') @@ -94,25 +95,31 @@ Plot data * .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_001.png - :scale: 47 + :class: sphx-glr-multi-img * .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_002.png - :scale: 47 + :class: sphx-glr-multi-img +.. rst-class:: sphx-glr-script-out + Out: -Compute EMD ------------ + .. code-block:: none + + + Text(0.5, 1.0, 'Cost matrix M') -.. code-block:: python +Compute EMD +----------- + +.. code-block:: default - #%% EMD G0 = ot.emd(a, b, M) @@ -136,26 +143,32 @@ Compute EMD * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_005.png - :scale: 47 + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_003.png + :class: sphx-glr-multi-img * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_006.png - :scale: 47 + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_004.png + :class: sphx-glr-multi-img +.. rst-class:: sphx-glr-script-out + Out: -Compute Sinkhorn ----------------- + .. code-block:: none + Text(0.5, 1.0, 'OT matrix with samples') -.. code-block:: python - #%% sinkhorn +Compute Sinkhorn +---------------- + + +.. code-block:: default + # reg term lambd = 1e-3 @@ -184,26 +197,33 @@ Compute Sinkhorn * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_009.png - :scale: 47 + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_005.png + :class: sphx-glr-multi-img * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_010.png - :scale: 47 + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_006.png + :class: sphx-glr-multi-img +.. rst-class:: sphx-glr-script-out + Out: -Emprirical Sinkhorn ----------------- + .. code-block:: none + + /home/rflamary/PYTHON/POT/examples/plot_OT_2D_samples.py:103: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. + pl.show() -.. code-block:: python + +Emprirical Sinkhorn +---------------- - #%% sinkhorn +.. code-block:: default + # reg term lambd = 1e-3 @@ -230,38 +250,55 @@ Emprirical Sinkhorn * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_013.png - :scale: 47 + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_007.png + :class: sphx-glr-multi-img * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_014.png - :scale: 47 + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_008.png + :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out - Out:: + Out: + + .. code-block:: none + /home/rflamary/PYTHON/POT/ot/bregman.py:363: RuntimeWarning: divide by zero encountered in true_divide + v = np.divide(b, KtransposeU) Warning: numerical errors at iteration 0 + /home/rflamary/PYTHON/POT/ot/plot.py:90: RuntimeWarning: invalid value encountered in double_scalars + if G[i, j] / mx > thr: + /home/rflamary/PYTHON/POT/examples/plot_OT_2D_samples.py:128: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. + pl.show() + -**Total running time of the script:** ( 0 minutes 2.616 seconds) +.. rst-class:: sphx-glr-timing + + **Total running time of the script:** ( 0 minutes 2.154 seconds) + + +.. _sphx_glr_download_auto_examples_plot_OT_2D_samples.py: + .. only :: html .. container:: sphx-glr-footer + :class: sphx-glr-footer-example + - .. container:: sphx-glr-download + .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_OT_2D_samples.py ` - .. container:: sphx-glr-download + .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_OT_2D_samples.ipynb ` @@ -270,4 +307,4 @@ Emprirical Sinkhorn .. rst-class:: sphx-glr-signature - `Gallery generated by Sphinx-Gallery `_ + `Gallery generated by Sphinx-Gallery `_ -- cgit v1.2.3