Apply ruff flake8-comprehensions (#21694)
This commit is contained in:
@@ -386,7 +386,7 @@ def main():
|
||||
|
||||
# Model has labels -> use them.
|
||||
if model.config.label2id != PretrainedConfig(num_labels=num_labels).label2id:
|
||||
if list(sorted(model.config.label2id.keys())) == list(sorted(label_list)):
|
||||
if sorted(model.config.label2id.keys()) == sorted(label_list):
|
||||
# Reorganize `label_list` to match the ordering of the model.
|
||||
if labels_are_int:
|
||||
label_to_id = {i: int(model.config.label2id[l]) for i, l in enumerate(label_list)}
|
||||
@@ -397,8 +397,8 @@ def main():
|
||||
else:
|
||||
logger.warning(
|
||||
"Your model seems to have been trained with labels, but they don't match the dataset: ",
|
||||
f"model labels: {list(sorted(model.config.label2id.keys()))}, dataset labels:"
|
||||
f" {list(sorted(label_list))}.\nIgnoring the model labels as a result.",
|
||||
f"model labels: {sorted(model.config.label2id.keys())}, dataset labels:"
|
||||
f" {sorted(label_list)}.\nIgnoring the model labels as a result.",
|
||||
)
|
||||
|
||||
# Set the correspondences label/ID inside the model config
|
||||
|
||||
@@ -425,7 +425,7 @@ def main():
|
||||
|
||||
# Model has labels -> use them.
|
||||
if model.config.label2id != PretrainedConfig(num_labels=num_labels).label2id:
|
||||
if list(sorted(model.config.label2id.keys())) == list(sorted(label_list)):
|
||||
if sorted(model.config.label2id.keys()) == sorted(label_list):
|
||||
# Reorganize `label_list` to match the ordering of the model.
|
||||
if labels_are_int:
|
||||
label_to_id = {i: int(model.config.label2id[l]) for i, l in enumerate(label_list)}
|
||||
@@ -436,8 +436,8 @@ def main():
|
||||
else:
|
||||
logger.warning(
|
||||
"Your model seems to have been trained with labels, but they don't match the dataset: ",
|
||||
f"model labels: {list(sorted(model.config.label2id.keys()))}, dataset labels:"
|
||||
f" {list(sorted(label_list))}.\nIgnoring the model labels as a result.",
|
||||
f"model labels: {sorted(model.config.label2id.keys())}, dataset labels:"
|
||||
f" {sorted(label_list)}.\nIgnoring the model labels as a result.",
|
||||
)
|
||||
|
||||
# Set the correspondences label/ID inside the model config
|
||||
|
||||
Reference in New Issue
Block a user