Skip to content

Commit 6a8aee8

Browse files
authored
Merge pull request #98 from JuliaMath/teh/promotion_fix
Fixes for 0.7
2 parents c238d42 + 1462341 commit 6a8aee8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/FixedPointNumbers.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Base: ==, <, <=, -, +, *, /, ~, isapprox,
1010
zero, oneunit, one, typemin, typemax, realmin, realmax, eps, sizeof, reinterpret,
1111
float, trunc, round, floor, ceil, bswap,
1212
div, fld, rem, mod, mod1, fld1, min, max, minmax,
13-
start, next, done, r_promote, reducedim_init, rand
13+
start, next, done, reducedim_init, rand
1414
if isdefined(Base, :rem1)
1515
import Base: rem1
1616
end
@@ -133,8 +133,12 @@ sizeof(::Type{T}) where {T <: FixedPoint} = sizeof(rawtype(T))
133133

134134
# Promotions for reductions
135135
const Treduce = Float64
136-
r_promote(::typeof(+), x::FixedPoint{T}) where {T} = Treduce(x)
137-
r_promote(::typeof(*), x::FixedPoint{T}) where {T} = Treduce(x)
136+
if isdefined(Base, :r_promote)
137+
Base.r_promote(::typeof(+), x::FixedPoint{T}) where {T} = Treduce(x)
138+
Base.r_promote(::typeof(*), x::FixedPoint{T}) where {T} = Treduce(x)
139+
else
140+
Base.promote_sys_size(::Type{<:FixedPoint}) = Treduce
141+
end
138142

139143
reducedim_init(f::typeof(identity),
140144
op::typeof(+),

test/fixed.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ for T in (Fixed{Int8,8}, Fixed{Int16,8}, Fixed{Int16,10}, Fixed{Int32,16})
124124
a = rand(T)
125125
@test isa(a, T)
126126
a = rand(T, (3, 5))
127-
@test isa(a, Array{T,2})
127+
@test ndims(a) == 2 && eltype(a) == T
128128
@test size(a) == (3,5)
129129
end
130130

test/normed.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ for T in (Normed{UInt8,8}, Normed{UInt8,6},
297297
a = rand(T)
298298
@test isa(a, T)
299299
a = rand(T, (3, 5))
300-
@test isa(a, Array{T,2})
300+
@test ndims(a) == 2 && eltype(a) == T
301301
@test size(a) == (3,5)
302302
end
303303

0 commit comments

Comments
 (0)