Skip to content

Commit

Permalink
feat(test): modified assert_same_type to use nested_multi_map
Browse files Browse the repository at this point in the history
  • Loading branch information
sherry30 committed Sep 15, 2023
1 parent a5da9e1 commit f482c18
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ivy_tests/test_ivy/helpers/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f482c18

Please sign in to comment.