File tree Expand file tree Collapse file tree 2 files changed +6
-18
lines changed
sklearn/metrics/_pairwise_distances_reduction Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -509,15 +509,9 @@ cdef class EuclideanArgKmin{{name_suffix}}(ArgKmin{{name_suffix}}):
509509 self.Y_norm_squared[j + Y_start]
510510 )
511511
512- sqeuclidean_dist_i_j = (
513- sqeuclidean_dist_i_j
514- # Catastrophic cancellation causing -0. and NaN can be present
515- # in some situations, e.g. when computing d(x_i, y_i) when X is Y.
516- #
517- # Guard against -0. Guard against NaN
518- # v v
519- if 0. < sqeuclidean_dist_i_j == sqeuclidean_dist_i_j else 0.
520- )
512+ # Catastrophic cancellation might cause -0. to be present,
513+ # e.g. when computing d(x_i, y_i) when X is Y.
514+ sqeuclidean_dist_i_j = max(0., sqeuclidean_dist_i_j)
521515
522516 heap_push(
523517 values=heaps_r_distances + i * self.k,
Original file line number Diff line number Diff line change @@ -513,15 +513,9 @@ cdef class EuclideanRadiusNeighbors{{name_suffix}}(RadiusNeighbors{{name_suffix}
513513 + self.Y_norm_squared[j]
514514 )
515515
516- sqeuclidean_dist_i_j = (
517- sqeuclidean_dist_i_j
518- # Catastrophic cancellation causing -0. and NaN can be present
519- # in some situations, e.g. when computing d(x_i, y_i) when X is Y.
520- #
521- # Guard against -0. Guard against NaN
522- # v v
523- if 0. < sqeuclidean_dist_i_j == sqeuclidean_dist_i_j else 0.
524- )
516+ # Catastrophic cancellation might cause -0. to be present,
517+ # e.g. when computing d(x_i, y_i) when X is Y.
518+ sqeuclidean_dist_i_j = max(0., sqeuclidean_dist_i_j)
525519
526520 if sqeuclidean_dist_i_j <= self.r_radius:
527521 deref(self.neigh_distances_chunks[thread_num])[i].push_back(sqeuclidean_dist_i_j)
You can’t perform that action at this time.
0 commit comments