You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would basically be for matching on floats when precision isn't controlled, although theoretically it'll work on any type that implements subtraction and abs():
classNearly(object):
"""Within a certain threshold."""def__init__(self, expected, epsilon=0.001):
self.expected=expectedself.epsilon=epsilondef__str__(self):
return'Nearly(%r, %r)'% (self.expected, self.epsilon)
defmatch(self, value):
ifabs(value-self.expected) >self.epsilon:
returnMismatch(
u'%r more than %r from %r'% (
value, self.epsilon, self.expected))
The text was updated successfully, but these errors were encountered:
This would basically be for matching on floats when precision isn't controlled, although theoretically it'll work on any type that implements subtraction and abs():
The text was updated successfully, but these errors were encountered: