summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Flamary <remi.flamary@gmail.com>2023-03-24 10:13:59 +0100
committerGitHub <noreply@github.com>2023-03-24 10:13:59 +0100
commit981fbe3873d7c1c121499bf83557f6d72425bf69 (patch)
tree9a5472b5da421169ccdf7db7a970e6ff261ed5b3
parent897026ea1f5c35ba9e881433bc61490e70776b8c (diff)
[WIP] Build donc in GH Action and report warnings + move contributing and code of conduct in documentation (#441)
* use action for doc with wraning visible * remove space * remove space again * test pre commands * install pot properly * install compiler... * try composite action * remoe warning in sliced exmaple * pep8 * move contributing and code of conduct * cleanup * underline too short * update quickstart * replace version selector by static list to avoid jsQuery bug
-rw-r--r--.github/CONTRIBUTING.md1
-rw-r--r--.github/workflows/build_doc.yml44
-rw-r--r--README.md2
-rw-r--r--docs/source/_templates/versions.html69
-rw-r--r--docs/source/all.rst2
-rw-r--r--docs/source/code_of_conduct.rst (renamed from docs/source/.github/CODE_OF_CONDUCT.rst)4
-rw-r--r--docs/source/contributing.rst (renamed from docs/source/.github/CONTRIBUTING.rst)4
-rw-r--r--docs/source/index.rst4
-rw-r--r--docs/source/quickstart.rst92
-rw-r--r--examples/backends/plot_ssw_unif_torch.py2
10 files changed, 134 insertions, 90 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 9bc8e87..168ffb3 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -1,4 +1,3 @@
-
Contributing to POT
===================
diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml
new file mode 100644
index 0000000..93bd113
--- /dev/null
+++ b/.github/workflows/build_doc.yml
@@ -0,0 +1,44 @@
+name: Build doc
+
+on:
+ workflow_dispatch:
+ pull_request:
+ push:
+ branches:
+ - 'master'
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v1
+ # Standard drop-in approach that should work for most people.
+
+ - name: Set up Python 3.8
+ uses: actions/setup-python@v1
+ with:
+ python-version: 3.8
+
+ - name: Get Python running
+ run: |
+ python -m pip install --user --upgrade --progress-bar off pip
+ python -m pip install --user --upgrade --progress-bar off -r requirements.txt
+ python -m pip install --user --upgrade --progress-bar off -r docs/requirements.txt
+ python -m pip install --user --upgrade --progress-bar off ipython "https://api.github.com/repos/sphinx-gallery/sphinx-gallery/zipball/master" memory_profiler
+ python -m pip install --user -e .
+ # Look at what we have and fail early if there is some library conflict
+ - name: Check installation
+ run: |
+ which python
+ python -c "import ot"
+ # Build docs
+ - name: Generate HTML docs
+ uses: rickstaa/sphinx-action@master
+ with:
+ docs-folder: "docs/"
+ - uses: actions/upload-artifact@v1
+ with:
+ name: Documentation
+ path: docs/build/html/ \ No newline at end of file
diff --git a/README.md b/README.md
index 9c5e07e..2a81e95 100644
--- a/README.md
+++ b/README.md
@@ -192,7 +192,7 @@ POT has benefited from the financing or manpower from the following partners:
## Contributions and code of conduct
-Every contribution is welcome and should respect the [contribution guidelines](.github/CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](.github/CODE_OF_CONDUCT.md).
+Every contribution is welcome and should respect the [contribution guidelines](https://pythonot.github.io/master/contributing.html). Each member of the project is expected to follow the [code of conduct](https://pythonot.github.io/master/code_of_conduct.html).
## Support
diff --git a/docs/source/_templates/versions.html b/docs/source/_templates/versions.html
index f48ab86..5b1021a 100644
--- a/docs/source/_templates/versions.html
+++ b/docs/source/_templates/versions.html
@@ -1,47 +1,50 @@
<div class="rst-versions" data-toggle="rst-versions" role="note"
aria-label="versions">
- <!-- add shift_up to the class for force viewing -->
- <span class="rst-current-version" data-toggle="rst-current-version">
+ <!-- add shift_up to the class for force viewing ,
+ data-toggle="rst-current-version" -->
+ <span class="rst-current-version" style="margin-bottom:1mm;">
<span class="fa fa-book"> Python Optimal Transport</span>
- versions
- <span class="fa fa-caret-down"></span>
+ <hr style="margin-bottom:1.5mm;margin-top:5mm;">
+ <!-- versions
+ <span class="fa fa-caret-down"></span>-->
+ <span class="rst-current-version" style="display: inline-block;padding:
+ 0px;color:#fcfcfcab;float:left;font-size: 100%;">
+ Versions:
+ <a href="https://pythonot.github.io/"
+ style="padding: 3px;color:#fcfcfc;font-size: 100%;">Release</a>
+ <a href="https://pythonot.github.io/master"
+ style="padding: 3px;color:#fcfcfc;font-size: 100%;">Development</a>
+ <a href="https://github.com/PythonOT/POT"
+ style="padding: 3px;color:#fcfcfc;font-size: 100%;">Code</a>
+
+ </span>
+
+
</span>
- <div class="rst-other-versions"><!-- Inserted RTD Footer -->
+
+ <!--
+ <div class="rst-other-versions">
+
+
<div class="injected">
-
-
- <dl>
- <dt>Versions</dt>
-
- <dd><a href="https://pythonot.github.io/">Release</a></dd>
-
- <dd><a href="https://pythonot.github.io/master">Development</a></dd>
-
-
-
- </dl>
-
+
+ <dl>
+ <dt>Versions</dt>
+ <dd><a href="https://pythonot.github.io/">Release</a></dd>
-
- <dl>
- <dt>On GitHub</dt>
- <dd>
- <a href="https://github.com/PythonOT/POT">Code on Github</a>
- </dd>
-
- </dl>
-
+ <dd><a href="https://pythonot.github.io/master">Development</a></dd>
+
-
-
- <hr>
-
+ <dt><a href="https://github.com/PythonOT/POT">Code on Github</a></dt>
+
+ </dl>
+ <hr>
-</div>
-</div>
+</div>
+</div>-->
</div> \ No newline at end of file
diff --git a/docs/source/all.rst b/docs/source/all.rst
index 1b8d13c..a9d7fe2 100644
--- a/docs/source/all.rst
+++ b/docs/source/all.rst
@@ -37,7 +37,7 @@ API and modules
Main :py:mod:`ot` functions
---------------
+---------------------------
.. automodule:: ot
:members:
diff --git a/docs/source/.github/CODE_OF_CONDUCT.rst b/docs/source/code_of_conduct.rst
index d4c5cec..40b432e 100644
--- a/docs/source/.github/CODE_OF_CONDUCT.rst
+++ b/docs/source/code_of_conduct.rst
@@ -1,6 +1,6 @@
-Code of Conduct
+Code of conduct
===============
-.. include:: ../../../.github/CODE_OF_CONDUCT.md
+.. include:: ../../.github/CODE_OF_CONDUCT.md
:parser: myst_parser.sphinx_
:start-line: 2
diff --git a/docs/source/.github/CONTRIBUTING.rst b/docs/source/contributing.rst
index aef24e9..8dec19a 100644
--- a/docs/source/.github/CONTRIBUTING.rst
+++ b/docs/source/contributing.rst
@@ -1,6 +1,6 @@
Contributing to POT
===================
-.. include:: ../../../.github/CONTRIBUTING.md
+.. include:: ../../.github/CONTRIBUTING.md
:parser: myst_parser.sphinx_
- :start-line: 3
+ :start-line: 2
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 3d53ef4..0f04738 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -21,9 +21,9 @@ Contents
all
auto_examples/index
releases
- .github/CONTRIBUTING
contributors
- .github/CODE_OF_CONDUCT
+ contributing
+ code_of_conduct
.. include:: ../../README.md
diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst
index c8eac30..1dc9f71 100644
--- a/docs/source/quickstart.rst
+++ b/docs/source/quickstart.rst
@@ -127,14 +127,6 @@ been used to solve both graph Laplacian regularization OT and Gromov
Wasserstein [30]_.
-.. note::
-
- POT is originally designed to solve OT problems with Numpy interface and
- is not yet compatible with Pytorch API. We are currently working on a torch
- submodule that will provide OT solvers and losses for the most common deep
- learning configurations.
-
-
When not to use POT
"""""""""""""""""""
@@ -692,42 +684,8 @@ A list of the provided implementation is given in the following note.
:heading-level: "
-Other applications
-------------------
-
-We discuss in the following several OT related problems and tools that has been
-proposed in the OT and machine learning community.
-
-Wasserstein Discriminant Analysis
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Wasserstein Discriminant Analysis [11]_ is a generalization of `Fisher Linear Discriminant
-Analysis <https://en.wikipedia.org/wiki/Linear_discriminant_analysis>`__ that
-allows discrimination between classes that are not linearly separable. It
-consists in finding a linear projector optimizing the following criterion
-
-.. math::
- P = \text{arg}\min_P \frac{\sum_i OT_e(\mu_i\#P,\mu_i\#P)}{\sum_{i,j\neq i}
- OT_e(\mu_i\#P,\mu_j\#P)}
-
-where :math:`\#` is the push-forward operator, :math:`OT_e` is the entropic OT
-loss and :math:`\mu_i` is the
-distribution of samples from class :math:`i`. :math:`P` is also constrained to
-be in the Stiefel manifold. WDA can be solved in POT using function
-:any:`ot.dr.wda`. It requires to have installed :code:`pymanopt` and
-:code:`autograd` for manifold optimization and automatic differentiation
-respectively. Note that we also provide the Fisher discriminant estimator in
-:any:`ot.dr.fda` for easy comparison.
-
-.. warning::
-
- Note that due to the hard dependency on :code:`pymanopt` and
- :code:`autograd`, :any:`ot.dr` is not imported by default. If you want to
- use it you have to specifically import it with :code:`import ot.dr` .
-
-.. minigallery:: ot.dr.wda
- :add-heading: Examples of the use of WDA
- :heading-level: "
+Unbalanced and partial OT
+-------------------------
@@ -845,10 +803,11 @@ regularization of the problem.
:heading-level: "
+Gromov Wasserstein and extensions
+---------------------------------
-
-Gromov-Wasserstein
-^^^^^^^^^^^^^^^^^^
+Gromov Wasserstein(GW)
+^^^^^^^^^^^^^^^^^^^^^^
Gromov Wasserstein (GW) is a generalization of OT to distributions that do not lie in
the same space [13]_. In this case one cannot compute distance between samples
@@ -877,6 +836,8 @@ There also exists an entropic regularized variant of GW that has been proposed i
:add-heading: Examples of computation of GW, regularized G and FGW
:heading-level: "
+Gromov Wasserstein barycenters
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note that similarly to Wasserstein distance GW allows for the definition of GW
barycenters that can be expressed as
@@ -905,6 +866,43 @@ The implementations of FGW and FGW barycenter is provided in functions
:heading-level: "
+Other applications
+------------------
+
+We discuss in the following several OT related problems and tools that has been
+proposed in the OT and machine learning community.
+
+Wasserstein Discriminant Analysis
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Wasserstein Discriminant Analysis [11]_ is a generalization of `Fisher Linear Discriminant
+Analysis <https://en.wikipedia.org/wiki/Linear_discriminant_analysis>`__ that
+allows discrimination between classes that are not linearly separable. It
+consists in finding a linear projector optimizing the following criterion
+
+.. math::
+ P = \text{arg}\min_P \frac{\sum_i OT_e(\mu_i\#P,\mu_i\#P)}{\sum_{i,j\neq i}
+ OT_e(\mu_i\#P,\mu_j\#P)}
+
+where :math:`\#` is the push-forward operator, :math:`OT_e` is the entropic OT
+loss and :math:`\mu_i` is the
+distribution of samples from class :math:`i`. :math:`P` is also constrained to
+be in the Stiefel manifold. WDA can be solved in POT using function
+:any:`ot.dr.wda`. It requires to have installed :code:`pymanopt` and
+:code:`autograd` for manifold optimization and automatic differentiation
+respectively. Note that we also provide the Fisher discriminant estimator in
+:any:`ot.dr.fda` for easy comparison.
+
+.. warning::
+
+ Note that due to the hard dependency on :code:`pymanopt` and
+ :code:`autograd`, :any:`ot.dr` is not imported by default. If you want to
+ use it you have to specifically import it with :code:`import ot.dr` .
+
+.. minigallery:: ot.dr.wda
+ :add-heading: Examples of the use of WDA
+ :heading-level: "
+
Solving OT with Multiple backends on CPU/GPU
--------------------------------------------
diff --git a/examples/backends/plot_ssw_unif_torch.py b/examples/backends/plot_ssw_unif_torch.py
index d1de5a9..7ccc2af 100644
--- a/examples/backends/plot_ssw_unif_torch.py
+++ b/examples/backends/plot_ssw_unif_torch.py
@@ -50,7 +50,7 @@ def plot_sphere(ax):
r = np.linspace(1.0, 1.0, 50)
X, Y = np.meshgrid(xlist, ylist)
- Z = np.sqrt(r**2 - X**2 - Y**2)
+ Z = np.sqrt(np.maximum(r**2 - X**2 - Y**2, 0))
ax.plot_wireframe(X, Y, Z, color="gray", alpha=.3)
ax.plot_wireframe(X, Y, -Z, color="gray", alpha=.3) # Now plot the bottom half