stefankoegl / kdtree

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

support for different distance measures #16

Closed vincefernando closed 10 years ago

vincefernando commented 10 years ago

It could be useful if other distance measures such the L_1 norm (Manhattan distance), L_inf norm (Chebyshev distance) and the the p-norm (Holder norm, where the entries are raised to the power of p, instead to 2 as in the case of the Eucliden norm) are included. [However, in the p-norm case, extreme values of p can lead to overflow/underflow problems]. A facility to include a user defined norm (or a semi norm) could be also desirable.

stefankoegl commented 10 years ago

Since 29e39c26428c578ed33623a3dd0ec88b889fec49 search_nn and search_knn take an optional dist parameter. An argument for this parameter should be a distance function, taking two points and returning a distance value. The distance can be of any comparable type.

I'll release this change as version 0.10 soon.