Skip to content

Commit

Permalink
Merge pull request #3423 from flairNLP/pin-black-ruff
Browse files Browse the repository at this point in the history
ci: fix black and ruff
  • Loading branch information
alanakbik authored Mar 25, 2024
2 parents 595d94a + 04cd227 commit cf229c9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
4 changes: 1 addition & 3 deletions flair/embeddings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def forward(self, tensors: List[torch.Tensor]) -> torch.Tensor:
"""
if len(tensors) != self.mixture_size:
log.error(
"{} tensors were passed, but the module was initialized to mix {} tensors.".format(
len(tensors), self.mixture_size
)
f"{len(tensors)} tensors were passed, but the module was initialized to mix {self.mixture_size} tensors."
)

normed_weights = torch.nn.functional.softmax(torch.cat(list(self.scalar_parameters)), dim=0)
Expand Down
4 changes: 1 addition & 3 deletions flair/models/pairwise_regression_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ def evaluate(

if out_path is not None:
for pair, prediction, true_value in zip(batch, results, true_values):
eval_line = "{}\t{}\t{}\t{}\n".format(
pair.first.to_original_text(), pair.second.to_original_text(), true_value, prediction
)
eval_line = f"{pair.first.to_original_text()}\t{pair.second.to_original_text()}\t{true_value}\t{prediction}\n"
out_file.write(eval_line)

store_embeddings(batch, embedding_storage_mode)
Expand Down
7 changes: 1 addition & 6 deletions flair/training_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ def to_empty_tsv():
return "\t_\t_\t_\t_"

def __str__(self) -> str:
line = "mean squared error: {:.4f} - mean absolute error: {:.4f} - pearson: {:.4f} - spearman: {:.4f}".format(
self.mean_squared_error(),
self.mean_absolute_error(),
self.pearsonr(),
self.spearmanr(),
)
line = f"mean squared error: {self.mean_squared_error():.4f} - mean absolute error: {self.mean_absolute_error():.4f} - pearson: {self.pearsonr():.4f} - spearman: {self.spearmanr():.4f}"
return line


Expand Down
9 changes: 5 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
black[jupyter]>=23.3.0
black[jupyter]==24.2.*
konoha[janome]<6.0.0
mypy>=1.2.0
pytest>=7.3.1
pytest-black-ng>=0.4.1
pytest-black-ng==0.4.*
pytest-github-actions-annotate-failures>=0.1.8
pytest-mypy>=0.10.3
pytest-ruff>=0.0.5
pytest-ruff==0.3.*
ruff==0.3.*
types-dataclasses>=0.6.6
types-Deprecated>=1.2.9.2
types-requests>=2.28.11.17
types-tabulate>=0.9.0.2
types-tabulate>=0.9.0.2

0 comments on commit cf229c9

Please sign in to comment.