Skip to content

[WIP] Linear Circular OT #736

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 10 commits into
base: master
Choose a base branch
from
Open

[WIP] Linear Circular OT #736

wants to merge 10 commits into from

Conversation

clbonet
Copy link
Contributor

@clbonet clbonet commented May 10, 2025

Types of changes

This PR aims to add the Linear Circular OT distance (with uniform measure on the circle as reference measure) introduced in LCOT: Linear Circular Optimal Transport
and its sliced counterpart introduced in Linear Spherical Sliced Optimal Transport: A Fast Metric for Comparing Spherical Data
.

Changes:

  • Added the ot.solver_1d.linear_circular_embedding and ot.solver_1d.linear_circular_ot functions to compute the Linear Circular OT distance.
  • Added the ot.sliced.linear_sliced_wasserstein_sphere function to compute its sliced counterpart.
  • Refactored the code for the spherical sliced distances, adding the functions ot.sliced.get_projections_sphere and ot.sliced.projection_sphere_to_circle.
  • Added tests for these functions in test/test_1d_solver and test/test_sliced.
  • Added the Linear Circular OT distance in the example plot_compute_wasserstein_circle.py
  • Modified the default behavior of ot.wasserstein_circle to always use ot.solver_1d.binary_search_circle for any p, which seems to give better results even for p=1.
  • Improved the visualization of the sphere in the example plot_ssw_unif_torch.py.

Motivation and context / Related issue

The Linear Circular OT distance with uniform measure on the circle is very fast to compute, as the OT maps can be computed in closed-forms. It is thus faster to compute than the true wasserstein distance on the circle.

How has this been tested (if it applies)

I added tests of these functions in test/test_1d_solver and test/test_sliced.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

Copy link

codecov bot commented May 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.10%. Comparing base (61e9af4) to head (52871e5).

Additional details and impacted files
@@           Coverage Diff            @@
##           master     #736    +/-   ##
========================================
  Coverage   97.09%   97.10%            
========================================
  Files         100      100            
  Lines       20432    20674   +242     
========================================
+ Hits        19839    20075   +236     
- Misses        593      599     +6     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant