Skip to content

Commit 0fcc5d0

Browse files
committed
Reduce div definition to clean up ambiguities
1 parent 08c0398 commit 0fcc5d0

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

src/disambiguities.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,3 @@ Base.:*(l::AbstractDimensions, r::Number) = error("Please use an `UnionAbstractQ
1212
Base.:*(l::Number, r::AbstractDimensions) = error("Please use an `UnionAbstractQuantity` for multiplication. You used multiplication on types: $(typeof(l)) and $(typeof(r)).")
1313
Base.:/(l::AbstractDimensions, r::Number) = error("Please use an `UnionAbstractQuantity` for division. You used division on types: $(typeof(l)) and $(typeof(r)).")
1414
Base.:/(l::Number, r::AbstractDimensions) = error("Please use an `UnionAbstractQuantity` for division. You used division on types: $(typeof(l)) and $(typeof(r)).")
15-
16-
if VERSION < v"1.7"
17-
@eval function Base.div(x::DynamicQuantities.AbstractGenericQuantity{T}, y::T) where {T}
18-
return new_quantity(typeof(x), div(ustrip(x), y), dimension(x))
19-
end
20-
end

src/math.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
66

77
Base.:*(l::$type, r::$base_type) = new_quantity(typeof(l), ustrip(l) * r, dimension(l))
88
Base.:/(l::$type, r::$base_type) = new_quantity(typeof(l), ustrip(l) / r, dimension(l))
9-
Base.div(x::$type, y::$base_type, r::RoundingMode=RoundToZero) = new_quantity(typeof(x), div(ustrip(x), y, r), dimension(x))
9+
Base.div(x::$type, y::Number, r::RoundingMode=RoundToZero) = new_quantity(typeof(x), div(ustrip(x), y, r), dimension(x))
1010

1111
Base.:*(l::$base_type, r::$type) = new_quantity(typeof(r), l * ustrip(r), dimension(r))
1212
Base.:/(l::$base_type, r::$type) = new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
13-
Base.div(x::$base_type, y::$type, r::RoundingMode=RoundToZero) = new_quantity(typeof(y), div(x, ustrip(y), r), inv(dimension(y)))
13+
Base.div(x::Number, y::$type, r::RoundingMode=RoundToZero) = new_quantity(typeof(y), div(x, ustrip(y), r), inv(dimension(y)))
1414

1515
Base.:*(l::$type, r::AbstractDimensions) = new_quantity(typeof(l), ustrip(l), dimension(l) * r)
1616
Base.:/(l::$type, r::AbstractDimensions) = new_quantity(typeof(l), ustrip(l), dimension(l) / r)

test/unittests.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -757,16 +757,6 @@ end
757757
y = x ^ (3//2)
758758
@test y == Quantity(1.0, length=3//2)
759759
@test typeof(y) == Quantity{Float64,DEFAULT_DIM_TYPE}
760-
761-
VERSION < v"1.7" && for I in (Int64, UInt64)
762-
x = GenericQuantity{I}(1u"km/s")
763-
a = (
764-
I <: Signed ?
765-
Base.MultiplicativeInverses.SignedMultiplicativeInverse :
766-
Base.MultiplicativeInverses.UnsignedMultiplicativeInverse
767-
)(I(3))
768-
@test div(x, a) == GenericQuantity{I}(333u"m/s")
769-
end
770760
end
771761

772762
for Q in (Quantity, GenericQuantity)

0 commit comments

Comments
 (0)