JuliaGraphics / ColorSchemes.jl

colorschemes, colormaps, gradients, and palettes
http://juliagraphics.github.io/ColorSchemes.jl/
Other
187 stars 33 forks source link

`firstindex` method error in color scheme #99

Closed stelmo closed 2 years ago

stelmo commented 2 years ago

Hi, I am not sure if this is expected behavior, but when one attempts to access the first color in a color scheme using begin instead of 1, a method error happens. Here is a MWE:

ColorSchemes.Dark2_3[begin] # error
ColorSchemes.Dark2_3[1] # okay
ColorSchemes.Dark2_3[end] # this works though
julia> cs = ColorSchemes.Dark2_3[begin]
ERROR: MethodError: no method matching firstindex(::ColorScheme{Vector{ColorTypes.RGB{Float64}}, String, String})
Closest candidates are:
  firstindex(::Any, ::Any) at abstractarray.jl:402
  firstindex(::Union{Tables.AbstractColumns, Tables.AbstractRow}) at C:\Users\stelmo\.julia\packages\Tables\PxO1m\src\Tables.jl:177
  firstindex(::Interpolations.KnotIterator) at C:\Users\stelmo\.julia\packages\Interpolations\jPlKV\src\iterate.jl:156
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[206]:1
rafaqz commented 2 years ago

Yes we are missing a firstindex method. If you like you can PR and write it as copy of the lastindex method, just above it in the ColoSchemes.jl file.

stelmo commented 2 years ago

Done! See #100 :)