Skip to content

Cannot compare equality of two ApproxSequencelike objects #8866

Discussion options

You must be logged in to vote

approx() is meant to be thought of as the reference value in a comparison, so I don't think it really makes sense to compare two approx instances to each other. For example, it's not clear whether the following should be True or False:

# The left operand is approximately close to 11, but the 
# right operand is not approximately close to 10...
approx(10, abs=2) == approx(11, abs=0.2)

If you actually try making this comparison, you'll find that the result depends on the order of the operands:

>>> approx(10, abs=2) == approx(11, abs=0.2)
False
>>> approx(11, abs=0.2) == approx(10, abs=2)
True

My opinion is that comparisons like this should probably be errors. Even if they aren't (yet), I wo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@benjaminhwilliams
Comment options

Answer selected by benjaminhwilliams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants