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

Is it possible to use integers instead of floats? #13

Open
tlnagy opened this issue Dec 21, 2015 · 1 comment
Open

Is it possible to use integers instead of floats? #13

tlnagy opened this issue Dec 21, 2015 · 1 comment

Comments

@tlnagy
Copy link
Contributor

tlnagy commented Dec 21, 2015

I would like to use NearestNeighbors.jl to find the nearest string in Hamming distance from a given input string. Do I have to convert them to floats to use the NearestNeighbors library? I would prefer to avoid this because of precision issues and memory use. For example, I can't use ints with BallTree:

data = rand(1:4, (10, 10^4))
balltree = BallTree(data, Hamming())

gives the following error:

LoadError: MethodError: `convert` has no method matching convert(::Type{NearestNeighbors.BallTree{T<:AbstractFloat,M<:Distances.Metric}}, ::Array{Int64,2}, ::Distances.Hamming)
This may have arisen from a call to the constructor NearestNeighbors.BallTree{T<:AbstractFloat,M<:Distances.Metric}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  NearestNeighbors.BallTree{T<:AbstractFloat,M<:Distances.Metric}(!Matched::Array{T<:AbstractFloat,2}, ::M<:Distances.Metric)
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, !Matched::T)
  ...
while loading In[53], in expression starting on line 2

 in call at essentials.jl:57

Is there a specific reason that AbstractFloat is the parent type? Distances.jl can handle other types just fine:

evaluate(Hamming(), ["A","B","C"], ["A","B","D"])

I'm using Julia v0.4.1 and the masters of both NearestNeighbors and Distances

@KristofferC
Copy link
Owner

This should be possible, might just need to relax some of the parameters. I will look into it.

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

Successfully merging a pull request may close this issue.

2 participants