Fix #1518: vocab.vectors.resize() didn't work

This commit is contained in:
Matthew Honnibal 2017-11-08 22:18:37 +01:00
parent dec79ca332
commit a5ea0fdf5a
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,7 @@
from ...vectors import Vectors
def test_issue1518():
'''Test vectors.resize() works.'''
vectors = Vectors(shape=(10, 10))
vectors.add(u'hello', row=2)
vectors.resize((5, 9))

View File

@ -150,7 +150,7 @@ cdef class Vectors:
filled = {row for row in self.key2row.values()}
self._unset = {row for row in range(shape[0]) if row not in filled}
removed_items = []
for key, row in dict(self.key2row.items()):
for key, row in self.key2row.items():
if row >= shape[0]:
self.key2row.pop(key)
removed_items.append((key, row))