def __eq__(self, actual):
if _is_numpy_array(actual):<EOL><INDENT>return all(self.__eq__(a) for a in actual.flat)<EOL><DEDENT>if actual == self.expected:<EOL><INDENT>return True<EOL><DEDENT>if math.isnan(abs(self.expected)):<EOL><INDENT>return self.nan_ok and math.isnan(abs(actual))<EOL><DEDENT>if math.isinf(abs(self.expected)):<EOL><INDENT>return False<EOL><DEDENT>return abs(self.expected - actual) <= self.tolerance<EOL>
Return true if the given value is equal to the expected value within
the pre-specified tolerance.