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 &quot;Accuracy of libkdtree&quot;, 29 Jan 2009.<br><br>This will need to be confirmed, I&#39;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&#39;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">&lt;<a href="mailto:w.richert@gmx.net">w.richert@gmx.net</a>&gt;</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 &quot;illogic&quot;:<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, &quot;Counted %i points instead of %i&quot;%(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, &quot;Counted %i points instead of %i&quot;%(res, 4))<br>
<br>
<br>
</div>libkdtree_new/python-bindings&gt; 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 &quot;py-kdtree_test.py&quot;, line 110, in test_count_within_range<br>
<div class="im">    self.assertEqual(3, res, &quot;Counted %i points instead of %i&quot;%(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)&gt;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>
&gt; Hi,<br>
&gt;<br>
&gt; 2009/3/20 Willi Richert &lt;<a href="mailto:w.richert@gmx.net">w.richert@gmx.net</a>&gt;<br>
&gt;<br>
&gt; &gt; One more thing: The current state of having one explicit template<br>
&gt; &gt; realization<br>
&gt; &gt; in the python/swig part annoys me a little bit. Some weeks ago there was<br>
&gt; &gt; a discussion on the ML about whether or not dynamically supporting the<br>
&gt; &gt; specification of the dimension and type. How is the status here, Paul? If<br>
&gt; &gt; you<br>
&gt; &gt; have decided against it, I will provide a python file that generates all<br>
&gt; &gt; the<br>
&gt; &gt; stuff for float, double and int for dim \in [1, .., 20]. That will ease<br>
&gt; &gt; the maintenance a lot.  In the other case the situation for the python<br>
&gt; &gt; bindings will be much smoother. But the performance will maybe suffer.<br>
&gt; &gt; Can you shed some light on this decision, Paul?<br>
&gt;<br>
&gt; Its still on the list, but I haven&#39;t had the time to do anything on kdtree<br>
&gt; for a while now, so i&#39;m just focusing pushing through bug fixes to ensure<br>
&gt; that the results are correct.<br>
&gt;<br>
&gt; I would guess it&#39;ll be at least a month before I can do anything, unless I<br>
&gt; manage to find a small random window of time where I can attack that issue.<br>
&gt;<br>
&gt; Would it be too much to ask if you write the python file that generates all<br>
&gt; the variants, and then we can do the dynamic version later?  I don&#39;t know<br>
&gt; how much work that would involve, if its not too much then I would prefer<br>
&gt; if you set yourself up with a low-maintenance solution first.<br>
&gt;<br>
&gt; cheers,<br>
&gt; Paul<br>
<br>
</div></div></blockquote></div><br>