From f482c18bec1041205abf546c2359ebf45b7b6f32 Mon Sep 17 00:00:00 2001 From: Shehryar Tariq Date: Fri, 15 Sep 2023 22:04:48 +0500 Subject: [PATCH] feat(test): modified `assert_same_type` to use `nested_multi_map` --- ivy_tests/test_ivy/helpers/assertions.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ivy_tests/test_ivy/helpers/assertions.py b/ivy_tests/test_ivy/helpers/assertions.py index a08d20bb1f678..981f6d02cc287 100644 --- a/ivy_tests/test_ivy/helpers/assertions.py +++ b/ivy_tests/test_ivy/helpers/assertions.py @@ -92,13 +92,18 @@ def assert_same_type(ret_from_target, ret_from_gt, backend_to_test, gt_backend): checks with a string comparison because with_backend returns different objects. Doesn't check recursively. """ - # ToDo: do this with nested map - assert_msg = ( - f"ground truth backend ({gt_backend}) returned" - f" {type(ret_from_gt)} but target backend ({backend_to_test}) returned" - f" {type(ret_from_target)}" + + def _assert_same_type(x, y): + assert_msg = ( + f"ground truth backend ({gt_backend}) returned" + f" {type(y)} but target backend ({backend_to_test}) returned" + f" {type(x)}" + ) + assert str(type(x)) == str(type(y)), assert_msg + + ivy.nested_multi_map( + lambda x, _: _assert_same_type(x[0], x[1]), [ret_from_target, ret_from_gt] ) - assert str(type(ret_from_target)) == str(type(ret_from_gt)), assert_msg def value_test(