diff --git a/spacy/tests/regression/test_issue1539.py b/spacy/tests/regression/test_issue1539.py new file mode 100644 index 000000000..6665f8087 --- /dev/null +++ b/spacy/tests/regression/test_issue1539.py @@ -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)) + diff --git a/spacy/tokens/span.pyx b/spacy/tokens/span.pyx index f09dfd134..10b8a7820 100644 --- a/spacy/tokens/span.pyx +++ b/spacy/tokens/span.pyx @@ -261,6 +261,11 @@ cdef class Span: self.start = start self.end = end + 1 + property vocab: + """RETURNS (Vocab): The Span's Doc's vocab.""" + def __get__(self): + return self.doc.vocab + property sent: """RETURNS (Span): The sentence span that the span is a part of.""" def __get__(self): diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index c0ff8c845..281c0a4be 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -341,19 +341,20 @@ cdef class Token: property sent_start: def __get__(self): - util.deprecated( - "Token.sent_start is now deprecated. Use Token.is_sent_start " - "instead, which returns a boolean value or None if the answer " - "is unknown – instead of a misleading 0 for False and 1 for " - "True. It also fixes a quirk in the old logic that would " - "always set the property to 0 for the first word of the " - "document.") + # Raising a deprecation warning causes errors for autocomplete + #util.deprecated( + # "Token.sent_start is now deprecated. Use Token.is_sent_start " + # "instead, which returns a boolean value or None if the answer " + # "is unknown – instead of a misleading 0 for False and 1 for " + # "True. It also fixes a quirk in the old logic that would " + # "always set the property to 0 for the first word of the " + # "document.") # Handle broken backwards compatibility case: doc[0].sent_start # was False. if self.i == 0: return False else: - return self.sent_start + return self.c.sent_start def __set__(self, value): self.is_sent_start = value diff --git a/spacy/vectors.pyx b/spacy/vectors.pyx index 46997cccf..96a9d3435 100644 --- a/spacy/vectors.pyx +++ b/spacy/vectors.pyx @@ -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))