Skip to content

Commit 2b3a9b3

Browse files
authored
fix deprecations (#65)
1 parent 387cfe5 commit 2b3a9b3

File tree

6 files changed

+12
-100
lines changed

6 files changed

+12
-100
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
julia 0.5
2+
Compat 0.17

src/Distances.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ __precompile__()
22

33
module Distances
44

5+
using Compat
6+
57
export
68
# generic types/functions
79
PreMetric,

src/generic.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
# d(x, y) >= 0
66
# d(x, x) = 0
77
#
8-
abstract PreMetric
8+
@compat abstract type PreMetric end
99

1010
# a semimetric is a function d that satisfies:
1111
#
1212
# d(x, y) >= 0
1313
# d(x, x) = 0
1414
# d(x, y) = d(y, x)
1515
#
16-
abstract SemiMetric <: PreMetric
16+
@compat abstract type SemiMetric <: PreMetric end
1717

1818
# a metric is a semimetric that satisfies triangle inequality:
1919
#
2020
# d(x, y) + d(y, z) >= d(x, z)
2121
#
22-
abstract Metric <: SemiMetric
22+
@compat abstract type Metric <: SemiMetric end
2323

2424

2525
# Generic functions

src/metrics.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ immutable RenyiDivergence{T <: Real} <: PreMetric
3535
is_zero::Bool
3636
is_one::Bool
3737
is_inf::Bool
38-
function RenyiDivergence(q)
38+
39+
function (::Type{RenyiDivergence{T}}){T}(q)
3940
# There are four different cases:
4041
# simpler to separate them out now, not over and over in eval_op()
4142
is_zero = q zero(T)
@@ -45,7 +46,7 @@ immutable RenyiDivergence{T <: Real} <: PreMetric
4546
# Only positive Rényi divergences are defined
4647
!is_zero && q < zero(T) && throw(ArgumentError("Order of Rényi divergence not legal, $(q) < 0."))
4748

48-
new(q - 1, !(is_zero || is_one || is_inf), is_zero, is_one, is_inf)
49+
new{T}(q - 1, !(is_zero || is_one || is_inf), is_zero, is_one, is_inf)
4950
end
5051
end
5152
RenyiDivergence{T}(q::T) = RenyiDivergence{T}(q)
@@ -55,7 +56,7 @@ type JSDivergence <: SemiMetric end
5556
type SpanNormDist <: SemiMetric end
5657

5758

58-
typealias UnionMetrics Union{Euclidean, SqEuclidean, Chebyshev, Cityblock, Minkowski, Hamming, Jaccard, RogersTanimoto, CosineDist, CorrDist, ChiSqDist, KLDivergence, RenyiDivergence, JSDivergence, SpanNormDist}
59+
const UnionMetrics = Union{Euclidean, SqEuclidean, Chebyshev, Cityblock, Minkowski, Hamming, Jaccard, RogersTanimoto, CosineDist, CorrDist, ChiSqDist, KLDivergence, RenyiDivergence, JSDivergence, SpanNormDist}
5960

6061
"""
6162
Euclidean([thresh])

src/wmetrics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Metric types
77
#
88
###########################################################
9-
typealias RealAbstractArray{T <: AbstractFloat} AbstractArray{T}
9+
@compat const RealAbstractArray{T <: AbstractFloat} = AbstractArray{T}
1010

1111

1212
immutable WeightedEuclidean{W <: RealAbstractArray} <: Metric
@@ -31,7 +31,7 @@ immutable WeightedHamming{W <: RealAbstractArray} <: Metric
3131
end
3232

3333

34-
typealias UnionWeightedMetrics{W} Union{WeightedEuclidean{W}, WeightedSqEuclidean{W}, WeightedCityblock{W}, WeightedMinkowski{W}, WeightedHamming{W}}
34+
@compat const UnionWeightedMetrics{W} = Union{WeightedEuclidean{W}, WeightedSqEuclidean{W}, WeightedCityblock{W}, WeightedMinkowski{W}, WeightedHamming{W}}
3535
Base.eltype(x::UnionWeightedMetrics) = eltype(x.weights)
3636
###########################################################
3737
#

test/collect_bench_results.jl

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)