mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
Fix vectors.resize() on Py3. Closes #1539
This commit is contained in:
parent
438050643c
commit
1a1cca6052
10
spacy/tests/regression/test_issue1539.py
Normal file
10
spacy/tests/regression/test_issue1539.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
'''Ensure vectors.resize() doesn't try to modify dictionary during iteration.'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ...vectors import Vectors
|
||||
|
||||
|
||||
def test_issue1539():
|
||||
v = Vectors(shape=(10, 10), keys=[5,3,98,100])
|
||||
v.resize((100,100))
|
||||
|
|
@ -151,7 +151,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 self.key2row.items():
|
||||
for key, row in list(self.key2row.items()):
|
||||
if row >= shape[0]:
|
||||
self.key2row.pop(key)
|
||||
removed_items.append((key, row))
|
||||
|
|
Loading…
Reference in New Issue
Block a user