From 8d6df674fa299604bb4e7495b72492ce05dae803 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Tue, 1 Aug 2023 08:34:05 +0200 Subject: [PATCH] Rephrase error about vocab methods for vectors --- spacy/errors.py | 3 ++- spacy/vocab.pyx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index 0cda0d5b2..14ec669a3 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -553,7 +553,8 @@ class Errors(metaclass=ErrorsWithCodes): "during training, make sure to include it in 'annotating components'") # New errors added in v3.x - E849 = ("Unable to {action} vectors for vectors of type {vectors_type}.") + E849 = ("The vocab only supports {method} for vectors of type " + "spacy.vectors.Vectors, not {vectors_type}.") E850 = ("The PretrainVectors objective currently only supports default or " "floret vectors, not {mode} vectors.") E851 = ("The 'textcat' component labels should only have values of 0 or 1, " diff --git a/spacy/vocab.pyx b/spacy/vocab.pyx index a357b7889..23d3dfe68 100644 --- a/spacy/vocab.pyx +++ b/spacy/vocab.pyx @@ -300,7 +300,7 @@ cdef class Vocab: width, you have to call this to change the size of the vectors. """ if not isinstance(self.vectors, Vectors): - raise ValueError(Errors.E849.format(action="reset", vectors_type=type(self.vectors))) + raise ValueError(Errors.E849.format(method="reset_vectors", vectors_type=type(Vectors))) if width is not None and shape is not None: raise ValueError(Errors.E065.format(width=width, shape=shape)) elif shape is not None: @@ -311,7 +311,7 @@ cdef class Vocab: def deduplicate_vectors(self): if not isinstance(self.vectors, Vectors): - raise ValueError(Errors.E849.format(action="deduplicate", vectors_type=type(self.vectors))) + raise ValueError(Errors.E849.format(method="deduplicate_vectors", vectors_type=type(self.vectors))) if self.vectors.mode != VectorsMode.default: raise ValueError(Errors.E858.format( mode=self.vectors.mode, @@ -366,7 +366,7 @@ cdef class Vocab: DOCS: https://spacy.io/api/vocab#prune_vectors """ if not isinstance(self.vectors, Vectors): - raise ValueError(Errors.E849.format(action="prune", vectors_type=type(self.vectors))) + raise ValueError(Errors.E849.format(method="prune_vectors", vectors_type=type(Vectors))) if self.vectors.mode != VectorsMode.default: raise ValueError(Errors.E858.format( mode=self.vectors.mode,