Skip to content

Commit

Permalink
fix check_output type bug (PaddlePaddle#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
joey12300 authored Mar 31, 2021
1 parent c232e2c commit 5135439
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions tests/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def _check_output_impl(self,
msg=error_msg.format(paddle.get_device(),
expected_result.shape, result.shape,
self.__class__.__name__))
else:
raise ValueError(
'result type must be str, int, bool, set, np.bool, np.int32, '
'np.int64, np.str, float, np.ndarray, np.float32, np.float64')

def check_output_equal(self,
result,
Expand Down
3 changes: 2 additions & 1 deletion tests/data/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def test_iter2(self):
def test_list(self):
train_batch_sampler = SamplerHelper(self.train_ds)
list_sampler = train_batch_sampler.list()
self.check_output_equal(type(iter(list_sampler)), "listiterator")
self.check_output_equal(
type(iter(list_sampler)).__name__, "list_iterator")
for i, sample in enumerate(list_sampler):
self.check_output_equal(i, sample)

Expand Down
4 changes: 1 addition & 3 deletions tests/transformers/bigbird/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def setUp(self):
'bigbird-base-uncased']
self.config['num_layers'] = 2
self.config['vocab_size'] = 1024
self.config['vocab_size'] = 1024
self.config['attn_dropout'] = 0.0
self.config['hidden_dropout_prob'] = 0.0
self.config['dim_feedforward'] = 1024
Expand All @@ -115,7 +114,7 @@ def test_forward(self):
expected_output = np.array(
[[0.38314182, -0.13412490], [0.32075390, 0.07187212]])

self.check_output_equal(output, expected_output)
self.check_output_equal(output.numpy(), expected_output)


class TestBigBirdForPretraining(CommonTest):
Expand All @@ -124,7 +123,6 @@ def setUp(self):
'bigbird-base-uncased']
self.config['num_layers'] = 2
self.config['vocab_size'] = 1024
self.config['vocab_size'] = 1024
self.config['attn_dropout'] = 0.0
self.config['hidden_dropout_prob'] = 0.0
self.config['dim_feedforward'] = 1024
Expand Down
2 changes: 1 addition & 1 deletion tests/transformers/bigbird/test_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def setUp(self):

def test_empty_text(self):
ids = self.tokenizer('')
self.check_output_equal(ids, [])
self.check_output_equal(ids == [], True)

def test_bytes(self):
byte_text = 'An extremely powerful film that certainly isnt '\
Expand Down

0 comments on commit 5135439

Please sign in to comment.