mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Merge branch 'master' of https://github.com/explosion/spaCy
This commit is contained in:
		
						commit
						5babb7d6f6
					
				
							
								
								
									
										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))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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