Update ruff to 0.11.2 (#36962)
* update * update * update --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -42,9 +42,9 @@ class TestFuyuImageProcessor(unittest.TestCase):
|
||||
expected_num_patches = self.processor.get_num_patches(image_height=self.height, image_width=self.width)
|
||||
|
||||
patches_final = self.processor.patchify_image(image=self.image_input)
|
||||
assert (
|
||||
patches_final.shape[1] == expected_num_patches
|
||||
), f"Expected {expected_num_patches} patches, got {patches_final.shape[1]}."
|
||||
assert patches_final.shape[1] == expected_num_patches, (
|
||||
f"Expected {expected_num_patches} patches, got {patches_final.shape[1]}."
|
||||
)
|
||||
|
||||
def test_scale_to_target_aspect_ratio(self):
|
||||
# (h:450, w:210) fitting (160, 320) -> (160, 210*160/450)
|
||||
|
||||
@@ -431,9 +431,9 @@ class GPT2ModelTester:
|
||||
model.eval()
|
||||
|
||||
# We want this for SDPA, eager works with a `None` attention mask
|
||||
assert (
|
||||
model.config._attn_implementation == "sdpa"
|
||||
), "This test assumes the model to have the SDPA implementation for its attention calculations."
|
||||
assert model.config._attn_implementation == "sdpa", (
|
||||
"This test assumes the model to have the SDPA implementation for its attention calculations."
|
||||
)
|
||||
|
||||
# Prepare cache and non_cache input, needs a full attention mask
|
||||
cached_len = input_ids.shape[-1] // 2
|
||||
|
||||
@@ -222,9 +222,9 @@ class GPTNeoXModelTester:
|
||||
model.eval()
|
||||
|
||||
# We want this for SDPA, eager works with a `None` attention mask
|
||||
assert (
|
||||
model.config._attn_implementation == "sdpa"
|
||||
), "This test assumes the model to have the SDPA implementation for its attention calculations."
|
||||
assert model.config._attn_implementation == "sdpa", (
|
||||
"This test assumes the model to have the SDPA implementation for its attention calculations."
|
||||
)
|
||||
|
||||
# Prepare cache and non_cache input, needs a full attention mask
|
||||
cached_len = input_ids.shape[-1] // 2
|
||||
|
||||
@@ -315,7 +315,7 @@ class Mask2FormerImageProcessingTest(ImageProcessingTestMixin, unittest.TestCase
|
||||
inst2class = {}
|
||||
for label in class_labels:
|
||||
instance_ids = np.unique(instance_seg[class_id_map == label])
|
||||
inst2class.update({i: label for i in instance_ids})
|
||||
inst2class.update(dict.fromkeys(instance_ids, label))
|
||||
|
||||
return instance_seg, inst2class
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ class MaskFormerImageProcessingTest(ImageProcessingTestMixin, unittest.TestCase)
|
||||
inst2class = {}
|
||||
for label in class_labels:
|
||||
instance_ids = np.unique(instance_seg[class_id_map == label])
|
||||
inst2class.update({i: label for i in instance_ids})
|
||||
inst2class.update(dict.fromkeys(instance_ids, label))
|
||||
|
||||
return instance_seg, inst2class
|
||||
|
||||
|
||||
@@ -1458,9 +1458,9 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase):
|
||||
|
||||
chunked_output = speech_recognizer(inputs.copy(), chunk_length_s=30)
|
||||
non_chunked_output = speech_recognizer(inputs.copy())
|
||||
assert (
|
||||
chunked_output.keys() == non_chunked_output.keys()
|
||||
), "The output structure should be the same for chunked vs non-chunked versions of asr pipelines."
|
||||
assert chunked_output.keys() == non_chunked_output.keys(), (
|
||||
"The output structure should be the same for chunked vs non-chunked versions of asr pipelines."
|
||||
)
|
||||
|
||||
@require_torch
|
||||
def test_return_timestamps_ctc_fast(self):
|
||||
|
||||
@@ -145,9 +145,9 @@ class DataTrainingArguments:
|
||||
train_extension = self.train_file.split(".")[-1]
|
||||
assert train_extension in ["csv", "json"], "`train_file` should be a csv or a json file."
|
||||
validation_extension = self.validation_file.split(".")[-1]
|
||||
assert (
|
||||
validation_extension == train_extension
|
||||
), "`validation_file` should have the same extension (csv or json) as `train_file`."
|
||||
assert validation_extension == train_extension, (
|
||||
"`validation_file` should have the same extension (csv or json) as `train_file`."
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -265,9 +265,9 @@ def main():
|
||||
if data_args.test_file is not None:
|
||||
train_extension = data_args.train_file.split(".")[-1]
|
||||
test_extension = data_args.test_file.split(".")[-1]
|
||||
assert (
|
||||
test_extension == train_extension
|
||||
), "`test_file` should have the same extension (csv or json) as `train_file`."
|
||||
assert test_extension == train_extension, (
|
||||
"`test_file` should have the same extension (csv or json) as `train_file`."
|
||||
)
|
||||
data_files["test"] = data_args.test_file
|
||||
else:
|
||||
raise ValueError("Need either a GLUE task or a test file for `do_predict`.")
|
||||
|
||||
@@ -3234,9 +3234,9 @@ class ModelTesterMixin:
|
||||
for model_class in self.all_model_classes:
|
||||
model = model_class(config)
|
||||
num_params = model.num_parameters()
|
||||
assert (
|
||||
num_params < 1000000
|
||||
), f"{model_class} is too big for the common tests ({num_params})! It should have 1M max."
|
||||
assert num_params < 1000000, (
|
||||
f"{model_class} is too big for the common tests ({num_params})! It should have 1M max."
|
||||
)
|
||||
|
||||
@require_flash_attn
|
||||
@require_torch_gpu
|
||||
|
||||
@@ -3005,9 +3005,9 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
|
||||
)
|
||||
trainer.train()
|
||||
# Check that we have the last known step:
|
||||
assert os.path.exists(
|
||||
os.path.join(tmp_dir, f"checkpoint-{trainer.state.max_steps}")
|
||||
), f"Could not find checkpoint-{trainer.state.max_steps}"
|
||||
assert os.path.exists(os.path.join(tmp_dir, f"checkpoint-{trainer.state.max_steps}")), (
|
||||
f"Could not find checkpoint-{trainer.state.max_steps}"
|
||||
)
|
||||
# And then check the last step
|
||||
assert os.path.exists(os.path.join(tmp_dir, "checkpoint-9")), "Could not find checkpoint-9"
|
||||
|
||||
|
||||
@@ -180,9 +180,9 @@ class Seq2seqTrainerTester(TestCasePlus):
|
||||
for num_return_sequences in range(3, 0, -1):
|
||||
gen_config.num_return_sequences = num_return_sequences
|
||||
metrics = trainer.evaluate(eval_dataset=prepared_dataset, generation_config=gen_config)
|
||||
assert (
|
||||
metrics["eval_samples"] == dataset_len * num_return_sequences
|
||||
), f"Got {metrics['eval_samples']}, expected: {dataset_len * num_return_sequences}"
|
||||
assert metrics["eval_samples"] == dataset_len * num_return_sequences, (
|
||||
f"Got {metrics['eval_samples']}, expected: {dataset_len * num_return_sequences}"
|
||||
)
|
||||
|
||||
@require_torch
|
||||
def test_bad_generation_config_fail_early(self):
|
||||
|
||||
Reference in New Issue
Block a user