Skip to content

Commit 9cb3724

Browse files
femtocleaner[bot]stevengj
authored andcommitted
Fix deprecations (#348)
1 parent 813db7b commit 9cb3724

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/PyPlot.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Base.show
1616
# that lazily looks up help from a PyObject via zero or more keys.
1717
# This saves us time when loading PyPlot, since we don't have
1818
# to load up all of the documentation strings right away.
19-
immutable LazyHelp
19+
struct LazyHelp
2020
o # a PyObject or similar object supporting getindex with a __doc__ key
2121
keys::Tuple{Vararg{String}}
2222
LazyHelp(o) = new(o, ())
@@ -51,7 +51,7 @@ include("init.jl")
5151
###########################################################################
5252
# Wrapper around matplotlib Figure, supporting graphics I/O and pretty display
5353

54-
type Figure
54+
mutable struct Figure
5555
o::PyObject
5656
end
5757
PyObject(f::Figure) = f.o
@@ -200,7 +200,7 @@ include("colormaps.jl")
200200
###########################################################################
201201
# Support array of string labels in bar chart
202202

203-
function bar{T<:AbstractString}(x::AbstractVector{T}, y; kws...)
203+
function bar(x::AbstractVector{T}, y; kws...) where T<:AbstractString
204204
xi = 1:length(x)
205205
if !any(kw -> kw[1] == :align, kws)
206206
push!(kws, (:align, "center"))
@@ -213,7 +213,7 @@ function bar{T<:AbstractString}(x::AbstractVector{T}, y; kws...)
213213
return p
214214
end
215215

216-
bar{T<:Symbol}(x::AbstractVector{T}, y; kws...) =
216+
bar(x::AbstractVector{T}, y; kws...) where {T<:Symbol} =
217217
bar(map(string, x), y; kws...)
218218

219219
###########################################################################

src/colormaps.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export ColorMap, get_cmap, register_cmap, get_cmaps
77
########################################################################
88
# Wrapper around colors.Colormap type:
99

10-
type ColorMap
10+
mutable struct ColorMap
1111
o::PyObject
1212
end
1313

@@ -58,21 +58,21 @@ end
5858

5959
# most general constructors using RGB arrays of triples, defined
6060
# as for matplotlib.colors.LinearSegmentedColormap
61-
ColorMap{T<:Real}(name::Union{AbstractString,Symbol},
62-
r::AbstractVector{Tuple{T,T,T}},
63-
g::AbstractVector{Tuple{T,T,T}},
64-
b::AbstractVector{Tuple{T,T,T}},
65-
n=max(256,length(r),length(g),length(b)), gamma=1.0) =
61+
ColorMap(name::Union{AbstractString,Symbol},
62+
r::AbstractVector{Tuple{T,T,T}},
63+
g::AbstractVector{Tuple{T,T,T}},
64+
b::AbstractVector{Tuple{T,T,T}},
65+
n=max(256,length(r),length(g),length(b)), gamma=1.0) where {T<:Real} =
6666
ColorMap(name, r,g,b, Array{Tuple{T,T,T}}(0), n, gamma)
6767

6868
# as above, but also passing an alpha array
69-
function ColorMap{T<:Real}(name::Union{AbstractString,Symbol},
70-
r::AbstractVector{Tuple{T,T,T}},
71-
g::AbstractVector{Tuple{T,T,T}},
72-
b::AbstractVector{Tuple{T,T,T}},
73-
a::AbstractVector{Tuple{T,T,T}},
74-
n=max(256,length(r),length(g),length(b),length(a)),
75-
gamma=1.0)
69+
function ColorMap(name::Union{AbstractString,Symbol},
70+
r::AbstractVector{Tuple{T,T,T}},
71+
g::AbstractVector{Tuple{T,T,T}},
72+
b::AbstractVector{Tuple{T,T,T}},
73+
a::AbstractVector{Tuple{T,T,T}},
74+
n=max(256,length(r),length(g),length(b),length(a)),
75+
gamma=1.0) where T<:Real
7676
segmentdata = Dict("red" => r, "green" => g, "blue" => b)
7777
if !isempty(a)
7878
segmentdata["alpha"] = a
@@ -82,8 +82,8 @@ function ColorMap{T<:Real}(name::Union{AbstractString,Symbol},
8282
end
8383

8484
# create from an array c, assuming linear mapping from [0,1] to c
85-
function ColorMap{T<:Colorant}(name::Union{AbstractString,Symbol},
86-
c::AbstractVector{T}, n=max(256, length(c)), gamma=1.0)
85+
function ColorMap(name::Union{AbstractString,Symbol},
86+
c::AbstractVector{T}, n=max(256, length(c)), gamma=1.0) where T<:Colorant
8787
nc = length(c)
8888
if nc == 0
8989
throw(ArgumentError("ColorMap requires a non-empty Colorant array"))
@@ -111,12 +111,12 @@ function ColorMap{T<:Colorant}(name::Union{AbstractString,Symbol},
111111
ColorMap(name, r,g,b,a, n, gamma)
112112
end
113113

114-
ColorMap{T<:Colorant}(c::AbstractVector{T},
115-
n=max(256, length(c)), gamma=1.0) =
114+
ColorMap(c::AbstractVector{T},
115+
n=max(256, length(c)), gamma=1.0) where {T<:Colorant} =
116116
ColorMap(string("cm_", hash(c)), c, n, gamma)
117117

118-
function ColorMap{T<:Real}(name::Union{AbstractString,Symbol}, c::AbstractMatrix{T},
119-
n=max(256, size(c,1)), gamma=1.0)
118+
function ColorMap(name::Union{AbstractString,Symbol}, c::AbstractMatrix{T},
119+
n=max(256, size(c,1)), gamma=1.0) where T<:Real
120120
if size(c,2) == 3
121121
return ColorMap(name,
122122
[RGB{T}(c[i,1],c[i,2],c[i,3]) for i in 1:size(c,1)],
@@ -131,7 +131,7 @@ function ColorMap{T<:Real}(name::Union{AbstractString,Symbol}, c::AbstractMatrix
131131
end
132132
end
133133

134-
ColorMap{T<:Real}(c::AbstractMatrix{T}, n=max(256, size(c,1)), gamma=1.0) =
134+
ColorMap(c::AbstractMatrix{T}, n=max(256, size(c,1)), gamma=1.0) where {T<:Real} =
135135
ColorMap(string("cm_", hash(c)), c, n, gamma)
136136

137137
########################################################################

src/plot3d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
###########################################################################
22
# Lazy wrapper around a PyObject to load a module on demand.
33

4-
type LazyPyModule
4+
mutable struct LazyPyModule
55
name::String
66
o::PyObject
77
LazyPyModule(n) = new(n, PyNULL())

0 commit comments

Comments
 (0)