Skip to content

Commit 3bd36da

Browse files
ksmcreynoldsstevengj
authored andcommitted
fix 0.7 depwarns (#368)
* update array constructors to 0.7 * replace linspace with range * fix other 0.7 depwarns in tests * switch to use Compat.Test
1 parent e46a33d commit 3bd36da

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ For example:
8787

8888
```
8989
using PyPlot
90-
x = linspace(0,2*pi,1000); y = sin.(3 * x + 4 * cos.(2 * x));
90+
# use x = linspace(0,2*pi,1000) in Julia 0.6
91+
x = range(0; stop=2*pi, length=1000); y = sin.(3 * x + 4 * cos.(2 * x));
9192
plot(x, y, color="red", linewidth=2.0, linestyle="--")
9293
title("A sinusoidally modulated sinusoid")
9394
```

src/colormaps.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ColorMap(name::Union{AbstractString,Symbol},
6363
g::AbstractVector{Tuple{T,T,T}},
6464
b::AbstractVector{Tuple{T,T,T}},
6565
n=max(256,length(r),length(g),length(b)), gamma=1.0) where {T<:Real} =
66-
ColorMap(name, r,g,b, Array{Tuple{T,T,T}}(0), n, gamma)
66+
ColorMap(name, r,g,b, Array{Tuple{T,T,T}}(undef, 0), n, gamma)
6767

6868
# as above, but also passing an alpha array
6969
function ColorMap(name::Union{AbstractString,Symbol},
@@ -88,11 +88,11 @@ function ColorMap(name::Union{AbstractString,Symbol},
8888
if nc == 0
8989
throw(ArgumentError("ColorMap requires a non-empty Colorant array"))
9090
end
91-
r = Array{Tuple{Float64,Float64,Float64}}(nc)
91+
r = Array{Tuple{Float64,Float64,Float64}}(undef, nc)
9292
g = similar(r)
9393
b = similar(r)
9494
a = T <: TransparentColor ?
95-
similar(r) : Array{Tuple{Float64,Float64,Float64}}(0)
95+
similar(r) : Array{Tuple{Float64,Float64,Float64}}(undef, 0)
9696
for i = 1:nc
9797
x = (i-1) / (nc-1)
9898
if T <: TransparentColor
@@ -158,7 +158,7 @@ get_cmaps() =
158158
function show(io::IO, ::MIME"image/svg+xml", cs::AbstractVector{ColorMap})
159159
n = 256
160160
nc = length(cs)
161-
a = linspace(0,1,n)
161+
a = Compat.range(0; stop=1, length=n)
162162
namelen = mapreduce(c -> length(c[:name]), max, cs)
163163
width = 0.5
164164
height = 5

test/runtests.jl

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@ ENV["MPLBACKEND"]="agg" # no GUI
22

33
using PyPlot, PyCall
44
using Compat
5+
using Compat.Test
56

67
VERSION >= v"0.7.0" && using Base64
78

8-
if isdefined(Base, :Test) && !Base.isdeprecated(Base, :Test)
9-
using Base.Test
10-
else
11-
using Test
12-
end
13-
149
plot(1:5, 2:6, "ro-")
1510

1611
line = gca()[:lines][1]

0 commit comments

Comments
 (0)