MCPcopy Create free account
hub / github.com/apple/axlearn / assertNestedEqual

Method assertNestedEqual

axlearn/common/test_utils.py:264–275  ·  view source on GitHub ↗
(self, a, b)

Source from the content-addressed store, hash-verified

262 self.assertAlmostEqual(a_value, b_value, msg=f"{a_name}")
263
264 def assertNestedEqual(self, a, b):
265 a_kv = flatten_items(a)
266 b_kv = flatten_items(b)
267 self.assertCountEqual([k for k, _ in a_kv], [k for k, _ in b_kv])
268 a_dict = dict(a_kv)
269 b_dict = dict(b_kv)
270 for k in a_dict:
271 a_value = a_dict[k]
272 b_value = b_dict[k]
273 np.testing.assert_array_equal(a_value, b_value, err_msg=k)
274 if hasattr(a_value, "dtype"):
275 self.assertEqual(a_value.dtype, b_value.dtype)
276
277 def assertAllCloseWithOutliers(self, actual, desired, *, tolerance_map: dict[float, Tolerance]):
278 """Like np.testing.assert_allclose, but allows outlier percentiles to be specified.

Calls 1

flatten_itemsFunction · 0.90

Tested by

no test coverage detected