From 3ba5238282d5ea84d5d2a71b5940de30fbaf3331 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Mon, 16 Sep 2019 15:16:12 +0200 Subject: [PATCH] Make "unnamed vectors" warning a real warning --- spacy/_ml.py | 5 +---- spacy/errors.py | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spacy/_ml.py b/spacy/_ml.py index d81ceccc1..6104324ab 100644 --- a/spacy/_ml.py +++ b/spacy/_ml.py @@ -286,10 +286,7 @@ def link_vectors_to_models(vocab): if vectors.name is None: vectors.name = VECTORS_KEY if vectors.data.size != 0: - print( - "Warning: Unnamed vectors -- this won't allow multiple vectors " - "models to be loaded. (Shape: (%d, %d))" % vectors.data.shape - ) + user_warning(Warnings.W020.format(shape=vectors.data.shape)) ops = Model.ops for word in vocab: if word.orth in vectors.key2row: diff --git a/spacy/errors.py b/spacy/errors.py index 80c4c6f85..b2a201773 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -84,6 +84,8 @@ class Warnings(object): W018 = ("Entity '{entity}' already exists in the Knowledge base.") W019 = ("Changing vectors name from {old} to {new}, to avoid clash with " "previously loaded vectors. See Issue #3853.") + W020 = ("Unnamed vectors. This won't allow multiple vectors models to be " + "loaded. (Shape: {shape})") @add_codes