-
Notifications
You must be signed in to change notification settings - Fork 8
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
Compute pairwise distances #278
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #278 +/- ##
=======================================
Coverage 99.76% 99.77%
=======================================
Files 14 14
Lines 846 878 +32
=======================================
+ Hits 844 876 +32
Misses 2 2 ☔ View full report in Codecov by Sentry. |
44b1e17
to
b110485
Compare
b5f4ca4
to
a20d283
Compare
58583b2
to
4f305de
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your work @lochhh!
The implementation is completely functional as is, but I think it's worth discussing the API design here.
I was thinking about this all day today, and it's not an easy problem to wrap one's head around, so as usual I resorted to drawing sketches 😉 .
Let's consider the following example:
Our current implementation exposes 3 public functions, and multiple ways of solving the above problem (i.e. getting the 3 distances of interest):
It took me a while to figure things out. Your examples were of great help and absolutely necessary, but in general it's not easy to figure out which function you need to use and there are multiple equivalent ways of doing things.
Here's what Id' propose as alternative:
We can debate the need to make cdist
private or not, but in my eyes it doesn't add any extra functionality or convenience to just having compute_pairwise_distances
.
You could argue that one can use cdist
to compute distances across different datasets, but I can't foresee a use-case for this (I may be overlooking something).
5c6528c
to
cf3c9b6
Compare
Thanks again @niksirbi for the usual thorough review! I've adopted your suggestion to remove the
|
Thanks @lochhh, I will take another look at this next week, with a fresh mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6df308e
to
f82b7f9
Compare
Co-authored-by: Niko Sirmpilatze <[email protected]>
Co-authored-by: Niko Sirmpilatze <[email protected]>
for more information, see https://pre-commit.ci
8258f2b
to
d1ca2cd
Compare
Quality Gate passedIssues Measures |
sorry both for the delay and thanks for pinging me ❤️ I can have a look on Friday, but I know that would delay this work further, so feel free to go ahead! Maybe I can draft an example instead? |
That would be perfect! |
Thanks for the initiative @sfmig. Perhaps the DLC dataset with the two mice would be a good candidate for the example? |
Description
What is this PR
Why is this PR needed?
Closes #277
What does this PR do?
_cdist
- open to rename suggestions!)compute_pairwise_distances
)da.sel
data withcoord_val.ndim == 0
TO-DO:
coord_val.ndim == 1
da.sel
withcoord_val.ndim == 0
References
#277
How has this PR been tested?
Tests passing locally and on CI
Does this PR require an update to the documentation?
Docstrings with examples are provided alongside the new functions.
Checklist: