Skip to content

Commit

Permalink
update unittests, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Shixiaowei02 committed Oct 29, 2020
1 parent 5e206bc commit 51cae84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,8 @@ def test(self):
self._test_feed_lod_tensor(use_cuda, use_parallel_executor)

# Test exception message when feeding with error
if six.PY2:
in_shape_tuple = (long(-1), long(3), long(4), long(8))
error_shape_list = [
long(self.data_batch_size), long(3), long(4), long(5)
]
else:
in_shape_tuple = (-1, 3, 4, 8)
error_shape_list = [self.data_batch_size, 3, 4, 5]
in_shape_tuple = (-1, 3, 4, 8)
error_shape_list = [self.data_batch_size, 3, 4, 5]

with self.assertRaises(ValueError) as shape_mismatch_err:
self._test_feed_data_shape_mismatch(use_cuda,
Expand Down
27 changes: 3 additions & 24 deletions python/paddle/fluid/tests/unittests/test_var_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,7 @@ def test_tensor_str(self):
paddle.set_printoptions(4, 100, 3)
a_str = str(a)

if six.PY2:
expected = '''Tensor(shape=[10L, 20L], dtype=float32, place=CPUPlace, stop_gradient=True,
[[0.2727, 0.5489, 0.8655, ..., 0.2916, 0.8525, 0.9000],
[0.3806, 0.8996, 0.0928, ..., 0.9535, 0.8378, 0.6409],
[0.1484, 0.4038, 0.8294, ..., 0.0148, 0.6520, 0.4250],
...,
[0.3426, 0.1909, 0.7240, ..., 0.4218, 0.2676, 0.5679],
[0.5561, 0.2081, 0.0676, ..., 0.9778, 0.3302, 0.9559],
[0.2665, 0.8483, 0.5389, ..., 0.4956, 0.6862, 0.9178]])'''

else:
expected = '''Tensor(shape=[10, 20], dtype=float32, place=CPUPlace, stop_gradient=True,
expected = '''Tensor(shape=[10, 20], dtype=float32, place=CPUPlace, stop_gradient=True,
[[0.2727, 0.5489, 0.8655, ..., 0.2916, 0.8525, 0.9000],
[0.3806, 0.8996, 0.0928, ..., 0.9535, 0.8378, 0.6409],
[0.1484, 0.4038, 0.8294, ..., 0.0148, 0.6520, 0.4250],
Expand All @@ -458,12 +447,7 @@ def test_tensor_str2(self):
a = paddle.to_tensor([[1.5111111, 1.0], [0, 0]])
a_str = str(a)

if six.PY2:
expected = '''Tensor(shape=[2L, 2L], dtype=float32, place=CPUPlace, stop_gradient=True,
[[1.5111, 1. ],
[0. , 0. ]])'''
else:
expected = '''Tensor(shape=[2, 2], dtype=float32, place=CPUPlace, stop_gradient=True,
expected = '''Tensor(shape=[2, 2], dtype=float32, place=CPUPlace, stop_gradient=True,
[[1.5111, 1. ],
[0. , 0. ]])'''

Expand All @@ -475,12 +459,7 @@ def test_tensor_str3(self):
a = paddle.to_tensor([[-1.5111111, 1.0], [0, -0.5]])
a_str = str(a)

if six.PY2:
expected = '''Tensor(shape=[2L, 2L], dtype=float32, place=CPUPlace, stop_gradient=True,
[[-1.5111, 1. ],
[ 0. , -0.5000]])'''
else:
expected = '''Tensor(shape=[2, 2], dtype=float32, place=CPUPlace, stop_gradient=True,
expected = '''Tensor(shape=[2, 2], dtype=float32, place=CPUPlace, stop_gradient=True,
[[-1.5111, 1. ],
[ 0. , -0.5000]])'''

Expand Down

0 comments on commit 51cae84

Please sign in to comment.