From dfc0eb386aa52c9fbb26557f40ec83e758ef8246 Mon Sep 17 00:00:00 2001 From: Joseph Salmon Date: Wed, 30 Apr 2025 23:26:26 +0200 Subject: [PATCH 1/6] typo in \text{max_nz} in ot.utils.projection_sparse_simplex( --- ot/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ot/utils.py b/ot/utils.py index 1f24fa33f..a56782364 100644 --- a/ot/utils.py +++ b/ot/utils.py @@ -140,7 +140,7 @@ def projection_sparse_simplex(V, max_nz, z=1, axis=None, nx=None): r"""Projection of :math:`\mathbf{V}` onto the simplex with cardinality constraint (maximum number of non-zero elements) and then scaled by `z`. .. math:: - P\left(\mathbf{V}, max_nz, z\right) = \mathop{\arg \min}_{\substack{\mathbf{y} >= 0 \\ \sum_i \mathbf{y}_i = z} \\ ||p||_0 \le \text{max_nz}} \quad \|\mathbf{y} - \mathbf{V}\|^2 + P\left(\mathbf{V}, \text{max_nz}, z\right) = \mathop{\arg \min}_{\substack{\mathbf{y} >= 0 \\ \sum_i \mathbf{y}_i = z} \\ ||p||_0 \le \text{max_nz}} \quad \|\mathbf{y} - \mathbf{V}\|^2 Parameters ---------- From 0d9d13618f4530bdfbae04c98dad4c55471465ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Flamary?= Date: Fri, 25 Jul 2025 15:47:23 +0200 Subject: [PATCH 2/6] add line with PR number --- RELEASES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASES.md b/RELEASES.md index 848cd69fe..7a213ebb1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -30,6 +30,7 @@ - Clean references in documentation (PR #722) - Clean documentation for `ot.gromov.gromov_wasserstein` (PR #737) - Debug wheels building (PR #739) +- Fix doc for projection sparse simplex (PR #734) ## 0.9.5 From 298fee3f72c838c0c9484e462080a9c0c98e6901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Flamary?= Date: Fri, 25 Jul 2025 15:56:50 +0200 Subject: [PATCH 3/6] updatre doc --- ot/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ot/utils.py b/ot/utils.py index 1f70832f2..582ed3ed4 100644 --- a/ot/utils.py +++ b/ot/utils.py @@ -145,6 +145,10 @@ def projection_sparse_simplex(V, max_nz, z=1, axis=None, nx=None): Parameters ---------- V: 1-dim or 2-dim ndarray + max_nz: int + Maximum number of non-zero elements in the projection. + If `max_nz` is larger than the number of elements in `V`, then + the projection is equivalent to `proj_simplex(V, z)`. z: float or array If array, len(z) must be compatible with :math:`\mathbf{V}` axis: None or int From 782083b2cb5fd5ff307b3dbe1f2c4fdf71bc0e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Flamary?= Date: Fri, 25 Jul 2025 15:59:18 +0200 Subject: [PATCH 4/6] update pr number --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 7a213ebb1..542f94851 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -30,7 +30,7 @@ - Clean references in documentation (PR #722) - Clean documentation for `ot.gromov.gromov_wasserstein` (PR #737) - Debug wheels building (PR #739) -- Fix doc for projection sparse simplex (PR #734) +- Fix doc for projection sparse simplex (PR #734, PR #746) ## 0.9.5 From 7b343b2a8aeb56ad1507cf9603a393f65a0a4cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Flamary?= Date: Fri, 25 Jul 2025 16:05:00 +0200 Subject: [PATCH 5/6] update reference --- ot/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ot/utils.py b/ot/utils.py index 582ed3ed4..0f5ec1f9f 100644 --- a/ot/utils.py +++ b/ot/utils.py @@ -160,8 +160,9 @@ def projection_sparse_simplex(V, max_nz, z=1, axis=None, nx=None): ------- projection: ndarray, shape :math:`\mathbf{V}`.shape - References: - Sparse projections onto the simplex + References + ---------- + .. [1] Sparse projections onto the simplex Anastasios Kyrillidis, Stephen Becker, Volkan Cevher and, Christoph Koch ICML 2013 https://arxiv.org/abs/1206.1529 From 4691a17f0b12bb5c1213018caef784221b404798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Flamary?= Date: Mon, 28 Jul 2025 15:43:54 +0200 Subject: [PATCH 6/6] fix other part in the doc --- ot/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ot/utils.py b/ot/utils.py index 0f5ec1f9f..2312d312e 100644 --- a/ot/utils.py +++ b/ot/utils.py @@ -152,9 +152,9 @@ def projection_sparse_simplex(V, max_nz, z=1, axis=None, nx=None): z: float or array If array, len(z) must be compatible with :math:`\mathbf{V}` axis: None or int - - axis=None: project :math:`\mathbf{V}` by :math:`P(\mathbf{V}.\mathrm{ravel}(), max_nz, z)` - - axis=1: project each :math:`\mathbf{V}_i` by :math:`P(\mathbf{V}_i, max_nz, z_i)` - - axis=0: project each :math:`\mathbf{V}_{:, j}` by :math:`P(\mathbf{V}_{:, j}, max_nz, z_j)` + - axis=None: project :math:`\mathbf{V}` by :math:`P(\mathbf{V}.\mathrm{ravel}(), \text{max_nz}, z)` + - axis=1: project each :math:`\mathbf{V}_i` by :math:`P(\mathbf{V}_i, \text{max_nz}, z_i)` + - axis=0: project each :math:`\mathbf{V}_{:, j}` by :math:`P(\mathbf{V}_{:, j}, \text{max_nz}, z_j)` Returns -------