Skip to content

[MRG] Fix screenkhorn with the full budget on non-square problems - #871

Open
itzzdev09 wants to merge 2 commits into
PythonOT:masterfrom
itzzdev09:screenkhorn-full-budget-shapes
Open

itzzdev09 wants to merge 2 commits into
PythonOT:masterfrom
itzzdev09:screenkhorn-full-budget-shapes

Conversation

@itzzdev09

Copy link
Copy Markdown
Contributor

Types of changes

  • Bug fix

Description

ot.bregman.screenkhorn fails when ns_budget and nt_budget are the full sizes and the problem is not square:

a, b = ot.unif(5), ot.unif(4)
M = ot.dist(np.random.randn(5, 2), np.random.randn(4, 2))
ot.bregman.screenkhorn(a, b, M, 1.0, ns_budget=5, nt_budget=4)
# ValueError: shapes (5,) and (4,) not aligned: 5 (dim 0) != 4 (dim 0)

In the full-budget branch, vec_eps_IJc and vec_eps_IcJ were created with each other's size. In the general branch, vec_eps_IJc sums K_IJc over its columns, so it has one entry per kept source point, and vec_eps_IcJ has one per kept target point. The full-budget branch used nt and ns the other way round, which only worked when ns == nt. With the sizes swapped back, the full-budget result matches ot.sinkhorn.

How has this been tested

Added test_screenkhorn_full_budget_non_square (20 x 12, full budgets), which compares with ot.sinkhorn. It fails on master, and the existing screenkhorn test still passes.

Checklist

  • I have added tests to cover my changes.
  • I have updated the RELEASES.md file.

@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.92%. Comparing base (98d09a1) to head (d8c942c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #871      +/-   ##
==========================================
+ Coverage   96.86%   96.92%   +0.05%     
==========================================
  Files         128      128              
  Lines       26304    26312       +8     
==========================================
+ Hits        25480    25503      +23     
+ Misses        824      809      -15     
🚀 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant