From 07178057733e7d38435b4859b375199583b3568f Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 4 Jul 2018 22:33:51 +0200 Subject: [PATCH] more deprecation fixes --- src/Plots.jl | 2 +- src/backends/gr.jl | 2 +- src/examples.jl | 14 +++++++------- src/pipeline.jl | 6 +++--- src/plot.jl | 4 ++-- src/recipes.jl | 2 +- src/utils.jl | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index 73b91da3..d67a0381 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -6,7 +6,7 @@ using Reexport import StaticArrays using StaticArrays.FixedSizeArrays -using Dates, Printf, Statistics, Base64 +using Dates, Printf, Statistics, Base64, LinearAlgebra @reexport using RecipesBase import RecipesBase: plot, plot!, animate diff --git a/src/backends/gr.jl b/src/backends/gr.jl index fc621591..e94b69c1 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -317,7 +317,7 @@ function normalize_zvals(zv::AVec, clims::NTuple{2, <:Real}) if vmin == vmax zeros(length(zv)) else - clamp.((zv - vmin) ./ (vmax - vmin), 0, 1) + clamp.((zv .- vmin) ./ (vmax .- vmin), 0, 1) end end diff --git a/src/examples.jl b/src/examples.jl index b749aacb..ee362741 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -52,7 +52,7 @@ the `z` argument to turn on series gradients. [:(begin y = rand(100) plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=0, α=0.6) -scatter!(y, zcolor=abs.(y-.5), m=(:heat,0.8,stroke(1,:green)), ms=10*abs.(y-0.5)+4, +scatter!(y, zcolor=abs.(y.-0.5), m=(:heat,0.8,stroke(1,:green)), ms=10*abs.(y.-0.5).+4, lab="grad") end)] ), @@ -69,7 +69,7 @@ the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!` y = rand(20,3) plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), leg=false) -hline!(mean(y,1)+rand(1,3), line=(4,:dash,0.6,[:lightgreen :green :darkgreen])) +hline!(mean(y, dims = 1)+rand(1,3), line=(4,:dash,0.6,[:lightgreen :green :darkgreen])) vline!([5,10]) title!("TITLE") yaxis!("YLABEL", :log10) @@ -145,7 +145,7 @@ styles = filter(s -> s in Plots.supported_styles(), [:solid, :dash, :dot, :dashdot, :dashdotdot]) styles = reshape(styles, 1, length(styles)) # Julia 0.6 unfortunately gives an error when transposing symbol vectors n = length(styles) -y = cumsum(randn(20,n),1) +y = cumsum(randn(20,n), dims = 1) plot(y, line = (5, styles), label = map(string,styles), legendtitle = "linestyle") end)] ), @@ -202,7 +202,7 @@ plot(Plots.fakedata(100,10), layout=4, palette=[:grays :blues :heat :lightrainbo PlotExample("", "", [:(begin - srand(111) + Random.srand(111) plot!(Plots.fakedata(100,10)) end)] ), @@ -215,7 +215,7 @@ subsequently create a :path series with the appropriate line segments. """, [:(begin n=20 -hgt=rand(n)+1 +hgt=rand(n).+1 bot=randn(n) openpct=rand(n) closepct=rand(n) @@ -254,7 +254,7 @@ verts = [(-1.0,1.0),(-1.28,0.6),(-0.2,-1.4),(0.2,-1.4),(1.28,0.6),(1.0,1.0), (-1.0,1.0),(-0.2,-0.6),(0.0,-0.2),(-0.4,0.6),(1.28,0.6),(0.2,-1.4), (-0.2,-1.4),(0.6,0.2),(-0.2,0.2),(0.0,-0.2),(0.2,0.2),(-0.2,-0.6)] x = 0.1:0.2:0.9 -y = 0.7rand(5)+0.15 +y = 0.7rand(5).+0.15 plot(x, y, line = (3,:dash,:lightblue), marker = (Shape(verts),30,RGBA(0,0,0,0.2)), bg=:pink, fg=:darkblue, xlim = (0,1), ylim=(0,1), leg=false) end)] @@ -439,7 +439,7 @@ each line segment or marker in the plot. # make and display one plot function test_examples(pkgname::Symbol, idx::Int; debug = false, disp = true) Plots._debugMode.on = debug - info("Testing plot: $pkgname:$idx:$(_examples[idx].header)") + @info("Testing plot: $pkgname:$idx:$(_examples[idx].header)") backend(pkgname) backend() map(eval, _examples[idx].exprs) diff --git a/src/pipeline.jl b/src/pipeline.jl index 411b83bf..d4cb1f4a 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -11,11 +11,11 @@ function _expand_seriestype_array(d::KW, args) sts = get(d, :seriestype, :path) if typeof(sts) <: AbstractArray delete!(d, :seriestype) - rd = Vector{RecipeData}(size(sts, 1)) + rd = Vector{RecipeData}(undef, size(sts, 1)) for r in 1:size(sts, 1) dc = copy(d) dc[:seriestype] = sts[r:r,:] - rd[i] = RecipeData(dc, args) + rd[r] = RecipeData(dc, args) end rd else @@ -153,7 +153,7 @@ function _add_smooth_kw(kw_list::Vector{KW}, kw::KW) x, y = kw[:x], kw[:y] β, α = convert(Matrix{Float64}, [x ones(length(x))]) \ convert(Vector{Float64}, y) sx = [ignorenan_minimum(x), ignorenan_maximum(x)] - sy = β * sx + α + sy = β .* sx .+ α push!(kw_list, merge(copy(kw), KW( :seriestype => :path, :x => sx, diff --git a/src/plot.jl b/src/plot.jl index 877c39c8..7e62b126 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -14,7 +14,7 @@ function current() if isplotnull() error("No current plot/subplot") end - get(CURRENT_PLOT.nullableplot) + CURRENT_PLOT.nullableplot end current(plot::AbstractPlot) = (CURRENT_PLOT.nullableplot = plot) @@ -65,7 +65,7 @@ function plot(plt1::Plot, plts_tail::Plot...; kw...) # build our plot vector from the args n = length(plts_tail) + 1 - plts = Array{Plot}(n) + plts = Array{Plot}(undef, n) plts[1] = plt1 for (i,plt) in enumerate(plts_tail) plts[i+1] = plt diff --git a/src/recipes.jl b/src/recipes.jl index dab7cfef..91f84fe5 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -586,7 +586,7 @@ function _auto_binning_nbins(vs::NTuple{N,AbstractVector}, dim::Integer; mode::S _iqr(v) = (q = quantile(v, 0.75) - quantile(v, 0.25); q > 0 ? q : oftype(q, 1)) _span(v) = ignorenan_maximum(v) - ignorenan_minimum(v) - n_samples = length(linearindices(first(vs))) + n_samples = length(LinearIndices(first(vs))) # The nd estimator is the key to most automatic binning methods, and is modified for twodimensional histograms to include correlation nd = n_samples^(1/(2+N)) diff --git a/src/utils.jl b/src/utils.jl index 5a840c36..cd1db249 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -382,7 +382,7 @@ end function convert_to_polar(x, y, r_extrema = calc_r_extrema(x, y)) rmin, rmax = r_extrema theta, r = filter_radial_data(x, y, r_extrema) - r = (r - rmin) / (rmax - rmin) + r = (r .- rmin) ./ (rmax .- rmin) x = r.*cos.(theta) y = r.*sin.(theta) x, y