Skip to content

Commit e6cacf6

Browse files
committed
Fix promotion
1 parent 9702aab commit e6cacf6

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/math.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ end
4444
Base.:-(l::UnionAbstractQuantity) = new_quantity(typeof(l), -ustrip(l), dimension(l))
4545

4646
# Combining different abstract types
47-
for op in (:*, :/, :+, :-, :div),
47+
for op in (:*, :/, :+, :-, :div, :atan, :atand, :copysign, :flipsign, :mod),
4848
(t1, _, _) in ABSTRACT_QUANTITY_TYPES,
4949
(t2, _, _) in ABSTRACT_QUANTITY_TYPES
5050

@@ -126,7 +126,6 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES, f in (:atan, :atand)
126126
end
127127
function Base.$f(y::$type, x::$type)
128128
dimension(y) == dimension(x) || throw(DimensionError(y, x))
129-
y, x = promote(y, x)
130129
return $f(ustrip(y), ustrip(x))
131130
end
132131
function Base.$f(y::$type, x::$base_type)
@@ -143,8 +142,8 @@ end
143142

144143
############################## Same dimension as input ##################################
145144
for f in (
146-
:abs, :real, :imag, :conj, :adjoint, :unsigned, :nextfloat, :prevfloat,
147-
:identity, :transpose,
145+
:float, :abs, :real, :imag, :conj, :adjoint, :unsigned,
146+
:nextfloat, :prevfloat, :identity, :transpose,
148147
)
149148
@eval function Base.$f(q::UnionAbstractQuantity)
150149
return new_quantity(typeof(q), $f(ustrip(q)), dimension(q))

src/utils.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ end
2525
return output
2626
end
2727

28-
Base.float(q::UnionAbstractQuantity) = new_quantity(typeof(q), float(ustrip(q)), dimension(q))
2928
Base.convert(::Type{Number}, q::AbstractQuantity) = q
3029
function Base.convert(::Type{T}, q::UnionAbstractQuantity) where {T<:Number}
3130
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."

0 commit comments

Comments
 (0)