From 332af843c2cbe1434de6f01d2b6b7c19cc758b64 Mon Sep 17 00:00:00 2001 From: "C.Brenhin Keller" Date: Mon, 23 May 2022 12:46:41 -0400 Subject: [PATCH] Remove a few less dangerous uses of `1:length` as well --- src/args.jl | 2 +- src/backends/gaston.jl | 2 +- src/backends/pgfplotsx.jl | 2 +- src/backends/plotly.jl | 2 +- test/imgcomp.jl | 2 +- test/runtests.jl | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/args.jl b/src/args.jl index c5fc4724ab..d571a5a606 100644 --- a/src/args.jl +++ b/src/args.jl @@ -399,7 +399,7 @@ const _series_defaults = KW( :hover => nothing, # text to display when hovering over the data points :stride => (1, 1), # array stride for wireframe/surface, the first element is the row stride and the second is the column stride. :connections => nothing, # tuple of arrays to specifiy connectivity of a 3d mesh - :z_order => :front, # one of :front, :back or integer in 1:length(sp.series_list) + :z_order => :front, # one of :front, :back or integer in eachindex(sp.series_list) :permute => :none, # tuple of two symbols to be permuted :extra_kwargs => Dict(), ) diff --git a/src/backends/gaston.jl b/src/backends/gaston.jl index 1f92fe4b82..074ab3ece6 100644 --- a/src/backends/gaston.jl +++ b/src/backends/gaston.jl @@ -227,7 +227,7 @@ function gaston_add_series(plt::Plot{GastonBackend}, series::Series) if gsp.dims == 2 && z === nothing for (n, seg) in enumerate(series_segments(series, st; check = true)) i, rng = seg.attr_index, seg.range - fr = _cycle(series[:fillrange], 1:length(x[rng])) + fr = _cycle(series[:fillrange], eachindex(x[rng])) for sc in gaston_seriesconf!(sp, series, i, n == 1) push!(curves, Gaston.Curve(x[rng], y[rng], nothing, fr, sc)) end diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 537802e7cc..c600872c1e 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -913,7 +913,7 @@ function pgfx_colormap(v::Vector{<:Colorant}) end function pgfx_colormap(cg::ColorGradient) join( - map(1:length(cg)) do i + map(eachindex(cg.colors)) do i @sprintf( "rgb(%.8f)=(%.8f,%.8f,%.8f)", cg.values[i], diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 3447430224..324683a665 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -759,7 +759,7 @@ end function plotly_series_shapes(plt::Plot, series::Series, clims) segments = series_segments(series; check = true) - plotattributes_outs = [KW() for _ in 1:length(segments)] + plotattributes_outs = [KW() for _ in eachindex(segments)] # TODO: create a plotattributes_out for each polygon # x, y = series[:x], series[:y] diff --git a/test/imgcomp.jl b/test/imgcomp.jl index 2324c785ca..22629fd230 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -61,7 +61,7 @@ function image_comparison_facts( sigma = [1, 1], # number of pixels to "blur" tol = 1e-2, ) # acceptable error (percent) - for i in 1:length(Plots._examples) + for i in eachindex(Plots._examples) i in skip && continue if only === nothing || i in only @test image_comparison_tests(pkg, i, debug = debug, sigma = sigma, tol = tol) |> diff --git a/test/runtests.jl b/test/runtests.jl index 2613f901da..35ce1018cc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -402,7 +402,7 @@ const PLOTS_IMG_TOL = parse( # :pyplot, # FIXME: fails with system matplotlib ) only = setdiff( - 1:length(Plots._examples), + eachindex(Plots._examples), (Plots._backend_skips[be] for be in backends)..., ) for be in backends