We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 49623e0 commit 0a748c7Copy full SHA for 0a748c7
src/quantities.jl
@@ -274,6 +274,9 @@ for (i,j) in zip((:<, :isless), (:_lt, :_isless))
274
@eval @inline ($j)(x::AbstractQuantity{T,D,U}, y::AbstractQuantity{T,D,U}) where {T,D,U} = ($i)(x.val,y.val)
275
@eval @inline ($j)(x::AbstractQuantity{T,D,U1}, y::AbstractQuantity{T,D,U2}) where {T,D,U1,U2} = ($i)(promote(x,y)...)
276
@eval @inline ($j)(x::AbstractQuantity{T,D1,U1}, y::AbstractQuantity{T,D2,U2}) where {T,D1,D2,U1,U2} = throw(DimensionError(x,y))
277
+
278
+ @eval @inline ($j)(x::DimensionlessQuantity{T,FreeUnits{(),NoDims,nothing}}, y::ScalarQuantity{T,D,U}) where {T,D,U} = iszero(x) ? ($i)(x.val,y.val) : throw(DimensionError(x,y))
279
+ @eval @inline ($j)(x::ScalarQuantity{T,D,U}, y::DimensionlessQuantity{T,FreeUnits{(),NoDims,nothing}}) where {T,D,U} = iszero(y) ? ($i)(x.val,y.val) : throw(DimensionError(x,y))
280
end
281
282
Base.rtoldefault(::Type{<:AbstractQuantity{T,D,U}}) where {T,D,U} = Base.rtoldefault(T)
test/runtests.jl
@@ -565,10 +565,13 @@ Base.:*(x::MatNum, y::MatNum) = MatNum(x.mat*y.mat)
565
@test @inferred(1 > 1μm/m)
566
@test @inferred(1μm/m < 1mm/m)
567
@test @inferred(1mm/m > 1μm/m)
568
+ @test @inferred(0 < 2m)
569
+ @test !@inferred(2mm < 0)
570
@test_throws DimensionError 1m < 1kg
571
@test_throws DimensionError 1m < 1
572
@test_throws DimensionError 1 < 1m
573
@test_throws DimensionError 1mm/m < 1m
574
+ @test_throws DimensionError 0 < 100°C
575
@test Base.rtoldefault(typeof(1.0u"m")) === Base.rtoldefault(typeof(1.0))
576
@test Base.rtoldefault(typeof(1u"m")) === Base.rtoldefault(Int)
577
0 commit comments