Apply several ruff SIM rules (#37283)
* Apply ruff SIM118 fix Signed-off-by: cyy <cyyever@outlook.com> * Apply ruff SIM910 fix Signed-off-by: cyy <cyyever@outlook.com> * Apply ruff SIM101 fix Signed-off-by: cyy <cyyever@outlook.com> * Format code Signed-off-by: cyy <cyyever@outlook.com> * More fixes Signed-off-by: cyy <cyyever@outlook.com> --------- Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -116,7 +116,7 @@ class Gemma3nProcessorTest(unittest.TestCase):
|
||||
input_image_processor = image_processor(raw_image, return_tensors="pt")
|
||||
input_processor = processor(text="Describe:", images=raw_image, return_tensors="pt")
|
||||
|
||||
for key in input_image_processor.keys():
|
||||
for key in input_image_processor:
|
||||
self.assertAlmostEqual(input_image_processor[key].sum(), input_processor[key].sum(), delta=1e-2)
|
||||
if "pixel_values" in key:
|
||||
# NOTE: all images should be re-scaled to 768x768
|
||||
@@ -135,7 +135,7 @@ class Gemma3nProcessorTest(unittest.TestCase):
|
||||
input_feat_extract = feature_extractor(raw_speech, return_tensors="pt")
|
||||
input_processor = processor(text="Transcribe:", audio=raw_speech, return_tensors="pt")
|
||||
|
||||
for key in input_feat_extract.keys():
|
||||
for key in input_feat_extract:
|
||||
self.assertAlmostEqual(input_feat_extract[key].sum(), input_processor[key].sum(), delta=1e-2)
|
||||
|
||||
def test_tokenizer(self):
|
||||
@@ -152,7 +152,7 @@ class Gemma3nProcessorTest(unittest.TestCase):
|
||||
|
||||
encoded_tok = tokenizer(input_str)
|
||||
|
||||
for key in encoded_tok.keys():
|
||||
for key in encoded_tok:
|
||||
self.assertListEqual(encoded_tok[key], encoded_processor[key][0])
|
||||
|
||||
def test_tokenizer_decode(self):
|
||||
|
||||
Reference in New Issue
Block a user