Skip to content

delegate all comparison methods #399

@goretkin

Description

@goretkin

As pointed out in JuliaIntervals/IntervalArithmetic.jl#237 (comment)

the assumption at https://github.com/PainterQubits/Unitful.jl/blob/47d131be92eefae1b49cd02b0a9f9a55b74be97f/src/quantities.jl#L324

<=(x::AbstractQuantity, y::AbstractQuantity) = <(x,y) || x==y

might not hold. Take for instance

using IntervalArithmetic: IntervalArithmetic, interval
using Unitful: Unitful, m

a = interval(0, 0)
b = interval(0, 1)
@assert a <= b
@assert a*m <= b*m  # assertion failure here

and the reason why is:

julia> a <= b
true

julia> a < b
false

julia> a == b
false

It seems worthwhile to delegate all comparison methods, not only isless and <, at
https://github.com/PainterQubits/Unitful.jl/blob/47d131be92eefae1b49cd02b0a9f9a55b74be97f/src/quantities.jl#L263-L275

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions