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

accept non-float z #41

Closed
tpapp opened this issue Jan 11, 2018 · 0 comments
Closed

accept non-float z #41

tpapp opened this issue Jan 11, 2018 · 0 comments

Comments

@tpapp
Copy link
Contributor

tpapp commented Jan 11, 2018

contours does not accept a z of Ints. A use case is count data:

using Contour
using StatsBase

N = 10000
x = randn(N)
y = randn(N)
H = fit(Histogram, (x, y), closed = :left)
contours(midpoints.(H.edges)..., H.weights)           # fails
contours(midpoints.(H.edges)..., Float64.(H.weights)) # works

The error message for the failing one is

julia> contours(midpoints.(H.edges)..., H.weights)
ERROR: MethodError: no method matching interpolate(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Int64,2}, ::Float64, ::Int64, ::Int64, ::UInt8)
Closest candidates are:
  interpolate(::Any, ::Any, ::Array{T<:AbstractFloat,2}, ::Number, ::Int64, ::Int64, ::UInt8) where T<:AbstractFloat at /home/tamas/.julia/v0.6/Contour/src/Contour.jl:232
Stacktrace:
 [1] trace_contour(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Int64,2}, ::Float64, ::Dict{Tuple{Int64,Int64},Contour.Cell}) at /home/tamas/.julia/v0.6/Contour/src/Contour.jl:328
 [2] collect(::Base.Generator{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Contour.##1#2{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Int64,2}}}) at ./array.jl:475
 [3] contours at /home/tamas/.julia/v0.6/Contour/src/Contour.jl:81 [inlined]
 [4] contours at /home/tamas/.julia/v0.6/Contour/src/Contour.jl:88 [inlined]
 [5] contours(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Int64,2}) at /home/tamas/.julia/v0.6/Contour/src/Contour.jl:94
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

1 participant