-
Notifications
You must be signed in to change notification settings - Fork 0
MAINT additional cleaning in reachibility.pyx #5
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
MAINT additional cleaning in reachibility.pyx #5
Conversation
|
It was easier to make a PR than commenting. |
| a core point. | ||
| max_dist : float, default=0.0 | ||
| max_distance : float, default=0.0 |
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.
I think that we can be explicit regarding the naming.
| `LIL` format. | ||
| min_points : int, default=5 | ||
| min_samples : int, default=5 |
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.
Change the name to be consistent with the high-level function and DBSCAN as well
| )[farther_neighbor_idx] | ||
| else: | ||
| core_distances[i] = np.infty | ||
| core_distances[i] = INFINITY |
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.
This would avoid a Python interaction
| graph of a distance matrix. Note that computation is performed in-place for | ||
| `distance_matrix`. If out-of-place computation is required, pass a copy to | ||
| this function. | ||
| def mutual_reachability_graph( |
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.
Since we build the graph, I prefer to make it explicit.
|
The test could be something like: import numpy as np
from scipy import sparse
from sklearn.utils._testing import assert_allclose
dist = np.random.randn(5, 5)
mr_dense = mutual_reachability_graph(dist)
mr_sparse = mutual_reachability_graph(sparse.lil_matrix(dist))
assert_allclose(mr_sparse.A, mr_dense)With my PR it fails. I will have a closer look to see what is wrong. |
glemaitre
left a comment
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.
I put the PR WIP but basically this is now working.
I have to update the documentation and make a pass to be sure that I like what I wrote.
| graph of a distance matrix. Note that computation is performed in-place for | ||
| `distance_matrix`. If out-of-place computation is required, pass a copy to | ||
| this function. | ||
| ctypedef fused integral: |
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.
I added fused type directly.
| return distance_matrix | ||
| core_distances[i] = INFINITY | ||
|
|
||
| for col_ind in range(n_samples): |
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.
This is a nogil interaction.
|
I am pretty happy with the current implementation.
A bit later, I will add a file that tests minimally the implementation. Something that I was wondering and seems quite important, it seems that we assume that the distance used is symmetric. Otherwise, the way we build the |
Some additional style change