From ef74f8f5e447dec10ab69d2a7e94f0e09165db75 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Tue, 11 Oct 2022 14:15:22 +0200 Subject: [PATCH] Fix mypy error in edittree lemmatizer (#11612) * cleanup imports * try limiting Thinc to previous release * remove Model specification * fix code and revert Thinc constraint --- spacy/pipeline/edit_tree_lemmatizer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spacy/pipeline/edit_tree_lemmatizer.py b/spacy/pipeline/edit_tree_lemmatizer.py index b7d615f6d..7f6367c75 100644 --- a/spacy/pipeline/edit_tree_lemmatizer.py +++ b/spacy/pipeline/edit_tree_lemmatizer.py @@ -1,7 +1,6 @@ from typing import cast, Any, Callable, Dict, Iterable, List, Optional -from typing import Sequence, Tuple, Union +from typing import Tuple from collections import Counter -from copy import deepcopy from itertools import islice import numpy as np @@ -150,7 +149,7 @@ class EditTreeLemmatizer(TrainablePipe): # Handle cases where there are no tokens in any docs. n_labels = len(self.cfg["labels"]) guesses: List[Ints2d] = [ - self.model.ops.alloc((0, n_labels), dtype="i") for doc in docs + self.model.ops.alloc2i(0, n_labels, dtype="i") for _ in docs ] assert len(guesses) == n_docs return guesses