Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using KDtree as a type? #32

Closed
lobingera opened this issue Sep 7, 2016 · 4 comments
Closed

using KDtree as a type? #32

lobingera opened this issue Sep 7, 2016 · 4 comments

Comments

@lobingera
Copy link

I've just seen the error the first time, i used (some time ago...) KDTree in a type definition

type pgraph
    x_screen::Array{Float64,1}
    y_screen::Array{Float64,1}
    x_last::Real
    y_last::Real
    kdtree::NearestNeighbors.KDTree{Float64,Distances.Euclidean}
end

which is later on instantiated with

p1 = pgraph(x,y,0.0,0.0,KDTree(zeros(2,2));

and p1.kdtree then given a value when applicable.

How to do that now?

@lobingera
Copy link
Author

Don't mind, i'm using ::Any right now.

@KristofferC
Copy link
Owner

KristofferC commented Sep 8, 2016

You could have

type pgraph{T <: KDTree}
    kdtree::T
end

@lobingera
Copy link
Author

This was just an example, pgraph is actually a little bit longer than this and i might reserve the "top-level type argument" (don't know how {T <: X} is called...) for data, not the KDTree representation. The initial example worked for some time...

@KristofferC
Copy link
Owner

Yes, The new version (#29) changes the way the KDTree is parameterized. It is now a sufficiently complex type that I would recommand just adding an extra parameter that is T <: KDTree to your type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants