KristofferC / NearestNeighbors.jl

High performance nearest neighbor data structures (KDTree and BallTree) and algorithms for Julia.
Other
413 stars 65 forks source link

Fix tree construction for vectors without `StaticArrays.setindex` #172

Closed fredrikekre closed 9 months ago

fredrikekre commented 9 months ago

In #166 the HyperRectangle struct was changed to use the same vector type as the input data for the mins and maxes, and to use StaticArrays.setindex for "mutation". Since this function is not implemented for all working input types (for example Tensors.Vec) there was an MethodError thrown. This patch adds NearestNeighbors.setindex which dispatches to StaticArrays.setindex for <: StaticArray.StaticArray and for other types casts to SVector and then back to the original type after mutating.

KristofferC commented 9 months ago

Thanks, I thought about just making the HyperRectangle contain SVectors but then I would have to add another parameter to the tree type which felt bad.