MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / assertNear

Method assertNear

tensorflow/python/framework/test_util.py:2265–2280  ·  view source on GitHub ↗

Asserts that two floats are near each other. Checks that |f1 - f2| < err and asserts a test failure if not. Args: f1: A float value. f2: A float value. err: A float value. msg: An optional string message to append to the failure message.

(self, f1, f2, err, msg=None)

Source from the content-addressed store, hash-verified

2263 # pylint: enable=invalid-name
2264 @py_func_if_in_function
2265 def assertNear(self, f1, f2, err, msg=None):
2266 """Asserts that two floats are near each other.
2267
2268 Checks that |f1 - f2| < err and asserts a test failure
2269 if not.
2270
2271 Args:
2272 f1: A float value.
2273 f2: A float value.
2274 err: A float value.
2275 msg: An optional string message to append to the failure message.
2276 """
2277 # f1 == f2 is needed here as we might have: f1, f2 = inf, inf
2278 self.assertTrue(
2279 f1 == f2 or math.fabs(f1 - f2) <= err, "%f != %f +/- %f%s" %
2280 (f1, f2, err, " (%s)" % msg if msg is not None else ""))
2281
2282 @py_func_if_in_function
2283 def assertArrayNear(self, farray1, farray2, err, msg=None):

Callers 15

assertArrayNearMethod · 0.95
testWeightedMeanMethod · 0.80
testLargeCaseMethod · 0.80
test_fitMethod · 0.80
test_monitorMethod · 0.80
_infer_helperMethod · 0.80
_run_test_sum_weightsMethod · 0.80
test_evalMethod · 0.80
testTop2Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected