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

Intermittent error when plotting chains. #127

Open
itsdfish opened this issue Oct 6, 2017 · 8 comments
Open

Intermittent error when plotting chains. #127

itsdfish opened this issue Oct 6, 2017 · 8 comments

Comments

@itsdfish
Copy link

itsdfish commented Oct 6, 2017

Hi-

I've been using the mamba plotting functions with Stan.jl. Sometimes I receive the following error when I plot my chains using the plot() function:

MethodError: no method matching isless(::Float64, ::Void)
Closest candidates are:
  isless(::Float64, !Matched::Float64) at float.jl:439
  isless(!Matched::DataArrays.NAtype, ::Any) at /Users/christopher.fisher/.julia/v0.6/DataArrays/src/operators.jl:383
  isless(::AbstractFloat, !Matched::AbstractFloat) at operators.jl:96
  ...
max(::Void, ::Float64) at operators.jl:348
apply_coordinate(::Gadfly.Coord.Cartesian, ::Array{Gadfly.Aesthetics,1}, ::Dict{Symbol,Gadfly.ScaleElement}) at coord.jl:215
#render_prepared#115(::Bool, ::Bool, ::Function, ::Gadfly.Plot, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics, ::Array{Gadfly.Aesthetics,1}, ::Array{Array{Gadfly.StatisticElement,1},1}, ::Array{Array{Gadfly.Aesthetics,1},1}, ::Array{Array{Gadfly.Data,1},1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Array{Gadfly.GuideElement,1}) at Gadfly.jl:806
render_prepared(::Gadfly.Plot, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics, ::Array{Gadfly.Aesthetics,1}, ::Array{Array{Gadfly.StatisticElement,1},1}, ::Array{Array{Gadfly.Aesthetics,1},1}, ::Array{Array{Gadfly.Data,1},1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Array{Gadfly.GuideElement,1}) at Gadfly.jl:806
render(::Gadfly.Plot) at Gadfly.jl:752
#draw#171(::Symbol, ::String, ::Measures.Length{:mm,Float64}, ::Measures.Length{:mm,Float64}, ::Int64, ::Int64, ::Bool, ::Bool, ::Compose.#draw, ::Array{Gadfly.Plot,2}) at plot.jl:45
(::Compose.#kw##draw)(::Array{Any,1}, ::Compose.#draw, ::Array{Gadfly.Plot,2}) at <missing>:0
include_string(::String, ::String) at sys.dylib:?
include_string(::String, ::String, ::Int64) at eval.jl:30
include_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N} where N) at eval.jl:34
(::Atom.##49#53{String,Int64,String})() at eval.jl:50
withpath(::Atom.##49#53{String,Int64,String}, ::String) at utils.jl:30
withpath(::Function, ::String) at eval.jl:38
macro expansion at eval.jl:49 [inlined]
(::Atom.##48#52{Dict{String,Any}})() at task.jl:80

I cannot share the code at this moment, but I would be willing to share the .jls file of the chain object if that is helpful.

Thanks,

-Chris

@bdeonovic
Copy link
Contributor

@fisherc2 If you could provide the chain that would be helpful.

@itsdfish
Copy link
Author

itsdfish commented Oct 6, 2017

@bdeonovic I could not upload the file here. I sent it to the email listed on your profile. Please let me know if that email is no longer active.

@goedman
Copy link

goedman commented Oct 6, 2017

@fisherc2 Hi Chris, could you also send it to me?

@bdeonovic
Copy link
Contributor

bdeonovic commented Oct 6, 2017

@fisherc2 I was able to plot and draw your code. No errors (just some Gadfly warnings) must be an issue with your setup. What version of julia are you on and what version of Gadfly do you have? Also how did you try to plot. I did:

dat = deserialize(open("Downloads\\Samples_1124543.jls"))
p = plot(dat)
draw(p, fmt=:png, filename="test")

@bdeonovic
Copy link
Contributor

To confirm here are the first 2 files from draw:

test-1
test-2

@itsdfish
Copy link
Author

itsdfish commented Oct 6, 2017

@bdeonovic I am using Julia .6 and Gadfly .6.4. After seeing your code, I think I may have identified the source of the error. Here is the code that produces the error based on @goedman Stan walk through:

sim = read("Samples_1124543.jls",Chains)
p = plot(sim, [:trace, :mean, :density, :autocor], legend=true);
draw(p, ncol=2, filename= "test", fmt=:png,width=20inch,height=15inch)

However, if I remove argument [:trace, :mean, :density, :autocor] from plot(), I no longer get the error. Note that the code above only produces an error on some chains.

@bdeonovic
Copy link
Contributor

error seems to be with autocor. I will investigate further

@bdeonovic
Copy link
Contributor

Issue is one of your variables (divergent__) is all 0s for all iterations and chains. This caused the autocor function to produce all NaNs which caused ChainSummary to error out.

We should probably have an error catch somewhere in the plotting to catch this and handle it more elegantly. @brian-j-smith

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

3 participants