[Scipy-tickets] [SciPy] #1373: Bug in KDTree.query_ball_point

SciPy Trac scipy-tickets@scipy....
Fri Feb 4 17:23:18 CST 2011


#1373: Bug in KDTree.query_ball_point
---------------------------+------------------------------------------------
 Reporter:  schmidtc       |       Owner:  peridot
     Type:  defect         |      Status:  new    
 Priority:  normal         |   Milestone:  0.9.0  
Component:  scipy.spatial  |     Version:  0.8.0  
 Keywords:                 |  
---------------------------+------------------------------------------------
Changes (by warren.weckesser):

  * owner:  wnbell => peridot
  * component:  scipy.sparse => scipy.spatial


Old description:

> There appears to be a bug in KDTree.query_ball_point, when using integer
> points neighbor points that lie on the radius are not always returned.
>
> Eg, with a 4x4 grid
> >>> import scipy.spatial
> >>> points = [(0, 0), (0, 1), (0, 2), (0, 3), \
> ...              (1, 0), (1, 1), (1, 2), (1, 3), \
> ...              (2, 0), (2, 1), (2, 2), (2, 3), \
> ...              (3, 0), (3, 1), (3, 2), (3, 3)]
> >>> kd=scipy.spatial.KDTree(points)
> >>> kd.query_ball_point((2,0),1)
> [8, 9, 12]
>

> >>> points = [(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (0.0, 3.0), \
> ...              (1.0, 0.0), (1.0, 1.0), (1.0, 2.0), (1.0, 3.0), \
> ...              (2.0, 0.0), (2.0, 1.0), (2.0, 2.0), (2.0, 3.0), \
> ...              (3.0, 0.0), (3.0, 1.0), (3.0, 2.0), (3.0, 3.0)]
>
> >>> kd=scipy.spatial.KDTree(points)
> >>> kd.query_ball_point((2,0),1)
> [4, 8, 9, 12]

New description:

 There appears to be a bug in KDTree.query_ball_point, when using integer
 points neighbor points that lie on the radius are not always returned.

 Eg, with a 4x4 grid
 {{{
 >>> import scipy.spatial
 >>> points = [(0, 0), (0, 1), (0, 2), (0, 3), \
 ...              (1, 0), (1, 1), (1, 2), (1, 3), \
 ...              (2, 0), (2, 1), (2, 2), (2, 3), \
 ...              (3, 0), (3, 1), (3, 2), (3, 3)]
 >>> kd=scipy.spatial.KDTree(points)
 >>> kd.query_ball_point((2,0),1)
 [8, 9, 12]


 >>> points = [(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (0.0, 3.0), \
 ...              (1.0, 0.0), (1.0, 1.0), (1.0, 2.0), (1.0, 3.0), \
 ...              (2.0, 0.0), (2.0, 1.0), (2.0, 2.0), (2.0, 3.0), \
 ...              (3.0, 0.0), (3.0, 1.0), (3.0, 2.0), (3.0, 3.0)]

 >>> kd=scipy.spatial.KDTree(points)
 >>> kd.query_ball_point((2,0),1)
 [4, 8, 9, 12]
 }}}

--

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1373#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list