[SciPy-User] Fwd: KDTree IndexError

Oleksandr Huziy guziy.sasha@gmail....
Fri Jul 20 17:19:10 CDT 2012


Hi,

the kdtree implementation uses recursion, and the standard limit of the
recursion depth in python is 1000.

For some of your data you need more than 1000 (for the bad data).

When I put

import sys

sys.setrecursionlimit(10000)

your bad data script works OK. Probably it would work with less...

Cheers
--
Oleksandr

2012/7/20 <DParker@chromalloy.com>

> Here it is. https://bitbucket.org/parkerdg/kdtree-failure
>
> Thank you for your help!
>
> *David G. Parker
> *
>
>
> From:        Oleksandr Huziy <guziy.sasha@gmail.com>
> To:        DParker@chromalloy.com
> Date:        07/20/2012 04:07 PM
> Subject:        Fwd: [SciPy-User] KDTree IndexError
> ------------------------------
>
>
>
> Hi,
>
> I have not received the files. Maybe it's best to upload them somewhere?
>
> Cheers
> --
> Oleksandr
>
> ---------- Forwarded message ----------
> From: <*DParker@chromalloy.com* <DParker@chromalloy.com>>
> Date: 2012/7/20
> Subject: Re: [SciPy-User] KDTree IndexError
> To: SciPy Users List <*scipy-user@scipy.org* <scipy-user@scipy.org>>
>
>
> Yes but the mailing list bounced back the email with the data attached due
> to size so I've emailed the file directly to you.
>
> I have two examples - one that works and one that causes a failure.
>
> Some info on the data:
>         Good                Bad
>         Min        Max        Min        Max
> X        -0.0551        0.0569        0.0610        0.0911
> Y        -0.0540        0.0350        -0.0586        0.0185
> Z        1.0589        1.0702        0.9121        1.0624
>
> I'll add that in the original script where I first encountered the KDTree
> failure there was some pre-processing of the data before building the
> KDTree: converting units, sorting the coordinates. I've recently eliminated
> all of the pre-processing and I still encountered the same failure.
> *
> David G. Parker*
>
>
>
> From:        Oleksandr Huziy <*guziy.sasha@gmail.com*<guziy.sasha@gmail.com>
> >
> To:        SciPy Users List <*scipy-user@scipy.org* <scipy-user@scipy.org>
> >
> Date:        07/20/2012 01:02 PM
> Subject:        Re: [SciPy-User] KDTree IndexError
> Sent by:        *scipy-user-bounces@scipy.org*<scipy-user-bounces@scipy.org>
>  ------------------------------
>
>
>
>
> Hi,
>
> is it possible to have x2,y2,z2 to test it?
>
> Thanks
> --
> Oleksandr Huziy
>
> 2012/7/20 <*DParker@chromalloy.com* <DParker@chromalloy.com>>
> I'm using scipy.spatial.KDTree (version 0.10.1) to perform nearest
> neighbor interpolation. Recently I've encountered an error when defining a
> KDTree from certain sets of data. I have not been able to determine what is
> unique about these data sets and the traceback doesn't provide much of a
> clue to me. I was hoping someone might be familiar with the problem and
> provide some insight into what is causing the failure, what to look for in
> my data set, and how to avoid the failure.
>
> The code which generates the traceback is:
> tree = KDTree(zip(x2,y2,z2))
>
> where x2, y2, and z2 are numpy arrays dtype float64. For one particular
> data set which fails these have a length of 157,237, shape is (157237,).
>
>
> As I said above I don't know what is unusual about the data that causes
> the failure to occur. The traceback is copied below:
>
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
>   File "<input>", line 75, in interactivemode
>   File "C:\Python26\lib\site-packages\fluenttools\profile.py", line 740,
> in commonnodes
>     tree = KDTree(zip(x2,y2,z2))
>   File "C:\Python26\lib\site-packages\scipy\spatial\kdtree.py", line 174,
> in __init__
>     self.tree = self.__build(np.arange(self.n), self.maxes, self.mins)
>   File "C:\Python26\lib\site-packages\scipy\spatial\kdtree.py", line 238,
> in __build
>     self.__build(idx[less_idx],lessmaxes,mins),
>
> {Prior two lines repeated 974 times}
>
>   File "C:\Python26\lib\site-packages\scipy\spatial\kdtree.py", line 201,
> in __build
>     data = self.data[idx]
> IndexError: index must be either an int or a sequence
>
> David G. Parker
> _______________________________________________
> SciPy-User mailing list*
> **SciPy-User@scipy.org* <SciPy-User@scipy.org>*
> **http://mail.scipy.org/mailman/listinfo/scipy-user*<http://mail.scipy.org/mailman/listinfo/scipy-user>
>
> _______________________________________________
> SciPy-User mailing list*
> **SciPy-User@scipy.org* <SciPy-User@scipy.org>*
> **http://mail.scipy.org/mailman/listinfo/scipy-user*<http://mail.scipy.org/mailman/listinfo/scipy-user>
>
>
> _______________________________________________
> SciPy-User mailing list*
> **SciPy-User@scipy.org* <SciPy-User@scipy.org>*
> **http://mail.scipy.org/mailman/listinfo/scipy-user*<http://mail.scipy.org/mailman/listinfo/scipy-user>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120720/a361154e/attachment-0001.html 


More information about the SciPy-User mailing list