Skip to content

Commit e0a85fa

Browse files
committed
add unit test for atan2
1 parent 85bca92 commit e0a85fa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_backend.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,6 +3352,20 @@ def func(base_matrix, diag, k):
33523352

33533353
self._run_test_case(func, [_OUTPUT], {_INPUT: input_val, _INPUT1: diag_val, _INPUT2: k_val})
33543354

3355+
@check_opset_min_version(7, "atan2")
3356+
def test_atan2(self):
3357+
# Test all possible pairs of pos, neg, zero for x and y.
3358+
test_pairs = [[y, x] for y in [3., -4., 0.] for x in [5., -6., 0.]]
3359+
y_val = np.array([y for y, x in test_pairs], dtype=np.float32)
3360+
x_val = np.array([x for y, x in test_pairs], dtype=np.float32)
3361+
3362+
def func(y, x):
3363+
atan2_ = tf.math.atan2(y, x)
3364+
return tf.identity(atan2_, name=_TFOUTPUT)
3365+
3366+
self._run_test_case(
3367+
func, [_OUTPUT], {_INPUT: y_val, _INPUT2: x_val}, rtol=1e-06)
3368+
33553369

33563370
if __name__ == '__main__':
33573371
unittest_main()

0 commit comments

Comments
 (0)