stefankoegl / kdtree

A Python implementation of a kd-tree
ISC License
371 stars 118 forks source link

Help: TypeError: unsupported operand type(s) for -: 'str' and 'float' #42

Closed lixingang closed 6 years ago

lixingang commented 6 years ago

I try to save about 4,700,000 points into the 'kdtree' and call search_nn_dist() but have such error :

Traceback (most recent call last): File "dataloader.py", line 226, in <module> createKdtree('/usr/data/lhw/lixg/eccv/xyz_irgb_label_cleared012.txt') File "dataloader.py", line 206, in createKdtree print(tree.search_nn_dist(p1,1)) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 197, in _wrapper return f(self, *args, **kwargs) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 529, in search_nn_dist self._search_nn_dist(point, distance, results, get_dist) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 499, in _search_nn_dist nodeDist = get_dist(self) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 527, in <lambda> get_dist = lambda n: n.dist(point) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 396, in dist return sum([self.axis_dist(point, i) for i in r]) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 396, in <listcomp> return sum([self.axis_dist(point, i) for i in r]) File "/usr/lhw/anaconda3/lib/python3.5/site-packages/kdtree.py", line 387, in axis_dist return math.pow(self.data[axis] - point[axis], 2) TypeError: unsupported operand type(s) for -: 'str' and 'float'

I am not sure whether the size of my data cause this error, THANKS!