-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
MNT Use const memory views in DistanceMetric subclasses #19883
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
MNT Use const memory views in DistanceMetric subclasses #19883
Conversation
|
Const fused types has not been released yet. But in this case, |
const with fused types memory views for cluster.DistanceMetricsconst memory views for cluster.DistanceMetrics
ogrisel
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.
+1 for fixing #19875 explicitly as part of this PR with a dedicated non-regression test + an entry in the changelog.
Since the DistanceMetric class is part of the documented public API, we should also mention the fix for this class in the changelog.
Co-authored-by: Olivier Grisel <[email protected]>
ogrisel
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.
Some minor comments but otherwise LGTM. Is this PR style a DRAFT? Do you plan other changes? I think it's already a net improvement.
Co-authored-by: Olivier Grisel <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Fix finting, again.
I was inspecting if changes made to |
const memory views for cluster.DistanceMetricsconst memory views for neighbors.DistanceMetric subclasses
thomasjpfan
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.
Thank you for the PR @jjerphan !
Co-authored-by: Thomas J. Fan <[email protected]>
thomasjpfan
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.
LGTM
const memory views for neighbors.DistanceMetric subclasses…#19883) Co-authored-by: Olivier Grisel <[email protected]> Co-authored-by: Thomas J. Fan <[email protected]>
Reference Issues/PRs
Fixes #19875.
See also #10624.
What does this implement/fix? Explain your changes.
Distances computations (
cluster.DistanceMetrics) implemented in Cython do not support readonly datasets, which are obtained when using mem-mapping for instance. This makes some interfaces relying on those implementation fail (see #19875).This PR makes the Cython implementations use
constmemoryviews to be able computing those distances on memmapped datasets.Any other comments?
5b61a29 fixes #19875, but maybe we should have the downstream issues be solved independently from this PR.
Also
scipy.spatial.distance.{cdist,pdist}on memmapped datasets with'mahalanobis'as a metric fail.I am inspecting why; in the meantime 716b330 skips the associated tests.