Skip to content

[WIP] Clarify transported mass in partial OT - #902

Open
JaylenTang wants to merge 2 commits into
PythonOT:masterfrom
JaylenTang:docs-partial-ot-mass-review
Open

JaylenTang wants to merge 2 commits into
PythonOT:masterfrom
JaylenTang:docs-partial-ot-mass-review

Conversation

@JaylenTang

Copy link
Copy Markdown

Types of changes

Documentation and example update.

Motivation and context / Related issue

Related to #890.

Hi, I've put together a first version of the transported-mass explanation proposed in #890.

The guide already gives the partial OT formulation, and the 1D example shows different numbers of transported samples. This extends the existing 2D example to help explain what m means for weighted distributions:

  • Distinguish transported weight from a point count or a normalized fraction, including inputs with unequal total weights.
  • Compare m=0.25, 0.5, 0.75, and 1 on the same data with a fixed seed.
  • Show how much Gaussian and remote-sample weight is used, separately for the source and target.
  • Explain why lower raw cost can mean less weight was transported, rather than better matching.

It uses the existing solver and keeps the original entropic and Gromov-Wasserstein sections and attribution. The example also checks transported mass, marginal limits, and the balanced OT endpoint.

I'd appreciate feedback on the scope and whether this fits best in the existing guide and example or in a separate focused example. Thanks!

How has this been tested (if it applies)

Local checks on Python 3.12 with the NumPy CPU backend:

  • pytest test/ -q --doctest-modules --disable-warnings: 1,524 passed, 134 skipped, 4 expected failures.
  • Partial/LP doctests with the project's test/conftest.py: 20 passed.
  • Local example/export checks: 11 passed, covering constraints, repeatability, group-mass accounting, the balanced endpoint, and figure preservation.
  • Changed-file pre-commit hooks and explicit Ruff lint passed.
  • Sphinx HTML and the focused gallery build completed; the selected example executed and both new figures were checked. Existing reference and optional-dependency diagnostics remain.

PR checklist

This is a draft for feedback on the documentation and example.

@JaylenTang
JaylenTang marked this pull request as ready for review October 26, 2026 14:33
@JaylenTang

Copy link
Copy Markdown
Author

Hi @rflamary, I've added an initial implementation of the idea in #890 to this PR. When you have a chance, could you let me know whether this would be a useful addition to the documentation? I'm happy to adjust the scope. Thanks!

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.57%. Comparing base (0b6f8d5) to head (875f765).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #902      +/-   ##
==========================================
- Coverage   97.01%   94.57%   -2.45%     
==========================================
  Files         130      130              
  Lines       26879    26879              
==========================================
- Hits        26078    25420     -658     
- Misses        801     1459     +658     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rflamary rflamary left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR @JaylenTang , I have some suggestions below about shortening the user guide and about the new info in the exmaple.

application, or validation suited to that application, can inform the choice.
Inspecting several feasible masses helps show the consequences of that choice.

The :ref:`2D partial Wasserstein example

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this discussion is interesting but much too detailed for a user's guide. you can eitehr move it to the exmaple file where it makes more sens or remove it. only keep a sentence with areference to the example please.

)

print("\nExact partial Wasserstein mass study (raw transport costs):")
print(" m cost source in source out target in target out any out")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

names are unclear please dont' use in and out that can mean source/target in OT but inlier outlier possibly . Actually it would porably be more clear with aplot (and maybe more valyues of m?) where you can have larger legends for the plots

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants