GH-3070: Fix inconsistency between best path and scores in ViterbiDecoder #1980
Annotations
10 errors
test:
flair/__init__.py#L1
mypy-status
mypy exited with status 1.
|
test:
flair/optim.py#L1
flair/optim.py
6: error: Unused "type: ignore" comment [unused-ignore]
|
test:
flair/datasets/base.py#L341
ruff
pytest_ruff.RuffError: flair/datasets/base.py:159:13: PIE790 [*] Unnecessary `pass` statement
|
157 | log.warning('To use MongoDataset, please first install with "pip install pymongo"')
158 | log.warning("-" * 100)
159 | pass
| ^^^^ PIE790
160 |
161 | self.in_memory = in_memory
|
= help: Remove unnecessary `pass`
|
test:
flair/datasets/biomedical.py#L341
ruff
pytest_ruff.RuffError: flair/datasets/biomedical.py:135:17: PIE790 [*] Unnecessary `pass` statement
|
133 | else:
134 | logging.debug(f"Skip entity type {entity.type}")
135 | pass
| ^^^^ PIE790
136 | mapped_entities_per_document[id] = new_entities
|
= help: Remove unnecessary `pass`
|
test:
flair/embeddings/document.py#L341
ruff
pytest_ruff.RuffError: flair/embeddings/document.py:559:13: PIE790 [*] Unnecessary `pass` statement
|
557 | log.warning('To use Sentence Transformers, please first install with "pip install sentence-transformers"')
558 | log.warning("-" * 100)
559 | pass
| ^^^^ PIE790
560 |
561 | self.model_name = model
|
= help: Remove unnecessary `pass`
|
test:
flair/embeddings/image.py#L1
flair/embeddings/image.py
34: error: Unused "type: ignore" comment [unused-ignore]
|
test:
flair/embeddings/image.py#L341
ruff
pytest_ruff.RuffError: flair/embeddings/image.py:107:13: PIE790 [*] Unnecessary `pass` statement
|
105 | log.warning('To use convnets pretraned on ImageNet, please first install with "pip install torchvision"')
106 | log.warning("-" * 100)
107 | pass
| ^^^^ PIE790
108 |
109 | model_info = {
|
= help: Remove unnecessary `pass`
|
test:
flair/embeddings/legacy.py#L341
ruff
pytest_ruff.RuffError: flair/embeddings/legacy.py:43:13: PIE790 [*] Unnecessary `pass` statement
|
41 | log.warning('To use ELMoEmbeddings, please first install with "pip install allennlp==0.9.0"')
42 | log.warning("-" * 100)
43 | pass
| ^^^^ PIE790
44 |
45 | assert embedding_mode in ["all", "top", "average"]
|
= help: Remove unnecessary `pass`
|
test:
flair/models/sequence_tagger_utils/viterbi.py#L1
flair/models/sequence_tagger_utils/viterbi.py
237: error: Invalid index type "signedinteger[Any]" for "Tensor"; expected type "Union[None, int, slice, Tensor, List[Any], Tuple[Any, ...]]" [index]
238: error: Invalid index type "signedinteger[Any]" for "Tensor"; expected type "Union[None, int, slice, Tensor, List[Any], Tuple[Any, ...]]" [index]
243: error: Invalid index type "signedinteger[Any]" for "Tensor"; expected type "Union[None, int, slice, Tensor, List[Any], Tuple[Any, ...]]" [index]
244: error: Invalid index type "signedinteger[Any]" for "Tensor"; expected type "Union[None, int, slice, Tensor, List[Any], Tuple[Any, ...]]" [index]
|
test:
flair/models/sequence_tagger_utils/viterbi.py#L341
ruff
pytest_ruff.RuffError: flair/models/sequence_tagger_utils/viterbi.py:235:20: E721 Do not compare types, use `isinstance()`
|
233 | for i_batch, batch in enumerate(scores):
234 | for i, (tag_id, tag_scores) in enumerate(zip(tag_seq, batch)):
235 | if type(tag_id) != int and tag_id.item() != np.argmax(tag_scores):
| ^^^^^^^^^^^^^^^^^^^ E721
236 | swap_index_score = np.argmax(tag_scores)
237 | scores[i_batch][i][tag_id.item()], scores[i_batch][i][swap_index_score] = (
|
flair/models/sequence_tagger_utils/viterbi.py:241:22: E721 Do not compare types, use `isinstance()`
|
239 | scores[i_batch][i][tag_id.item()],
240 | )
241 | elif type(tag_id) == int and tag_id != np.argmax(tag_scores):
| ^^^^^^^^^^^^^^^^^^^ E721
242 | swap_index_score = np.argmax(tag_scores)
243 | scores[i_batch][i][tag_id], scores[i_batch][i][swap_index_score] = (
|
|