From 04641f38374ba35cf71e5d487e55f2d936ad8114 Mon Sep 17 00:00:00 2001 From: ritualOne <963822768@qq.com> Date: Fri, 20 Jan 2023 15:29:39 +0800 Subject: [PATCH 1/2] moving two methods 'copy' and 'power' to test_backend_methods_2 --- tests/test_backends.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_backends.py b/tests/test_backends.py index 58daeb69..c2928b43 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -241,6 +241,16 @@ def test_backend_methods_2(backend): np.sinh(0.5 * tc.backend.ones([2])), atol=1e-5, ) + np.testing.assert_allclose( + tc.backend.sin(0.5*tc.backend.ones([2],dtype="float32")), + np.sin(0.5*tc.backend.ones([2])), + atol=1e-5, + ) + np.testing.assert_allclose( + tc.backend.cos(0.5*tc.backend.ones([2],dtype="float32")), + np.cos(0.5*tc.backend.ones([2])), + atol=1e-5, + ) np.testing.assert_allclose( tc.backend.eigvalsh(tc.backend.ones([2, 2])), np.array([0, 2]), atol=1e-5 ) @@ -273,6 +283,17 @@ def test_backend_methods_2(backend): tc.backend.arange(1, 5, 2), np.array([1, 3]), ) + arr = np.random.normal(size=(6, 6)) + np.testing.assert_allclose( + tc.backend.copy(arr), + arr, + atol=1e-5, + ) + np.testing.assert_allclose( + tc.backend.power(arr,6), + np.power(arr,6), + atol=1e-5 + ) assert tc.backend.dtype(tc.backend.ones([])) == "complex64" edges = [-1, 3.3, 9.1, 10.0] values = tc.backend.convert_to_tensor(np.array([0.0, 4.1, 12.0], dtype=np.float32)) From 9964ea7ecf6d1ffecb4f214f2f44b693a56c14ee Mon Sep 17 00:00:00 2001 From: ritualOne <963822768@qq.com> Date: Fri, 20 Jan 2023 19:02:21 +0800 Subject: [PATCH 2/2] two new methods with black check --- tests/test_backends.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/test_backends.py b/tests/test_backends.py index c2928b43..fc83b15f 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -242,13 +242,13 @@ def test_backend_methods_2(backend): atol=1e-5, ) np.testing.assert_allclose( - tc.backend.sin(0.5*tc.backend.ones([2],dtype="float32")), - np.sin(0.5*tc.backend.ones([2])), + tc.backend.sin(0.5 * tc.backend.ones([2], dtype="float32")), + np.sin(0.5 * tc.backend.ones([2])), atol=1e-5, ) np.testing.assert_allclose( - tc.backend.cos(0.5*tc.backend.ones([2],dtype="float32")), - np.cos(0.5*tc.backend.ones([2])), + tc.backend.cos(0.5 * tc.backend.ones([2], dtype="float32")), + np.cos(0.5 * tc.backend.ones([2])), atol=1e-5, ) np.testing.assert_allclose( @@ -289,11 +289,7 @@ def test_backend_methods_2(backend): arr, atol=1e-5, ) - np.testing.assert_allclose( - tc.backend.power(arr,6), - np.power(arr,6), - atol=1e-5 - ) + np.testing.assert_allclose(tc.backend.power(arr, 6), np.power(arr, 6), atol=1e-5) assert tc.backend.dtype(tc.backend.ones([])) == "complex64" edges = [-1, 3.3, 9.1, 10.0] values = tc.backend.convert_to_tensor(np.array([0.0, 4.1, 12.0], dtype=np.float32))