From 7ed33b7a886ac7f66794003aa2e40d9ad5aad81e Mon Sep 17 00:00:00 2001 From: liuhui29 Date: Wed, 21 Oct 2020 20:27:15 +0800 Subject: [PATCH] fix typo --- .../fluid/tests/unittests/test_reduce_op.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_reduce_op.py b/python/paddle/fluid/tests/unittests/test_reduce_op.py index dee9bd27c200f..fce028eeb8ec1 100644 --- a/python/paddle/fluid/tests/unittests/test_reduce_op.py +++ b/python/paddle/fluid/tests/unittests/test_reduce_op.py @@ -795,7 +795,9 @@ def test_dygraph(self): paddle.disable_static() for place in self.places: with fluid.dygraph.guard(place): - x = fluid.layers.assign(np.array([[1, 0], [1, 1]], dtype='int32')) + x = fluid.layers.assign( + np.array( + [[1, 0], [1, 1]], dtype='int32')) x = fluid.layers.cast(x, 'bool') out1 = paddle.all(x) @@ -825,7 +827,7 @@ def setUp(self): self.places = [fluid.CPUPlace()] if core.is_compiled_with_cuda(): self.places.append(fluid.CUDAPlace(0)) - + def check_static_result(self, place): paddle.disable_static() with fluid.program_guard(fluid.Program(), fluid.Program()): @@ -833,39 +835,41 @@ def check_static_result(self, place): result = paddle.inverse(x=input) input_np = np.random.random([4, 4]).astype("float64") result_np = np.linalg.inv(input_np) - + exe = fluid.Executor(place) fetches = exe.run(fluid.default_main_program(), feed={"input": input_np}, fetch_list=[result]) self.assertTrue(np.allclose(fetches[0], np.linalg.inv(input_np))) - + def test_static(self): for place in self.places: self.check_static_result(place=place) - + def test_dygraph(self): paddle.disable_static() for place in self.places: with fluid.dygraph.guard(place): - x = fluid.layers.assign(np.array([[1, 0], [1, 1]], dtype='int32')) + x = fluid.layers.assign( + np.array( + [[1, 0], [1, 1]], dtype='int32')) x = fluid.layers.cast(x, 'bool') - + out1 = paddle.any(x) res1 = fluid.layers.assign(np.array([1], dtype='int32')) res1 = fluid.layers.cast(res1, 'bool') self.assertTrue(out1, res1) - + out2 = paddle.any(x, axis=0) res2 = fluid.layers.assign(np.array([1, 0], dtype='int32')) res2 = fluid.layers.cast(res2, 'bool') self.assertTrue(out2, res2) - + out3 = paddle.any(x, axis=-1) res3 = fluid.layers.assign(np.array([1, 0], dtype='int32')) res3 = fluid.layers.cast(res3, 'bool') self.assertTrue(out3, res3) - + out4 = paddle.any(x, axis=1, keep_dim=True) res4 = fluid.layers.assign(np.array([[1, 0]], dtype='int32')) res4 = fluid.layers.cast(res4, 'bool')