Skip to content

accept non-float z #41

Closed
Closed
@tpapp

Description

@tpapp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions