Skip to content

Commit 403280c

Browse files
Fix more unit errors (#239)
1 parent 751e2a4 commit 403280c

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/kd_tree.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function knn_kernel!(tree::KDTree{V},
195195
left_idx = getleft(index)
196196
right_idx = getright(index)
197197
# Point is to the right of the split value
198-
if split_diff > 0
198+
if split_diff > zero(split_diff)
199199
close = right_idx
200200
far = left_idx
201201
hyper_rec_far = left_region
@@ -274,7 +274,7 @@ function inrange_kernel!(
274274
left_region, right_region = split_hyperrectangle(hyper_rec, split_dim, split_val)
275275
left_idx = getleft(index)
276276
right_idx = getright(index)
277-
if split_diff > 0 # Point is to the right of the split value
277+
if split_diff > zero(split_diff) # Point is to the right of the split value
278278
close = right_idx
279279
far = left_idx
280280
hyper_rec_far = left_region
@@ -288,7 +288,7 @@ function inrange_kernel!(
288288
# Compute contributions for both close and far subtrees
289289
M = tree.metric
290290
old_contrib = max_dist_contribs[split_dim]
291-
if split_diff > 0
291+
if split_diff > zero(split_diff)
292292
# Point is to the right
293293
# Close subtree: split_val as new min, far subtree: split_val as new max
294294
new_contrib_close = get_max_distance_contribution_single(M, point[split_dim], split_val, hyper_rec.maxes[split_dim], split_dim)

test/test_unitful.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ using Unitful
1313

1414
# Data with units
1515
m = u"m"
16-
data_unitful = [SVector(1.0m, 2.0m, 3.0m), SVector(2.0m, 3.0m, 4.0m), SVector(10.0m, 10.0m, 10.0m)]
16+
data_unitful = mapreduce(vcat, range(0.0m, 0.5m; length = 20)) do d
17+
[SVector(d, d, d) + v
18+
for v in [SVector(1.0m, 2.0m, 3.0m), SVector(2.0m, 3.0m, 4.0m), SVector(10.0m, 10.0m, 10.0m)]]
19+
end
1720
query_unitful = [1.0m, 2.0m, 3.0m]
1821
bounds_min_unitful = [0.0m, 0.0m, 0.0m]
1922
bounds_max_unitful = [20.0m, 20.0m, 20.0m]

0 commit comments

Comments
 (0)