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

No method matching isfinite for nullable Int64 #1083

Closed
alexomics opened this issue Jan 2, 2018 · 8 comments
Closed

No method matching isfinite for nullable Int64 #1083

alexomics opened this issue Jan 2, 2018 · 8 comments

Comments

@alexomics
Copy link

julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-2415M CPU @ 2.30GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)

julia> Pkg.status("Gadfly")
 - Gadfly                        0.6.4

julia> head(s)
6×2 DataFrames.DataFrame
│ Row │ foo │ bar     │
├─────┼─────┼─────────┤
│ 1   │ 521 │ 40.0    │
│ 2   │ 521 │ 40.0003 │
│ 3   │ 542 │ 40.0005 │
│ 4   │ 540 │ 40.0007 │
│ 5   │ 566 │ 40.001  │
│ 6   │ 664 │ 40.0012 │

julia> plot(s, x="bar", y="foo", Geom.line)
Error showing value of type Gadfly.Plot:
ERROR: MethodError: no method matching isfinite(::Nullable{Int64})
Closest candidates are:
  isfinite(::Float16) at float.jl:539
  isfinite(::BigFloat) at mpfr.jl:831
  isfinite(::DataArrays.NAtype) at /Users/Alex/.julia/v0.6/DataArrays/src/predicates.jl:10
  ...
Stacktrace:
 [1] apply_statistic_typed(::Nullable{Int64}, ::Nullable{Int64}, ::Array{Nullable{Int64},1}, ::Array{Void,1}, ::Array{Void,1}) at /Users/Alex/.julia/v0.6/Gadfly/src/statistics.jl:909
 [2] apply_statistic(::Gadfly.Stat.TickStatistic, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /Users/Alex/.julia/v0.6/Gadfly/src/statistics.jl:772
 [3] apply_statistics(::Array{Gadfly.StatisticElement,1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /Users/Alex/.julia/v0.6/Gadfly/src/statistics.jl:40
 [4] render_prepare(::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:695
 [5] render(::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:748
 [6] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/html")}, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:1062
 [7] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:1007
 [8] display(::Gadfly.Plot) at ./multimedia.jl:218
 [9] hookless(::Media.##7#8{Gadfly.Plot}) at /Users/Alex/.julia/v0.6/Media/src/compat.jl:14
 [10] render(::Media.NoDisplay, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Media/src/compat.jl:27
 [11] display(::Media.DisplayHook, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Media/src/compat.jl:9
 [12] display(::Gadfly.Plot) at ./multimedia.jl:218
 [13] eval(::Module, ::Any) at ./boot.jl:235
 [14] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [15] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [16] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646
@alexomics
Copy link
Author

Related to #909 ?

@Mattriks
Copy link
Member

Mattriks commented Jan 2, 2018

Note that Gadfly has not supported the use of DataFrames with missing values (NA) for a while (#538, #567). Gadfly will produce an error on Julia v0.5 and v0.6 with the following example :

y = DataArray(randn(10))
y[5] = NA
D = DataFrame(x=[1:10;], y=y)
p = plot(D, x=:x, y=:y, Geom.line)

Does your DataFrame contain missing values, and can you provide a minimum example which produces the same error as you encountered.

@alexomics
Copy link
Author

The DataFrame doesn't contain any missing values. I think the issue is stemming from using CSV. Manually creating small DataFrames doesn't produce the problem.

    julia> using CSV
    WARNING: Method definition ==(Base.Nullable{S}, Base.Nullable{T}) in module Base at nullable.jl:238 overwritten in module NullableArrays at /Users/Alex/.julia/v0.6/NullableArrays/src/operators.jl:99.
    
    julia> using DataFrames, Gadfly
    
    julia> poc = CSV.read("poc.csv");
    
    julia> poc
    6×2 DataFrames.DataFrame
    │ Row │ foo │ bar     │
    ├─────┼─────┼─────────┤
    │ 1   │ 521 │ 40.0    │
    │ 2   │ 521 │ 40.0003 │
    │ 3   │ 542 │ 40.0005 │
    │ 4   │ 540 │ 40.0007 │
    │ 5   │ 566 │ 40.001  │
    │ 6   │ 664 │ 40.0012 │
    
    julia> poc[:bar]
    6-element NullableArrays.NullableArray{Float64,1}:
     40.0
     40.0003
     40.0005
     40.0007
     40.001
     40.0012
    
    julia> poc[:foo]
    6-element NullableArrays.NullableArray{Int64,1}:
     521
     521
     542
     540
     566
     664
    
    julia> plot(poc, x=:bar, y=:foo, Geom.line)
    Error showing value of type Gadfly.Plot:
    ERROR: MethodError: no method matching isfinite(::Nullable{Float64})
    Closest candidates are:
      isfinite(::Float16) at float.jl:539
      isfinite(::BigFloat) at mpfr.jl:831
      isfinite(::DataArrays.NAtype) at /Users/Alex/.julia/v0.6/DataArrays/src/predicates.jl:10
      ...
    Stacktrace:
     [1] apply_statistic_typed(::Nullable{Float64}, ::Nullable{Float64}, ::Array{Nullable{Float64},1}, ::Array{Void,1}, ::Array{Void,1}) at /Users/Alex/.julia/v0.6/Gadfly/src/statistics.jl:909
     [2] apply_statistic(::Gadfly.Stat.TickStatistic, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /Users/Alex/.julia/v0.6/Gadfly/src/statistics.jl:772
     [3] apply_statistics(::Array{Gadfly.StatisticElement,1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /Users/Alex/.julia/v0.6/Gadfly/src/statistics.jl:40
     [4] render_prepare(::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:695
     [5] render(::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:748
     [6] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/html")}, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:1062
     [7] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Gadfly/src/Gadfly.jl:1007
     [8] display(::Gadfly.Plot) at ./multimedia.jl:218
     [9] hookless(::Media.##7#8{Gadfly.Plot}) at /Users/Alex/.julia/v0.6/Media/src/compat.jl:14
     [10] render(::Media.NoDisplay, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Media/src/compat.jl:27
     [11] display(::Media.DisplayHook, ::Gadfly.Plot) at /Users/Alex/.julia/v0.6/Media/src/compat.jl:9
     [12] display(::Gadfly.Plot) at ./multimedia.jl:218
     [13] eval(::Module, ::Any) at ./boot.jl:235
     [14] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
     [15] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
     [16] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

@Mattriks
Copy link
Member

Mattriks commented Jan 3, 2018

This works for me:

D = CSV.read("poc.csv", nullable=false)
p = plot(D, x=:bar, y=:foo, Geom.line)

See CSV documentation

@aterenin
Copy link

aterenin commented Jan 6, 2018

Confirmed same issue. There are no missing values in my data frame. Adding nullable=false fixes the error.

@tlnagy
Copy link
Member

tlnagy commented Jan 6, 2018

Will the new missing code in Base help these problems?

@Mattriks
Copy link
Member

Since Julia 1.0 has a stable implementation of missing values, it would be worth supporting missing values in Gadfly now. This example already works:

D = DataFrame(x=1:10, y=randn(10))
allowmissing!(D)
D.y[5] = missing

p = plot(D, x=:x, y=:y, Geom.line)
draw(PNG(3.3inch,3.3inch), p)

iss1083a

But if you add Geom.point to the above code, it errors.

@Mattriks
Copy link
Member

Closing this is in favor of #1267

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

4 participants