Hrm.<br><br>It may be the same reason that find_within_range() would return 4 as well.<br><br>See email in archives, subject "Accuracy of libkdtree", 29 Jan 2009.<br><br>This will need to be confirmed, I'll put it on my list to try and do asap. My theory is that it may only be checking in each dimension individually (a Manhattan distance check), and not doing a final Euclidean distance check. That would be my initial guess. I'm not sure what the logic would be behind that, maybe just speed. Anyway enough guess-work, next step is to confirm.<br>
<br>If anyone wants to step up and figure out what is going on, and to have some input into what should be done about it, be my guest :)<br><br>cheers,<br>Paul<br><br><br><div class="gmail_quote">2009/3/20 Willi Richert <span dir="ltr"><<a href="mailto:w.richert@gmx.net">w.richert@gmx.net</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
alright, I can do that.<br>
<br>
However, I just found out that the range measurement is somehow "illogic":<br>
<div class="im"><br>
def test_count_within_range(self):<br>
nn = KDTree_2Int()<br>
<br>
for p in [(0,0), (1,0), (0,1), (1,1)]:<br>
</div><div class="im"> nn.add((p, id(p)))<br>
<br>
</div><div class="im"> res = nn.count_within_range((0,0), 1.0)<br>
self.assertEqual(3, res, "Counted %i points instead of %i"%(res, 3))<br>
<br>
</div><div class="im"> res = nn.count_within_range((0,0), 1.9)<br>
</div><div class="im"> self.assertEqual(4, res, "Counted %i points instead of %i"%(res, 4))<br>
<br>
<br>
</div>libkdtree_new/python-bindings> python -m unittest py-kdtree_test.KDTree_2IntTestCase.test_count_within_range<br>
F<br>
======================================================================<br>
FAIL: test_count_within_range (py-kdtree_test.KDTree_2IntTestCase)<br>
----------------------------------------------------------------------<br>
Traceback (most recent call last):<br>
File "py-kdtree_test.py", line 110, in test_count_within_range<br>
<div class="im"> self.assertEqual(3, res, "Counted %i points instead of %i"%(res, 3))<br>
</div>AssertionError: Counted 4 points instead of 3<br>
<br>
----------------------------------------------------------------------<br>
Ran 1 test in 0.001s<br>
<br>
<br>
Any suggestion why that is the case? The point (1,1) should not be counted as its distance to (0,0) is sqrt(2)>1.0<br>
<font color="#888888"><br>
wr<br>
</font><div><div></div><div class="h5"><br>
On Freitag 20 März 2009 11:56:16 Paul Harris wrote:<br>
> Hi,<br>
><br>
> 2009/3/20 Willi Richert <<a href="mailto:w.richert@gmx.net">w.richert@gmx.net</a>><br>
><br>
> > One more thing: The current state of having one explicit template<br>
> > realization<br>
> > in the python/swig part annoys me a little bit. Some weeks ago there was<br>
> > a discussion on the ML about whether or not dynamically supporting the<br>
> > specification of the dimension and type. How is the status here, Paul? If<br>
> > you<br>
> > have decided against it, I will provide a python file that generates all<br>
> > the<br>
> > stuff for float, double and int for dim \in [1, .., 20]. That will ease<br>
> > the maintenance a lot. In the other case the situation for the python<br>
> > bindings will be much smoother. But the performance will maybe suffer.<br>
> > Can you shed some light on this decision, Paul?<br>
><br>
> Its still on the list, but I haven't had the time to do anything on kdtree<br>
> for a while now, so i'm just focusing pushing through bug fixes to ensure<br>
> that the results are correct.<br>
><br>
> I would guess it'll be at least a month before I can do anything, unless I<br>
> manage to find a small random window of time where I can attack that issue.<br>
><br>
> Would it be too much to ask if you write the python file that generates all<br>
> the variants, and then we can do the dynamic version later? I don't know<br>
> how much work that would involve, if its not too much then I would prefer<br>
> if you set yourself up with a low-maintenance solution first.<br>
><br>
> cheers,<br>
> Paul<br>
<br>
</div></div></blockquote></div><br>