mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Update docstrings and formatting
This commit is contained in:
		
							parent
							
								
									0de8d213a3
								
							
						
					
					
						commit
						ba2e6c8c6f
					
				| 
						 | 
					@ -42,6 +42,7 @@ cdef class Vectors:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        shape (tuple): Size of the table, as (# entries, # columns)
 | 
					        shape (tuple): Size of the table, as (# entries, # columns)
 | 
				
			||||||
        data (numpy.ndarray): The vector data.
 | 
					        data (numpy.ndarray): The vector data.
 | 
				
			||||||
 | 
					        keys (iterable): A sequence of keys, aligned with the data.
 | 
				
			||||||
        RETURNS (Vectors): The newly created object.
 | 
					        RETURNS (Vectors): The newly created object.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        if data is None:
 | 
					        if data is None:
 | 
				
			||||||
| 
						 | 
					@ -102,7 +103,7 @@ cdef class Vectors:
 | 
				
			||||||
        """Set a vector for the given key.
 | 
					        """Set a vector for the given key.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        key (int): The key to set the vector for.
 | 
					        key (int): The key to set the vector for.
 | 
				
			||||||
        vector (numpy.ndarray): The vector to set.
 | 
					        vector (ndarray): The vector to set.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        i = self.key2row[key]
 | 
					        i = self.key2row[key]
 | 
				
			||||||
        self.data[i] = vector
 | 
					        self.data[i] = vector
 | 
				
			||||||
| 
						 | 
					@ -110,9 +111,9 @@ cdef class Vectors:
 | 
				
			||||||
            self._unset.remove(i)
 | 
					            self._unset.remove(i)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __iter__(self):
 | 
					    def __iter__(self):
 | 
				
			||||||
        """Yield vectors from the table.
 | 
					        """Iterate over the keys in the table.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        YIELDS (ndarray): A vector.
 | 
					        YIELDS (int): A key in the table.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        yield from self.key2row
 | 
					        yield from self.key2row
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,14 +133,14 @@ cdef class Vectors:
 | 
				
			||||||
        return key in self.key2row
 | 
					        return key in self.key2row
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def resize(self, shape, inplace=False):
 | 
					    def resize(self, shape, inplace=False):
 | 
				
			||||||
        '''Resize the underlying vectors array. If inplace=True, the memory
 | 
					        """Resize the underlying vectors array. If inplace=True, the memory
 | 
				
			||||||
        is reallocated. This may cause other references to the data to become
 | 
					        is reallocated. This may cause other references to the data to become
 | 
				
			||||||
        invalid, so only use inplace=True if you're sure that's what you want.
 | 
					        invalid, so only use inplace=True if you're sure that's what you want.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        If the number of vectors is reduced, keys mapped to rows that have been
 | 
					        If the number of vectors is reduced, keys mapped to rows that have been
 | 
				
			||||||
        deleted are removed. These removed items are returned as a list of
 | 
					        deleted are removed. These removed items are returned as a list of
 | 
				
			||||||
        (key, row) tuples.
 | 
					        `(key, row)` tuples.
 | 
				
			||||||
        '''
 | 
					        """
 | 
				
			||||||
        if inplace:
 | 
					        if inplace:
 | 
				
			||||||
            self.data.resize(shape, refcheck=False)
 | 
					            self.data.resize(shape, refcheck=False)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -155,14 +156,20 @@ cdef class Vectors:
 | 
				
			||||||
        return removed_items
 | 
					        return removed_items
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def keys(self):
 | 
					    def keys(self):
 | 
				
			||||||
        '''Iterate over the keys in the table.'''
 | 
					        """A sequence of the keys in the table.
 | 
				
			||||||
        yield from self.key2row.keys()
 | 
					
 | 
				
			||||||
 | 
					        RETURNS (iterable): The keys.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        return self.key2row.keys()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def values(self):
 | 
					    def values(self):
 | 
				
			||||||
        '''Iterate over vectors that have been assigned to at least one key.
 | 
					        """Iterate over vectors that have been assigned to at least one key.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Note that some vectors may be unassigned, so the number of vectors
 | 
					        Note that some vectors may be unassigned, so the number of vectors
 | 
				
			||||||
        returned may be less than the length of the vectors table.'''
 | 
					        returned may be less than the length of the vectors table.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        YIELDS (ndarray): A vector in the table.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
        for row, vector in enumerate(range(self.data.shape[0])):
 | 
					        for row, vector in enumerate(range(self.data.shape[0])):
 | 
				
			||||||
            if row not in self._unset:
 | 
					            if row not in self._unset:
 | 
				
			||||||
                yield vector
 | 
					                yield vector
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user