Skip to content

Commit 26a5449

Browse files
committed
Fix type deprecations for 0.4
1 parent d2e015c commit 26a5449

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

src/fixed32.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ abs{f}(x::Fixed32{f}) = Fixed32{f}(abs(x.i),0)
3939

4040
# conversions and promotions
4141
convert{f}(::Type{Fixed32{f}}, x::Integer) = Fixed32{f}(x<<f,0)
42-
convert{f}(::Type{Fixed32{f}}, x::FloatingPoint) = Fixed32{f}(trunc(Int32,x)<<f + round(Int32, rem(x,1)*(1<<f)),0)
42+
convert{f}(::Type{Fixed32{f}}, x::AbstractFloat) = Fixed32{f}(trunc(Int32,x)<<f + round(Int32, rem(x,1)*(1<<f)),0)
4343
convert{f}(::Type{Fixed32{f}}, x::Rational) = Fixed32{f}(x.num)/Fixed32{f}(x.den)
4444

4545
convert{f}(::Type{BigFloat}, x::Fixed32{f}) =
4646
convert(BigFloat,x.i>>f) + convert(BigFloat,x.i&(1<<f - 1))/convert(BigFloat,1<<f)
47-
convert{T<:FloatingPoint, f}(::Type{T}, x::Fixed32{f}) =
47+
convert{T<:AbstractFloat, f}(::Type{T}, x::Fixed32{f}) =
4848
convert(T,x.i>>f) + convert(T,x.i&(1<<f - 1))/convert(T,1<<f)
4949

5050
convert(::Type{Bool}, x::Fixed32) = x.i!=0
@@ -57,7 +57,7 @@ convert{T<:Rational, f}(::Type{T}, x::Fixed32{f}) =
5757
convert(T, x.i>>f + (x.i&(1<<f-1))//(1<<f))
5858

5959
promote_rule{f,T<:Integer}(ft::Type{Fixed32{f}}, ::Type{T}) = ft
60-
promote_rule{f,T<:FloatingPoint}(::Type{Fixed32{f}}, ::Type{T}) = T
60+
promote_rule{f,T<:AbstractFloat}(::Type{Fixed32{f}}, ::Type{T}) = T
6161
promote_rule{f,T}(::Type{Fixed32{f}}, ::Type{Rational{T}}) = Rational{T}
6262

6363
decompose{f}(x::Fixed32{f}) = x.i, -f, 1

src/ufixed.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# UfixedBase{T,f} maps Uints from 0 to 2^f-1 to the range [0.0, 1.0]
1+
# UfixedBase{T,f} maps UInts from 0 to 2^f-1 to the range [0.0, 1.0]
22
# For example, a Ufixed8 maps 0x00 to 0.0 and 0xff to 1.0
33

44
immutable UfixedBase{T<:Unsigned,f} <: Ufixed
@@ -8,31 +8,31 @@ immutable UfixedBase{T<:Unsigned,f} <: Ufixed
88
UfixedBase(x) = convert(UfixedBase{T,f}, x)
99
end
1010

11-
typealias Ufixed8 UfixedBase{Uint8,8}
12-
typealias Ufixed10 UfixedBase{Uint16,10}
13-
typealias Ufixed12 UfixedBase{Uint16,12}
14-
typealias Ufixed14 UfixedBase{Uint16,14}
15-
typealias Ufixed16 UfixedBase{Uint16,16}
11+
typealias Ufixed8 UfixedBase{UInt8,8}
12+
typealias Ufixed10 UfixedBase{UInt16,10}
13+
typealias Ufixed12 UfixedBase{UInt16,12}
14+
typealias Ufixed14 UfixedBase{UInt16,14}
15+
typealias Ufixed16 UfixedBase{UInt16,16}
1616

1717
const UF = (Ufixed8, Ufixed10, Ufixed12, Ufixed14, Ufixed16)
1818

1919
rawtype{T,f}(::Type{UfixedBase{T,f}}) = T
2020
nbitsfrac{T,f}(::Type{UfixedBase{T,f}}) = f
2121

22-
reinterpret(::Type{Ufixed8}, x::Uint8) = UfixedBase{Uint8,8}(x,0)
22+
reinterpret(::Type{Ufixed8}, x::UInt8) = UfixedBase{UInt8,8}(x,0)
2323
for (T,f) in ((Ufixed10,10),(Ufixed12,12),(Ufixed14,14),(Ufixed16,16))
24-
@eval reinterpret(::Type{$T}, x::Uint16) = UfixedBase{Uint16,$f}(x, 0)
24+
@eval reinterpret(::Type{$T}, x::UInt16) = UfixedBase{UInt16,$f}(x, 0)
2525
end
2626

2727

2828
# The next lines mimic the floating-point literal syntax "3.2f0"
2929
immutable UfixedConstructor{T,f} end
3030
*{T,f}(n::Integer, ::UfixedConstructor{T,f}) = UfixedBase{T,f}(n,0)
31-
const uf8 = UfixedConstructor{Uint8,8}()
32-
const uf10 = UfixedConstructor{Uint16,10}()
33-
const uf12 = UfixedConstructor{Uint16,12}()
34-
const uf14 = UfixedConstructor{Uint16,14}()
35-
const uf16 = UfixedConstructor{Uint16,16}()
31+
const uf8 = UfixedConstructor{UInt8,8}()
32+
const uf10 = UfixedConstructor{UInt16,10}()
33+
const uf12 = UfixedConstructor{UInt16,12}()
34+
const uf14 = UfixedConstructor{UInt16,14}()
35+
const uf16 = UfixedConstructor{UInt16,16}()
3636

3737
zero{T,f}(::Type{UfixedBase{T,f}}) = UfixedBase{T,f}(zero(T),0)
3838
for T in UF
@@ -48,7 +48,7 @@ rawone(v) = reinterpret(one(v))
4848
# Conversions
4949
convert{T<:Ufixed}(::Type{T}, x::T) = x
5050
convert{T1<:Ufixed}(::Type{T1}, x::Ufixed) = reinterpret(T1, round(rawtype(T1), (rawone(T1)/rawone(x))*reinterpret(x)))
51-
convert(::Type{Ufixed16}, x::Ufixed8) = reinterpret(Ufixed16, convert(Uint16, 0x0101*reinterpret(x)))
51+
convert(::Type{Ufixed16}, x::Ufixed8) = reinterpret(Ufixed16, convert(UInt16, 0x0101*reinterpret(x)))
5252
convert{T<:Ufixed}(::Type{T}, x::Real) = T(round(rawtype(T), rawone(T)*x),0)
5353

5454
ufixed8(x) = convert(Ufixed8, x)
@@ -65,7 +65,7 @@ ufixed16(x) = convert(Ufixed16, x)
6565

6666

6767
convert(::Type{BigFloat}, x::Ufixed) = reinterpret(x)*(1/BigFloat(rawone(x)))
68-
convert{T<:FloatingPoint}(::Type{T}, x::Ufixed) = reinterpret(x)*(1/convert(T, rawone(x)))
68+
convert{T<:AbstractFloat}(::Type{T}, x::Ufixed) = reinterpret(x)*(1/convert(T, rawone(x)))
6969
convert(::Type{Bool}, x::Ufixed) = x == zero(x) ? false : true
7070
convert{T<:Integer}(::Type{T}, x::Ufixed) = convert(T, x*(1/one(T)))
7171
convert{Ti<:Integer}(::Type{Rational{Ti}}, x::Ufixed) = convert(Ti, reinterpret(x))//convert(Ti, rawone(x))
@@ -119,7 +119,7 @@ isfinite(x::Ufixed) = true
119119
isnan(x::Ufixed) = false
120120
isinf(x::Ufixed) = false
121121

122-
bswap{f}(x::UfixedBase{Uint8,f}) = x
122+
bswap{f}(x::UfixedBase{UInt8,f}) = x
123123
bswap(x::Ufixed) = typeof(x)(bswap(reinterpret(x)),0)
124124

125125
for f in (:div, :fld, :rem, :mod, :mod1, :rem1, :fld1, :min, :max)
@@ -157,7 +157,7 @@ for T in UF
157157
promote_rule(::Type{$T}, ::Type{Float64}) = Float64
158158
promote_rule{TR<:Rational}(::Type{$T}, ::Type{TR}) = TR
159159
end
160-
for Ti in (Int8, Uint8, Int16, Uint16, Int32, Uint32, Int64, Uint64)
160+
for Ti in (Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64)
161161
Tp = eps(convert(Float32, typemax(Ti))) > eps(T) ? Float64 : Float32
162162
@eval begin
163163
promote_rule(::Type{$T}, ::Type{$Ti}) = $Tp

test/ufixed.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ for T in FixedPointNumbers.UF
2626
@test sizeof(T) == 1 + (T != Ufixed8)
2727
end
2828
@test typemax(Ufixed8) == 1
29-
@test typemax(Ufixed10) == typemax(Uint16)//(2^10-1)
30-
@test typemax(Ufixed12) == typemax(Uint16)//(2^12-1)
31-
@test typemax(Ufixed14) == typemax(Uint16)//(2^14-1)
29+
@test typemax(Ufixed10) == typemax(UInt16)//(2^10-1)
30+
@test typemax(Ufixed12) == typemax(UInt16)//(2^12-1)
31+
@test typemax(Ufixed14) == typemax(UInt16)//(2^14-1)
3232
@test typemax(Ufixed16) == 1
33-
@test typemax(Ufixed10) == typemax(Uint16) // (2^10-1)
34-
@test typemax(Ufixed12) == typemax(Uint16) // (2^12-1)
35-
@test typemax(Ufixed14) == typemax(Uint16) // (2^14-1)
33+
@test typemax(Ufixed10) == typemax(UInt16) // (2^10-1)
34+
@test typemax(Ufixed12) == typemax(UInt16) // (2^12-1)
35+
@test typemax(Ufixed14) == typemax(UInt16) // (2^14-1)
3636

3737
x = Ufixed8(0.5)
3838
@test isfinite(x) == true
3939
@test isnan(x) == false
4040
@test isinf(x) == false
4141

42-
@test convert(Ufixed8, 1.1/typemax(Uint8)) == eps(Ufixed8)
43-
@test convert(Ufixed10, 1.1/typemax(Uint16)*64) == eps(Ufixed10)
44-
@test convert(Ufixed12, 1.1/typemax(Uint16)*16) == eps(Ufixed12)
45-
@test convert(Ufixed14, 1.1/typemax(Uint16)*4) == eps(Ufixed14)
46-
@test convert(Ufixed16, 1.1/typemax(Uint16)) == eps(Ufixed16)
42+
@test convert(Ufixed8, 1.1/typemax(UInt8)) == eps(Ufixed8)
43+
@test convert(Ufixed10, 1.1/typemax(UInt16)*64) == eps(Ufixed10)
44+
@test convert(Ufixed12, 1.1/typemax(UInt16)*16) == eps(Ufixed12)
45+
@test convert(Ufixed14, 1.1/typemax(UInt16)*4) == eps(Ufixed14)
46+
@test convert(Ufixed16, 1.1/typemax(UInt16)) == eps(Ufixed16)
4747

48-
@test convert(Ufixed8, 1.1f0/typemax(Uint8)) == eps(Ufixed8)
48+
@test convert(Ufixed8, 1.1f0/typemax(UInt8)) == eps(Ufixed8)
4949

50-
@test convert(Float64, eps(Ufixed8)) == 1/typemax(Uint8)
51-
@test convert(Float32, eps(Ufixed8)) == 1.0f0/typemax(Uint8)
52-
@test convert(BigFloat, eps(Ufixed8)) == BigFloat(1)/typemax(Uint8)
50+
@test convert(Float64, eps(Ufixed8)) == 1/typemax(UInt8)
51+
@test convert(Float32, eps(Ufixed8)) == 1.0f0/typemax(UInt8)
52+
@test convert(BigFloat, eps(Ufixed8)) == BigFloat(1)/typemax(UInt8)
5353
for T in FixedPointNumbers.UF
5454
@test convert(Bool, zero(T)) == false
5555
@test convert(Bool, one(T)) == true
@@ -123,7 +123,7 @@ function generic_scale!(C::AbstractArray, X::AbstractArray, s::Number)
123123
C
124124
end
125125

126-
a = rand(Uint8, 10)
126+
a = rand(UInt8, 10)
127127
rfloat = similar(a, Float32)
128128
rfixed = similar(rfloat)
129129
af8 = reinterpret(Ufixed8, a)

0 commit comments

Comments
 (0)