-
-
Notifications
You must be signed in to change notification settings - Fork 26k
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.DistanceMetric
sconst
memory views for cluster.DistanceMetric
s
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 <olivier.grisel@gmail.com>
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 <olivier.grisel@ensta.org>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Fix finting, again.
I was inspecting if changes made to |
const
memory views for cluster.DistanceMetric
sconst
memory views for neighbors.DistanceMetric
subclasses
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 <thomasjpfan@gmail.com>
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 <olivier.grisel@ensta.org> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
Fixes #19875.
See also #10624.
What does this implement/fix? Explain your changes.
Distances computations (
cluster.DistanceMetric
s) 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
const
memoryviews 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.