Skip to content

Commit 3367582

Browse files
committed
Fix pylint errors
1 parent ed089da commit 3367582

27 files changed

+132
-122
lines changed

tensorflow_datasets/core/decode/base_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def decode_crop(serialized_image, feature):
6464
with tf.io.gfile.GFile(image_path, 'rb') as f:
6565
serialized_img = f.read()
6666

67-
self.assertFeature(
67+
self.assert_feature(
6868
# Image with statically defined shape
6969
feature=features_lib.Image(shape=(30, 60, 3), encoding_format='jpeg'),
7070
shape=(30, 60, 3),
@@ -98,7 +98,7 @@ def test_video_custom_decode(self):
9898
with tf.io.gfile.GFile(image_path, 'rb') as f:
9999
serialized_img = f.read()
100100

101-
self.assertFeature(
101+
self.assert_feature(
102102
# Image with statically defined shape
103103
feature=features_lib.Video(shape=(None, 30, 60, 3)),
104104
shape=(None, 30, 60, 3),
@@ -115,7 +115,7 @@ def test_video_custom_decode(self):
115115
)
116116

117117
# Test with FeatureDict
118-
self.assertFeature(
118+
self.assert_feature(
119119
feature=features_lib.FeaturesDict({
120120
'image': features_lib.Image(
121121
shape=(30, 60, 3), encoding_format='jpeg'),

tensorflow_datasets/core/download/kaggle_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ def test_competition_download(self):
4444

4545
def test_competition_download_404(self):
4646
with testing.mock_kaggle_api(err_msg="404 - Not found"):
47-
with self.assertLogs(
47+
with self.assert_logs(
4848
"spelled the competition name correctly", level="error"):
4949
downloader = kaggle.KaggleCompetitionDownloader("digit-recognizer")
5050
with self.assertRaises(subprocess.CalledProcessError):
5151
_ = downloader.competition_files
5252

5353
def test_competition_download_error(self):
5454
with testing.mock_kaggle_api(err_msg="Some error"):
55-
with self.assertLogs("install the kaggle API", level="error"):
55+
with self.assert_logs("install the kaggle API", level="error"):
5656
downloader = kaggle.KaggleCompetitionDownloader("digit-recognizer")
5757
with self.assertRaises(subprocess.CalledProcessError):
5858
_ = downloader.competition_files

tensorflow_datasets/core/example_serializer_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def assertRaggedFieldEqual(self, dict1, dict2):
3636
self.assertIsInstance(dict2, dict)
3737
self.assertEqual(set(dict1.keys()), set(dict2.keys()))
3838
for k, (field1, field2) in py_utils.zip_dict(dict1, dict2):
39-
with self._subTest(k):
39+
with self._sub_test(k):
4040
# Compare the example_data
4141
self.assertAllEqual(field1[0], field2[0])
4242
# Compare the tensor_info

tensorflow_datasets/core/features/audio_feature_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def create_np_audio(self):
4040
def test_numpy_array(self):
4141
np_audio = self.create_np_audio()
4242

43-
self.assertFeature(
43+
self.assert_feature(
4444
feature=features.Audio(),
4545
shape=(None,),
4646
dtype=tf.int64,
@@ -65,7 +65,7 @@ def test_wav_file(self):
6565
_, tmp_file = tempfile.mkstemp()
6666
self.write_wave_file(np_audio, tmp_file)
6767

68-
self.assertFeature(
68+
self.assert_feature(
6969
feature=features.Audio(file_format="wav"),
7070
shape=(None,),
7171
dtype=tf.int64,
@@ -85,7 +85,7 @@ def test_file_object(self):
8585
class GFileWithSeekOnRead(tf.io.gfile.GFile):
8686
"""Wrapper around GFile which is reusable across multiple read() calls.
8787
88-
This is needed because assertFeature reuses the same
88+
This is needed because assert_feature reuses the same
8989
FeatureExpectationItem several times.
9090
"""
9191

@@ -95,7 +95,7 @@ def read(self, *args, **kwargs):
9595
return data_read
9696

9797
with GFileWithSeekOnRead(tmp_file, "rb") as file_obj:
98-
self.assertFeature(
98+
self.assert_feature(
9999
feature=features.Audio(file_format="wav"),
100100
shape=(None,),
101101
dtype=tf.int64,

tensorflow_datasets/core/features/bounding_boxes_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BBoxFeatureTest(testing.FeatureExpectationsTestCase):
3131

3232
def test_feature(self):
3333

34-
self.assertFeature(
34+
self.assert_feature(
3535
feature=features.BBoxFeature(),
3636
shape=(4,),
3737
dtype=tf.float32,

tensorflow_datasets/core/features/class_label_feature_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class ClassLabelFeatureTest(testing.FeatureExpectationsTestCase):
3131

3232
def test_feature(self):
33-
self.assertFeature(
33+
self.assert_feature(
3434
feature=features.ClassLabel(num_classes=10),
3535
dtype=tf.int64,
3636
shape=(),
@@ -58,7 +58,7 @@ def test_feature(self):
5858

5959
def test_labels(self):
6060

61-
self.assertFeature(
61+
self.assert_feature(
6262
feature=features.ClassLabel(names=['left', 'right']),
6363
dtype=tf.int64,
6464
shape=(),

tensorflow_datasets/core/features/features_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_tensor_info(self):
9696

9797
def test_fdict(self):
9898

99-
self.assertFeature(
99+
self.assert_feature(
100100
feature=features_lib.FeaturesDict({
101101
'input': AnInputConnector(),
102102
'output': AnOutputConnector(),
@@ -239,7 +239,7 @@ def test_shape_static(self):
239239
[4, 5, 6],
240240
]
241241

242-
self.assertFeature(
242+
self.assert_feature(
243243
feature=features_lib.Tensor(shape=(2, 3), dtype=tf.float32),
244244
dtype=tf.float32,
245245
shape=(2, 3),
@@ -274,7 +274,7 @@ def test_shape_dynamic(self):
274274
np_input_dynamic_1 = np.random.randint(256, size=(2, 3, 2), dtype=np.int32)
275275
np_input_dynamic_2 = np.random.randint(256, size=(5, 3, 2), dtype=np.int32)
276276

277-
self.assertFeature(
277+
self.assert_feature(
278278
feature=features_lib.Tensor(shape=(None, 3, 2), dtype=tf.int32),
279279
dtype=tf.int32,
280280
shape=(None, 3, 2),
@@ -299,7 +299,7 @@ def test_shape_dynamic(self):
299299

300300
def test_bool_flat(self):
301301

302-
self.assertFeature(
302+
self.assert_feature(
303303
feature=features_lib.Tensor(shape=(), dtype=tf.bool),
304304
dtype=tf.bool,
305305
shape=(),
@@ -325,7 +325,7 @@ def test_bool_flat(self):
325325

326326
def test_bool_array(self):
327327

328-
self.assertFeature(
328+
self.assert_feature(
329329
feature=features_lib.Tensor(shape=(3,), dtype=tf.bool),
330330
dtype=tf.bool,
331331
shape=(3,),
@@ -345,7 +345,7 @@ def test_string(self):
345345
nonunicode_text = 'hello world'
346346
unicode_text = u'你好'
347347

348-
self.assertFeature(
348+
self.assert_feature(
349349
feature=features_lib.Tensor(shape=(), dtype=tf.string),
350350
shape=(),
351351
dtype=tf.string,
@@ -373,7 +373,7 @@ def test_string(self):
373373
],
374374
)
375375

376-
self.assertFeature(
376+
self.assert_feature(
377377
feature=features_lib.Tensor(shape=(2, 1), dtype=tf.string),
378378
shape=(2, 1),
379379
dtype=tf.string,

tensorflow_datasets/core/features/image_feature_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_images(self, dtype):
5151
if dtype == tf.uint16:
5252
img_file_expected_content *= 257 # Scale int16 images
5353

54-
self.assertFeature(
54+
self.assert_feature(
5555
feature=features_lib.Image(dtype=dtype),
5656
shape=(None, None, 3),
5757
dtype=dtype,
@@ -96,7 +96,7 @@ def test_image_shaped(self):
9696

9797
img_shaped = randint(256, size=(32, 64, 3), dtype=np.uint8)
9898

99-
self.assertFeature(
99+
self.assert_feature(
100100
# Image with statically defined shape
101101
feature=features_lib.Image(shape=(32, 64, 3)),
102102
shape=(32, 64, 3),

tensorflow_datasets/core/features/sequence_feature_test.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SequenceDictFeatureTest(testing.FeatureExpectationsTestCase):
3232

3333
def test_int(self):
3434

35-
self.assertFeature(
35+
self.assert_feature(
3636
feature=feature_lib.Sequence({'int': tf.int32}, length=3),
3737
shape={'int': (3,)},
3838
dtype={'int': tf.int32},
@@ -70,7 +70,7 @@ def test_int(self):
7070

7171
def test_label(self):
7272

73-
self.assertFeature(
73+
self.assert_feature(
7474
feature=feature_lib.Sequence({
7575
'label': feature_lib.ClassLabel(names=['left', 'right']),
7676
}, length=None),
@@ -99,7 +99,7 @@ def test_label(self):
9999

100100
def test_nested(self):
101101

102-
self.assertFeature(
102+
self.assert_feature(
103103
feature=feature_lib.Sequence({
104104
'a': tf.string,
105105
'b': {
@@ -218,10 +218,10 @@ def test_encoding(self):
218218
def to_ragged(ex):
219219
ex['a']['c'] = tf.ragged.constant(ex['a']['c'])
220220
return ex
221-
self.assertAllEqualNested(to_ragged(ex1), out)
222-
self.assertAllEqualNested(to_ragged(ex2), out)
223-
self.assertAllEqualNested(to_ragged(ex3), out)
224-
self.assertAllEqualNested(to_ragged(ex4), out)
221+
self.assert_all_equal_nested(to_ragged(ex1), out)
222+
self.assert_all_equal_nested(to_ragged(ex2), out)
223+
self.assert_all_equal_nested(to_ragged(ex3), out)
224+
self.assert_all_equal_nested(to_ragged(ex4), out)
225225

226226
# Should raise error if two sequences do not have the same length.
227227
with self.assertRaisesWithPredicateMatch(
@@ -233,14 +233,14 @@ def to_ragged(ex):
233233

234234
# Empty sequence should create the correct number of dimension
235235
ex2 = f.encode_example([])
236-
self.assertAllEqualNested(ex2, {
236+
self.assert_all_equal_nested(ex2, {
237237
'a': {'c': np.zeros((0, 0), np.int64)},
238238
'b': np.zeros((0,), np.int64),
239239
})
240240

241241
def test_2lvl_sequences_mixed(self):
242242
# Mix of sequence and non-sequence
243-
self.assertFeature(
243+
self.assert_feature(
244244
feature=feature_lib.Sequence({
245245
'a': feature_lib.Sequence(tf.int32),
246246
'b': tf.int32,
@@ -269,7 +269,7 @@ def test_2lvl_sequences_mixed(self):
269269

270270
def test_2lvl_sequences(self):
271271

272-
self.assertFeature(
272+
self.assert_feature(
273273
feature=feature_lib.Sequence(
274274
feature_lib.Sequence(
275275
feature_lib.Tensor(shape=(2,), dtype=tf.int32),
@@ -336,7 +336,7 @@ def test_2lvl_sequences(self):
336336

337337
def test_2lvl_sequences_string(self):
338338

339-
self.assertFeature(
339+
self.assert_feature(
340340
feature=feature_lib.Sequence(
341341
feature_lib.Sequence(tf.string),
342342
),
@@ -379,7 +379,7 @@ def test_2lvl_sequences_string(self):
379379

380380
def test_3lvl_sequence(self):
381381

382-
self.assertFeature(
382+
self.assert_feature(
383383
feature=feature_lib.Sequence(
384384
feature_lib.Sequence(
385385
feature_lib.Sequence(tf.int32),
@@ -420,7 +420,7 @@ def test_image(self):
420420
]
421421
imgs_stacked = np.stack(imgs)
422422

423-
self.assertFeature(
423+
self.assert_feature(
424424
feature=feature_lib.Sequence({
425425
'image': feature_lib.Image(shape=(128, 100, 3)),
426426
}, length=None),
@@ -458,7 +458,7 @@ class SequenceFeatureTest(testing.FeatureExpectationsTestCase):
458458

459459
def test_int(self):
460460

461-
self.assertFeature(
461+
self.assert_feature(
462462
feature=feature_lib.Sequence(tf.int32, length=3),
463463
shape=(3,),
464464
dtype=tf.int32,
@@ -484,7 +484,7 @@ def test_int(self):
484484

485485
def test_label(self):
486486

487-
self.assertFeature(
487+
self.assert_feature(
488488
feature=feature_lib.Sequence(
489489
feature_lib.ClassLabel(names=['left', 'right']),
490490
),

tensorflow_datasets/core/features/text_feature_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_text(self):
3535
nonunicode_text = 'hello world'
3636
unicode_text = u'你好'
3737

38-
self.assertFeature(
38+
self.assert_feature(
3939
feature=features.Text(),
4040
shape=(),
4141
dtype=tf.string,
@@ -62,7 +62,7 @@ def test_text_encoded(self):
6262
unicode_text = u'你好'
6363

6464
# Unicode integer-encoded by byte
65-
self.assertFeature(
65+
self.assert_feature(
6666
feature=features.Text(encoder=text_encoder.ByteTextEncoder()),
6767
shape=(None,),
6868
dtype=tf.int64,

tensorflow_datasets/core/features/translation_feature_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
class TranslationFeatureTest(testing.FeatureExpectationsTestCase):
4343

4444
def test_translation(self):
45-
self.assertFeature(
45+
self.assert_feature(
4646
feature=features.Translation(["en", "zh"]),
4747
shape={"en": (), "zh": ()},
4848
dtype={"en": tf.string, "zh": tf.string},
@@ -57,7 +57,7 @@ def test_translation(self):
5757

5858
def test_translation_encoded(self):
5959
# Unicode integer-encoded by byte
60-
self.assertFeature(
60+
self.assert_feature(
6161
feature=features.Translation(
6262
languages=["en", "zh"],
6363
encoder=text_encoder.ByteTextEncoder()),
@@ -77,7 +77,7 @@ def test_translation_encoded(self):
7777

7878
def test_translation_multiple_encoders(self):
7979
# Unicode integer-encoded by byte
80-
self.assertFeature(
80+
self.assert_feature(
8181
feature=features.Translation(
8282
languages=["en", "zh"],
8383
encoder=[text_encoder.TokenTextEncoder(["hello", " "]),
@@ -100,7 +100,7 @@ class TranslationVariableLanguagesFeatureTest(
100100
testing.FeatureExpectationsTestCase):
101101

102102
def test_translation_variable_languages_nolist(self):
103-
self.assertFeature(
103+
self.assert_feature(
104104
feature=features.TranslationVariableLanguages(),
105105
shape={"language": (None,), "translation": (None,)},
106106
dtype={"language": tf.string, "translation": tf.string},
@@ -130,7 +130,7 @@ def test_translation_variable_languages_nolist(self):
130130
)
131131

132132
def test_translation_variable_languages_list(self):
133-
self.assertFeature(
133+
self.assert_feature(
134134
feature=features.TranslationVariableLanguages(
135135
languages=["en", "de", "zh"]),
136136
shape={"language": (None,), "translation": (None,)},

0 commit comments

Comments
 (0)