From 9e4c7ee78f4cc056b3666dc34fdf69397eaf9b96 Mon Sep 17 00:00:00 2001 From: "Ralph A. Smith" Date: Fri, 29 Jun 2018 23:40:34 -0400 Subject: [PATCH] replace deprecated linspace; another tweak to CI stuff --- .travis.yml | 2 +- appveyor.yml | 7 ++----- src/arg_desc.jl | 2 +- src/axes.jl | 4 ++-- src/backends/glvisualize.jl | 4 ++-- src/backends/gr.jl | 6 +++--- src/backends/plotly.jl | 2 +- src/examples.jl | 14 +++++++------- src/recipes.jl | 2 +- src/series.jl | 4 ++-- src/themes.jl | 4 ++-- src/utils.jl | 4 ++-- test/travis_commands.jl | 2 +- 13 files changed, 27 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c56cb62..2e9ab8bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: julia os: - linux - # - osx + - osx julia: # - 0.7 - nightly diff --git a/appveyor.yml b/appveyor.yml index 81d2e51f..7f74d24c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,10 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" matrix: allow_failures: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" #check and address - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" @@ -32,8 +29,8 @@ install: build_script: # Need to convert from shallow to complete for Pkg.clone to work - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -e "versioninfo(); Pkg.clone(pwd(), \"Plots\"); Pkg.build(\"Plots\")" + - C:\projects\julia\bin\julia -e "using InteractiveUtils; versioninfo(); import Pkg; Pkg.clone(pwd(),\"Plots\"); Pkg.build(\"Plots\")" test_script: # - C:\projects\julia\bin\julia -e "Pkg.test(\"Plots\")" - - C:\projects\julia\bin\julia -e "include(Pkg.dir(\"Plots\", \"test\", \"travis_commands.jl\"))" + - C:\projects\julia\bin\julia -e "import Pkg; include(Pkg.dir(\"Plots\", \"test\", \"travis_commands.jl\"))" diff --git a/src/arg_desc.jl b/src/arg_desc.jl index 56e3719d..9ba485f5 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -21,7 +21,7 @@ const _arg_desc = KW( :markerstrokewidth => "Number. Width of the marker stroke (border. in pixels)", :markerstrokecolor => "Color Type. Color of the marker stroke (border). `:match` will take the value from `:foreground_color_subplot`.", :markerstrokealpha => "Number in [0,1]. The alpha/opacity override for the marker stroke (border). `nothing` (the default) means it will take the alpha value of markerstrokecolor.", -:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g. `linspace(extrema(x)..., 25)`", +:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g. `range(minimum(x),stop=maximum(x), length=25)`", :smooth => "Bool. Add a regression line?", :group => "AbstractVector. Data is split into a separate series, one for each unique value in `group`.", :x => "Various. Input data. First Dimension", diff --git a/src/axes.jl b/src/axes.jl index 5e422837..fa7499f7 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -251,7 +251,7 @@ function get_ticks(axis::Axis) # discrete ticks... n = length(dvals) rng = if ticks == :auto - Int[round(Int,i) for i in linspace(1, n, 15)] + Int[round(Int,i) for i in range(1, stop=n, length=15)] else # if ticks == :all 1:n end @@ -265,7 +265,7 @@ function get_ticks(axis::Axis) end elseif typeof(ticks) <: Union{AVec, Int} if !isempty(dvals) && typeof(ticks) <: Int - rng = Int[round(Int,i) for i in linspace(1, length(dvals), ticks)] + rng = Int[round(Int,i) for i in range(1, stop=length(dvals), length=ticks)] axis[:continuous_values][rng], dvals[rng] else # override ticks, but get the labels diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 241609d0..cacf8ebe 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -397,7 +397,7 @@ function gappy(x, ps) return last(ps) - x end function ticks(points, resolution) - Float16[gappy(x, points) for x = linspace(first(points),last(points), resolution)] + Float16[gappy(x, points) for x = range(first(points),stop=last(points), length=resolution)] end @@ -901,7 +901,7 @@ function gl_boxplot(d, kw_args) # filter y values = y[filter(i -> _cycle(x,i) == glabel, 1:length(y))] # compute quantiles - q1,q2,q3,q4,q5 = quantile(values, linspace(0,1,5)) + q1,q2,q3,q4,q5 = quantile(values, range(0,stop=1,5)) # notch n = Plots.notch_width(q2, q4, length(values)) # warn on inverted notches? diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 5e01e23c..1d8cf944 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -485,7 +485,7 @@ function gr_colorbar(sp::Subplot, clims) xmin, xmax = gr_xy_axislims(sp)[1:2] gr_set_viewport_cmap(sp) l = zeros(Int32, 1, 256) - l[1,:] = Int[round(Int, _i) for _i in linspace(1000, 1255, 256)] + l[1,:] = Int[round(Int, _i) for _i in range(1000, stop=1255, length=256)] GR.setscale(0) GR.setwindow(xmin, xmax, clims[1], clims[2]) GR.cellarray(xmin, xmax, clims[2], clims[1], 1, length(l), l) @@ -531,7 +531,7 @@ const _gr_gradient_alpha = ones(256) function gr_set_gradient(c) grad = isa(c, ColorGradient) ? c : cgrad() - for (i,z) in enumerate(linspace(0, 1, 256)) + for (i,z) in enumerate(range(0, stop=1, length=256)) c = grad[z] GR.setcolorrep(999+i, red(c), green(c), blue(c)) _gr_gradient_alpha[i] = alpha(c) @@ -1051,7 +1051,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) if typeof(series[:levels]) <: AbstractArray h = series[:levels] else - h = series[:levels] > 1 ? linspace(zmin, zmax, series[:levels]) : [(zmin + zmax) / 2] + h = series[:levels] > 1 ? range(zmin, stop=zmax, length=series[:levels]) : [(zmin + zmax) / 2] end if series[:fillrange] != nothing GR.surface(x, y, z, GR.OPTION_CELL_ARRAY) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 7bef25d2..79a66154 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -450,7 +450,7 @@ function plotly_colorscale(c::AbstractVector{<:RGBA}, α) if length(c) == 1 return [[0.0, rgba_string(plot_color(c[1], α))], [1.0, rgba_string(plot_color(c[1], α))]] else - vals = linspace(0.0, 1.0, length(c)) + vals = range(0.0, stop=1.0, length=length(c)) return [[vals[i], rgba_string(plot_color(c[i], α))] for i in eachindex(c)] end end diff --git a/src/examples.jl b/src/examples.jl index e592154b..e01db363 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -31,7 +31,7 @@ animation. [:(begin p = plot([sin,cos], zeros(0), leg=false) anim = Animation() - for x in linspace(0, 10π, 100) + for x in range(0, stop=10π, length=100) push!(p, x, Float64[sin(x), cos(x)]) frame(anim) end @@ -158,7 +158,7 @@ PlotExample("Marker types", markers = filter(m -> m in Plots.supported_markers(), Plots._shape_keys) markers = reshape(markers, 1, length(markers)) n = length(markers) - x = linspace(0,10,n+2)[2:end-1] + x = range(0,stop=10,length=n+2)[2:end-1] y = repeat(reshape(reverse(x),1,:), n, 1) scatter(x, y, m=(8,:auto), lab=map(string,markers), bg=:linen, xlim=(0,10), ylim=(0,10)) end)] @@ -240,7 +240,7 @@ y = rand(10) plot(y, annotations = (3,y[3],text("this is #3",:left)), leg=false) annotate!([(5, y[5], text("this is #5",16,:red,:center)), (10, y[10], text("this is #10",:right,20,"courier"))]) -scatter!(linspace(2,8,6), rand(6), marker=(50,0.2,:orange), +scatter!(range(2,stop=8,length=6), rand(6), marker=(50,0.2,:orange), series_annotations = ["series","annotations","map","to","series", text("data",:green)]) end)] @@ -293,7 +293,7 @@ PlotExample("3D", "", [:(begin n = 100 - ts = linspace(0,8π,n) + ts = range(0,stop=8π,length=n) x = ts .* map(cos,ts) y = 0.1ts .* map(sin,ts) z = 1:n @@ -325,7 +325,7 @@ PlotExample("Groups and Subplots", PlotExample("Polar Plots", "", [:(begin - Θ = linspace(0,1.5π,100) + Θ = range(0,stop=1.5π,length=100) r = abs.(0.1randn(100)+sin.(3Θ)) plot(Θ, r, proj=:polar, m=2) end)] @@ -370,7 +370,7 @@ PlotExample("Animation with subplots", plot(log,1,xlims=(1,10π),ylims=(0,5),leg=false),layout=l) anim = Animation() - for x = linspace(1,10π,100) + for x = range(1,stop=10π,length=100) plot(push!(p,x,Float64[sin(x),cos(x),atan(x),cos(x),log(x)])) frame(anim) end @@ -424,7 +424,7 @@ You can use the `line_z` and `marker_z` properties to associate a color with each line segment or marker in the plot. """, [:(begin - t = linspace(0, 1, 100) + t = range(0, stop=1, length=100) θ = 6π .* t x = t .* cos.(θ) y = t .* sin.(θ) diff --git a/src/recipes.jl b/src/recipes.jl index a246fd89..04e1da79 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -284,7 +284,7 @@ end # where the points are the control points of the curve for rng in iter_segments(args...) length(rng) < 2 && continue - ts = linspace(0, 1, npoints) + ts = range(0, stop=1, length=npoints) nanappend!(newx, map(t -> bezier_value(_cycle(x,rng), t), ts)) nanappend!(newy, map(t -> bezier_value(_cycle(y,rng), t), ts)) if z != nothing diff --git a/src/series.jl b/src/series.jl index 1eff25a5..517b6d00 100644 --- a/src/series.jl +++ b/src/series.jl @@ -518,7 +518,7 @@ end xs, fs end @recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, u::AVec) where {F<:Function,G<:Function} = mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u) -@recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, umin::Number, umax::Number, n = 200) where {F<:Function,G<:Function} = fx, fy, linspace(umin, umax, n) +@recipe f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, umin::Number, umax::Number, n = 200) where {F<:Function,G<:Function} = fx, fy, range(umin, stop=umax, length=n) # # # special handling... 3D parametric function(s) @@ -526,7 +526,7 @@ end mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u), mapFuncOrFuncs(fz, u) end @recipe function f(fx::FuncOrFuncs{F}, fy::FuncOrFuncs{G}, fz::FuncOrFuncs{H}, umin::Number, umax::Number, numPoints = 200) where {F<:Function,G<:Function,H<:Function} - fx, fy, fz, linspace(umin, umax, numPoints) + fx, fy, fz, range(umin, stop=umax, length=numPoints) end # diff --git a/src/themes.jl b/src/themes.jl index c2b2aee1..43cf86d8 100644 --- a/src/themes.jl +++ b/src/themes.jl @@ -132,7 +132,7 @@ _get_showtheme_args(thm::Symbol, func::Symbol) = thm, get(_color_functions, func f(r) = sin(r) / r _norm(x, y) = norm([x, y]) - x = y = linspace(-3π, 3π, 30) + x = y = range(-3π, stop=3π, length=30) z = f.(_norm.(x, y')) wi = 2:3:30 @@ -152,7 +152,7 @@ _get_showtheme_args(thm::Symbol, func::Symbol) = thm, get(_color_functions, func end n = 100 - ts = linspace(0, 10π, n) + ts = range(0, stop=10π, length=n) x = ts .* cos.(ts) y = (0.1ts) .* sin.(ts) z = 1:n diff --git a/src/utils.jl b/src/utils.jl index 52f39d30..80c00daa 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -4,7 +4,7 @@ calcMidpoints(edges::AbstractVector) = Float64[0.5 * (edges[i] + edges[i+1]) for "Make histogram-like bins of data" function binData(data, nbins) lo, hi = ignorenan_extrema(data) - edges = collect(linspace(lo, hi, nbins+1)) + edges = collect(range(lo, stop=hi, length=nbins+1)) midpoints = calcMidpoints(edges) buckets = Int[max(2, min(searchsortedfirst(edges, x), length(edges)))-1 for x in data] counts = zeros(Int, length(midpoints)) @@ -119,7 +119,7 @@ function replace_image_with_heatmap(z::Array{T}) where T<:Colorant n, m = size(z) # idx = 0 colors = ColorGradient(vec(z)) - newz = reshape(linspace(0, 1, n*m), n, m) + newz = reshape(range(0, stop=1, length=n*m), n, m) newz, colors # newz = zeros(n, m) # for i=1:n, j=1:m diff --git a/test/travis_commands.jl b/test/travis_commands.jl index 97aeea2e..575dd6ac 100644 --- a/test/travis_commands.jl +++ b/test/travis_commands.jl @@ -9,7 +9,7 @@ Pkg.build("ImageMagick") Pkg.clone("StatPlots") -Pkg.develop("PlotUtils") +Pkg.add("PlotUtils") Pkg.develop("RecipesBase") # Pkg.clone("Blink")