[SciPy-user] Error in scipy.spatial.cKDTree

Anne Archibald peridot.faceted@gmail....
Sat Feb 21 22:07:41 CST 2009


2009/2/21 Rob Hetland <hetland@tamu.edu>:
>
> I am getting a strange error in scipy.spatial.cKDtree:

Oops! Fixed in SVN r5585.

The error happens when the query array is not "contiguous"; the
easiest way to trigger it is to do a query with a transposed array;
the query coordinates will be scrambled. As a workaround, just apply
np.ascontiguousarray() to any query.

Anne

> # make a sample array.
> fill_value = 0.5
> x = np.random.rand(25, 50)
> x = x.clip(min=fill_value, max=inf)
>
> # Create (i, j) point arrays for good and bad data.
> # Bad data is marked by the fill_value, good data elsewhere.
> igood = np.vstack(np.where(x!=fill_value)).astype('d').T
> ibad = np.vstack(np.where(x==fill_value)).astype('d').T
>
> # create a tree for the bad points, the points to be filled
> tree = scipy.spatial.cKDTree(ibad)
>
> # get the four closest points to the bad points
> dist, iquery = tree.query(igood, k=4, p=2)
>
> np.any(dist == 0)
>
>
>
>
> I get True for the last command, which should not be.  Other
> implementations of kdtree that I have, including regular KDTree.  I'm
> not good enough at C to track the code down.
>
> -Rob
>
>
>
> ----
> Rob Hetland, Associate Professor
> Dept. of Oceanography, Texas A&M University
> http://pong.tamu.edu/~rob
> phone: 979-458-0096, fax: 979-845-6331
>
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-user mailing list