Skip to content
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 @@ -22,6 +22,7 @@

#### Closed issues

- Fix `ot.bregman.screenkhorn` failing with a shape error when `ns_budget` and `nt_budget` are the full source and target sizes and these differ (PR #871)
- Fix ordinary JAX gradients for dense `ot.emd2` and preserve the magnitude and higher-order dependence of gradients supplied to `JaxBackend.set_gradients`, including the envelope gradients in `ot.solve` (Issue #625)
- Fix `ot.semidiscrete_wasserstein2_unif_circle` pairing sorted sample locations with unsorted weights, which broke permutation and rotation invariance for nonuniform weights (Issue #921)
- Fix an out-of-bounds read in `ot.bsp.merge_bijections`: the number of plans was taken from `perms.shape[1]` (the number of samples) instead of `perms.shape[0]`, so merging fewer plans than samples read past the array and merging more silently dropped plans. A `perms` outside the documented `(n_plans, n_samples)` layout, an empty plan stack and rows that are not permutations are now rejected (PR #911, Issue #910)
Expand Down
4 changes: 2 additions & 2 deletions ot/bregman/_screenkhorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def projection(u, epsilon):
K_IJc = []
K_IcJ = []

vec_eps_IJc = nx.zeros((nt,), type_as=M)
vec_eps_IcJ = nx.zeros((ns,), type_as=M)
vec_eps_IJc = nx.zeros((ns,), type_as=M)
vec_eps_IcJ = nx.zeros((nt,), type_as=M)

else:
# sum of rows and columns of K
Expand Down
14 changes: 14 additions & 0 deletions test/test_bregman.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,20 @@ def test_screenkhorn(nx):
np.testing.assert_allclose(G_sink.sum(1), G_screen.sum(1), atol=1e-02)



def test_screenkhorn_full_budget_non_square():
# with the full budget no point is screened out, which used to fail with
# a shape error whenever the source and target sizes differ
rng = np.random.RandomState(0)
ns, nt = 20, 12
a = ot.unif(ns)
b = ot.unif(nt)
M = ot.dist(rng.randn(ns, 2), rng.randn(nt, 2))

G_screen = ot.bregman.screenkhorn(a, b, M, 1.0, ns_budget=ns, nt_budget=nt)
np.testing.assert_allclose(G_screen, ot.sinkhorn(a, b, M, 1.0), atol=1e-4)


def test_convolutional_barycenter_non_square(nx):
# test for image with height not equal width
A = np.ones((2, 2, 3)) / (2 * 3)
Expand Down
Loading