Skip to content

Commit a688ceb

Browse files
femtocleaner[bot]ararslan
authored andcommitted
Fix deprecations (#48)
1 parent 89d8b94 commit a688ceb

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/KernelDensity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Distributions: twoπ, pdf
1414

1515
export kde, kde_lscv, UnivariateKDE, BivariateKDE, InterpKDE, pdf
1616

17-
@compat abstract type AbstractKDE end
17+
abstract type AbstractKDE end
1818

1919
include("univariate.jl")
2020
include("bivariate.jl")

src/bivariate.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
# Store both grid and density for KDE over R2
2-
type BivariateKDE{Rx<:Range,Ry<:Range} <: AbstractKDE
2+
mutable struct BivariateKDE{Rx<:Range,Ry<:Range} <: AbstractKDE
33
x::Rx
44
y::Ry
55
density::Matrix{Float64}
66
end
77

8-
function kernel_dist{D<:UnivariateDistribution}(::Type{D},w::Tuple{Real,Real})
8+
function kernel_dist(::Type{D},w::Tuple{Real,Real}) where D<:UnivariateDistribution
99
kernel_dist(D,w[1]), kernel_dist(D,w[2])
1010
end
11-
function kernel_dist{Dx<:UnivariateDistribution,Dy<:UnivariateDistribution}(::Type{Tuple{Dx, Dy}},w::Tuple{Real,Real})
11+
function kernel_dist(::Type{Tuple{Dx, Dy}},w::Tuple{Real,Real}) where {Dx<:UnivariateDistribution,Dy<:UnivariateDistribution}
1212
kernel_dist(Dx,w[1]), kernel_dist(Dy,w[2])
1313
end
1414

15-
if VERSION >= v"0.6.0-dev.2123"
16-
const DataTypeOrUnionAll = Union{DataType, UnionAll}
17-
else
18-
const DataTypeOrUnionAll = DataType
19-
end
15+
const DataTypeOrUnionAll = Union{DataType, UnionAll}
2016

2117
# this function provided for backwards compatibility, though it doesn't have the type restrictions
2218
# to ensure that the given tuple only contains univariate distributions

src/interp.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Interpolations: interpolate, scale
22

3-
type InterpKDE{K,I} <: AbstractKDE
3+
mutable struct InterpKDE{K,I} <: AbstractKDE
44
kde::K
55
itp::I
6-
@compat (::Type{InterpKDE{K,I}}){K,I}(kde::K, itp::I) = new{K,I}(kde, itp)
6+
InterpKDE{K,I}(kde::K, itp::I) where {K,I} = new{K,I}(kde, itp)
77
end
88

99

src/univariate.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Store both grid and density for KDE over the real line
2-
type UnivariateKDE{R<:Range} <: AbstractKDE
2+
mutable struct UnivariateKDE{R<:Range} <: AbstractKDE
33
x::R
44
density::Vector{Float64}
55
end
@@ -9,7 +9,7 @@ kernel_dist(::Type{Normal},w::Real) = Normal(0.0,w)
99
kernel_dist(::Type{Uniform},w::Real) = (s = 1.7320508075688772*w; Uniform(-s,s))
1010

1111
const LocationScale = Union{Laplace,Logistic,SymTriangularDist}
12-
kernel_dist{D}(::Type{D},w::Real) = (s = w/std(D(0.0,1.0)); D(0.0,s))
12+
kernel_dist(::Type{D},w::Real) where {D} = (s = w/std(D(0.0,1.0)); D(0.0,s))
1313

1414

1515
# Silverman's rule of thumb for KDE bandwidth selection
@@ -70,14 +70,14 @@ function kde_range(boundary::Tuple{Real,Real}, npoints::Int)
7070
lo:step:hi
7171
end
7272

73-
immutable UniformWeights{N} end
73+
struct UniformWeights{N} end
7474

7575
UniformWeights(n) = UniformWeights{n}()
7676

7777
Base.sum(x::UniformWeights) = 1.
78-
Base.getindex{N}(x::UniformWeights{N}, i) = 1/N
78+
Base.getindex(x::UniformWeights{N}, i) where {N} = 1/N
7979

80-
typealias Weights Union{UniformWeights, RealVector, WeightVec}
80+
const Weights = Union{UniformWeights, RealVector, WeightVec}
8181

8282

8383
# tabulate data for kde
@@ -175,7 +175,7 @@ function kde_lscv(data::RealVector, midpoints::Range;
175175
K = length(k.density)
176176
ft = rfft(k.density)
177177

178-
ft2 = @compat(abs2.(ft))
178+
ft2 = abs2.(ft)
179179
c = -twoπ/(step(k.x)*K)
180180
hlb, hub = bandwidth_range
181181

0 commit comments

Comments
 (0)