Skip to content

Commit

Permalink
fixed the distance condition for range queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Luca van den Busch committed Jan 29, 2024
1 parent dc34ba8 commit 29f5769
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ballnode_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static double ptslc_sumw_in_range_sq(
for (const Point *point = slice->start; point < slice->end; ++point) {
double dist_sq = EUCLIDEAN_DIST_SQ(ref_point, point);
// add point weight if condition is met otherwise zero
int dist_mask = rmin_sq < dist_sq || dist_sq <= rmax_sq;
int dist_mask = rmin_sq < dist_sq && dist_sq <= rmax_sq;
sumw += point->weight * (double)dist_mask;
}
return sumw;
Expand All @@ -57,7 +57,7 @@ static double ptslc_dualsumw_in_radius_sq(

static double ptslc_dualsumw_in_range_sq(
const PointSlice *slice1,
const PointSlice *slice2,
const PointSlice *slice2,
double rmin_sq,
double rmax_sq
) {
Expand All @@ -80,7 +80,7 @@ double bnode_count_radius(
if (distance <= radius - node_radius) {
return point->weight * node->sum_weight;
}

// case: some points may be pairs
else if (distance <= radius + node_radius) {
if (BALLNODE_IS_LEAF(node) == false) {
Expand Down
2 changes: 0 additions & 2 deletions tests/test_balltree.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ def test_count_radius_multi(self, radius, rand_data_weight):
count += brute_force((data, weight), (p, w), radius)
npt.assert_almost_equal(tree.count_radius(data, radius, weight), count)

@pytest.mark.xfail
@pytest.mark.parametrize("rmin,rmax", rminmax_testvalues)
def test_count_range_single(self, rmin, rmax, rand_data_weight):
data, weight = rand_data_weight
Expand All @@ -275,7 +274,6 @@ def test_dualcount_radius(self, radius, rand_data_weight):
count += brute_force((data, weight), (p, w), radius)
npt.assert_almost_equal(tree.dualcount_radius(tree, radius), count)

@pytest.mark.xfail
@pytest.mark.parametrize("rmin,rmax", rminmax_testvalues)
def test_dualcount_range(self, rmin, rmax, rand_data_weight):
data, weight = rand_data_weight
Expand Down

0 comments on commit 29f5769

Please sign in to comment.