KristofferC / NearestNeighbors.jl

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

Cannot build KDTree with Subarrays since v0.4.14 #173

Closed davnn closed 8 months ago

davnn commented 8 months ago

Hi, I've been determining whether or not to transform the input arrays to SizedVector based on the data dimensionality, see OutlierDetectionNeighbors.jl.

The resulting input data for NearestNeighbors.jl, therefore, consists of SizedVector sub-arrays. However, due to the new type requirements introduced in commit, this input is no longer valid and therefore breaks our package.

The question now is, should we change the usage, is something wrong with our usage of the package, or should we revert the types back to v0.4.13?

KristofferC commented 8 months ago

Could you give a concrete example of what now fails? I didn't mean to break anything with that commit.

davnn commented 8 months ago

Sure,

import Pkg
Pkg.activate(temp=true)
Pkg.add("NearestNeighbors")

import NearestNeighbors as NN

dynamic_view(X) = [NN.SizedVector{length(v)}(v) for v in eachslice(X; dims = ndims(X))]
data = randn(1000, 1000)
view = dynamic_view(data)
NN.KDTree(view)
ERROR: MethodError: no method matching NearestNeighbors.KDTree(::Vector{StaticArraysCore.SizedVector{1000, Float64, SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}}, ::NearestNeighbors.HyperRectangle{StaticArraysCore.SizedVector{1000, Float64, Vector{Float64}}}, ::Vector{Int64}, ::Distances.Euclidean, ::Vector{NearestNeighbors.KDNode{Float64}}, ::NearestNeighbors.TreeData, ::Bool)
davnn commented 8 months ago

thx 🚀