Skip to content

Finish PR 734 : typo in \text{max_nz} in ot.utils.projection_sparse_simplex #746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, PR #746)

## 0.9.5

Expand Down
11 changes: 8 additions & 3 deletions ot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,15 @@ 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
----------
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
Expand All @@ -156,8 +160,9 @@ def projection_sparse_simplex(V, max_nz, z=1, axis=None, nx=None):
-------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you're at it you fix them int he 3 lines above.
Screenshot 2025-07-25 at 17 41 13

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
Expand Down
Loading