From 8cefc58abcc2102c04b43cac29e79320813a8fee Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 10 Mar 2018 22:53:42 +0100 Subject: [PATCH] Fix Vectors pickling --- spacy/vectors.pyx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spacy/vectors.pyx b/spacy/vectors.pyx index 7daebabe6..1b265e189 100644 --- a/spacy/vectors.pyx +++ b/spacy/vectors.pyx @@ -15,11 +15,8 @@ from .compat import basestring_, path2str from . import util -def unpickle_vectors(keys_and_rows, data): - vectors = Vectors(data=data) - for key, row in keys_and_rows: - vectors.add(key, row=row) - return vectors +def unpickle_vectors(bytes_data): + return Vectors().from_bytes(bytes_data) cdef class Vectors: @@ -86,8 +83,7 @@ cdef class Vectors: return len(self.key2row) def __reduce__(self): - keys_and_rows = tuple(self.key2row.items()) - return (unpickle_vectors, (keys_and_rows, self.data)) + return (unpickle_vectors, (self.to_bytes(),)) def __getitem__(self, key): """Get a vector by key. If the key is not found, a KeyError is raised.