GH-3070: Fix inconsistency between best path and scores in ViterbiDecoder #1994
Annotations
4 errors
flair/__init__.py#L1
mypy-status
mypy exited with status 1.
|
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]
|
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] = (
|
|
|
The logs for this run have expired and are no longer available.
Loading