Skip to content
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

Replace earthmover's distance implementation #280

Merged
merged 11 commits into from
Jan 13, 2020
Merged

Conversation

sdmccabe
Copy link
Collaborator

This resolves #232 and helps with #267 by replacing the POT-based earthmover's distance implementation with Jeremy Kun's newly MIT-licensed implementation based on ortools. His implementation is not on pypi so the relevant functions are reproduced (with the license) in nbd.py. This removes the Cython and POT workarounds we had in .travis.yml and requirements.txt to handle its installation. This will hopefully make for a smoother experience with test builds.

@sdmccabe
Copy link
Collaborator Author

image

@sdmccabe sdmccabe marked this pull request as ready for review January 13, 2020 00:16
@sdmccabe
Copy link
Collaborator Author

Is including the license at the bottom of nbd.py the way I've done sufficient?

@sdmccabe
Copy link
Collaborator Author

Seems confusing/troubling that the build passed before I had added ortools to requirements.txt; should double-check that before merging.

@sdmccabe
Copy link
Collaborator Author

And now it's failing with ortools in requirements.

@sdmccabe
Copy link
Collaborator Author

The tests passed in the previous case because NBD wasn't imported in the case of an ImportError in that module, a workaround we had previously used when adding NBD. So this all looks good to me, as long as it (in particular the license stuff) looks good to other people.

@@ -16,5 +16,3 @@ python:
- requirements: requirements.txt
- method: pip
path: .
extra_requirements:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not following why this was removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My read is that the doc 'extra_requirements in .readthedocs.yml is the same doc extra_requirements in setup.py, which was just POT, and which is also removed in this PR. Is that wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ohhh wait I think you're right! We will have to see if this build the docs correctly, but I bet you're right.

Which makes me feel Bad for not having a test branch.

dist = emd2(mass(vals1.shape[0]), mass(vals2.shape[0]), vals_dist)

vals1 = [tuple(vals1[i]) for i in range(len(vals1))]
vals2 = [tuple(vals2[i]) for i in range(len(vals2))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

[tuple(v) for v in vals]

# This file borrows code (euclidean_distance and earthmover_distance) with the
# following license:
#
# MIT License
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add the License inside earthmover_distance instead of at EOF?

@sdmccabe sdmccabe merged commit ad38da8 into netsiphd:master Jan 13, 2020
@sdmccabe sdmccabe deleted the emd branch January 13, 2020 14:49
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.

Earth mover's distance and POT dependency
2 participants