Less than approx equals? <≈

Oops, it’s already been merged, and the branch deleted. You can checkout the master branch or wait to the next patch release, probably tomorrow…

I quickly looked at the code for _leq in LazySets but I didn’t really understand it. Is it overloading from Base?

See this function, that I copy here for convenience:

function _leq(x::N, y::N;
              rtol::Real=_rtol(N),
              ztol::Real=_ztol(N),
              atol::Real=_atol(N)) where {N<:AbstractFloat}
    return x <= y || _isapprox(x, y, rtol=rtol, ztol=ztol, atol=atol)
end

It doesn’t overload functions from Base, it simply uses an internal _isapprox for approximate equality comparisons, with tolerances that can be set at once (globally) for all operations. Some problems require very small tolerances, for other problems you can work with bigger tolerances so it’s useful to be able to change everything with one command (like tests for disjointness, inclusion, membership, etc).

What are your thoughts about introducing a <≈ operator into Julia Base? Is it too specialized?

I think that’s not justified, the building blocks are already in Base, and the actual meaning of approximate <= depends a lot on the application (as suggested above).

1 Like