From b1f11f590529473c1118ee932e1fdef2830732b3 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Mon, 13 May 2019 09:31:15 +0200 Subject: [PATCH] Fix BoundsError with empty datasets The error can be triggered with: @gp Float64[] which produces the following error message ERROR: BoundsError: attempt to access 0-element Array{Float64,1} at index [1] Stacktrace: [1] getindex at ./array.jl:729 [inlined] [2] #newdatasource#83(::String, ::Function, ::Gnuplot.Concrete_Session, ::Array{Float64,1}) at ~/.julia/dev/Gnuplot/src/Gnuplot.jl:316 ... This commit fixes the Julia error, but Gnuplot still reports the following error: "Bad data on line 1 of file $data0". This is dealt with in the following commit. --- src/Gnuplot.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index 07ef58e..db7ab7f 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -313,10 +313,10 @@ function newdatasource(gp::DrySession, args...; name="") if typeof(d) <: Number ok = true elseif typeof(d) <: AbstractArray - if typeof(d[1]) <: Number + if typeof(d).parameters[1] <: Number ok = true end - if typeof(d[1]) <: ColorTypes.RGB + if typeof(d).parameters[1] <: ColorTypes.RGB ok = true end end