MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / equalWithAbsError

Function equalWithAbsError

src/python/PyImathTest/pyImathTest.py:102–110  ·  view source on GitHub ↗
(x1, x2, e)

Source from the content-addressed store, hash-verified

100# between vector and scalar types for our purposes here
101
102def equalWithAbsError(x1, x2, e):
103 if hasattr(x1, '__len__') and hasattr(x1, '__getitem__') and hasattr(x2, '__len__') and hasattr(x2, '__getitem__'):
104 assert(len(x1) == len(x2))
105 for i in range(0, len(x1)):
106 if not equalWithAbsErrorScalar(x1[i], x2[i], e):
107 return False
108 return True
109 else:
110 return equalWithAbsErrorScalar(x1, x2, e)
111
112def equalWithRelErrorScalar(x1, x2, e):
113 return abs(x1 - x2) <= e * abs(x1)

Calls 2

lenFunction · 0.85
equalWithAbsErrorScalarFunction · 0.70

Tested by

no test coverage detected