Skip to content

Commit

Permalink
fixed a bug wherein null value for csr matrix was being incorrectly c…
Browse files Browse the repository at this point in the history
…alculated, causing an array of the wrong dimensions to be created
  • Loading branch information
RichJackson committed Jan 19, 2024
1 parent 0abc077 commit 7490c9b
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def __init__(self, contexts_path: str, model_path: str):
self._calculate_id_vectors(
directory=contexts_path_as_path.parent, filename=contexts_path_as_path.name
)
self.null_vector = self.vectorizer.transform([""])

@kazu_disk_cache.memoize(ignore={0, 1})
def _calculate_id_vectors(self, directory: Path, filename: str) -> None:
Expand Down Expand Up @@ -216,9 +217,7 @@ def __call__(
if maybe_id_vec is not None:
idx_to_vec[idx] = maybe_id_vec
else:
idx_to_vec[idx] = csr_matrix(
(0, self.vectorizer.max_features), dtype=np.float64
)
idx_to_vec[idx] = self.null_vector
if idx_to_vec:
idx_lst = list(idx_to_vec.keys())
scores = -(
Expand Down

0 comments on commit 7490c9b

Please sign in to comment.