Skip to content

Conversation

AdrienCorenflos
Copy link
Contributor

Fixes #138

@rflamary rflamary added the bug label Apr 2, 2020
Copy link
Contributor

@rtavenar rtavenar left a comment

Choose a reason for hiding this comment

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

Good catch ! I just have a minor comment. Also I am not sure if it is better to have two different tests for the variants with and without weights, but this is not very important I guess.

@@ -656,7 +656,7 @@ def emd_1d(x_a, x_b, a=None, b=None, metric='sqeuclidean', p=1., dense=True,
perm_a = np.argsort(x_a_1d)
perm_b = np.argsort(x_b_1d)

G_sorted, indices, cost = emd_1d_sorted(a, b,
G_sorted, indices, cost = emd_1d_sorted(a[perm_a.flatten()], b[perm_b.flatten()],
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you do not have to flatten the permutation indices since they are computed from 1d arrays, or do you ?

Copy link
Contributor

@rtavenar rtavenar Apr 2, 2020

Choose a reason for hiding this comment

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

Could you explain why you flatten here?

Apart from that, LGTM!

test/test_ot.py Outdated
np.testing.assert_allclose(wass, wass1d_emd2)

# check loss is similar to scipy's implementation for Euclidean metric
wass_sp = wasserstein_distance(u.reshape((-1,)), v.reshape((-1,)))
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot the weights here, which is probably why the test fails at the moment

@AdrienCorenflos
Copy link
Contributor Author

AdrienCorenflos commented Apr 2, 2020 via email

@rflamary
Copy link
Collaborator

rflamary commented Apr 2, 2020

Hello @AdrienCorenflos,

Thank you for finding the bug and the PR.

In addition to the comments from @rtavenar be careful to check pep8 on test_ot.py or else the tests will fail.

Copy link
Contributor

@rtavenar rtavenar left a comment

Choose a reason for hiding this comment

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

LGTM ! Thanks a lot for this bugfix !

@rflamary rflamary changed the title Fix ordering [MRG] Fix ordering Apr 3, 2020
@rflamary rflamary merged commit d399f62 into PythonOT:master Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad value in EMD 1D
3 participants