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.
This commit is contained in:
Michal Sojka 2019-05-13 09:31:15 +02:00
parent 0017f69cee
commit b1f11f5905

View File

@ -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