neulab/docprompting-conala huggingface dataset:
numpy.ndarray.dtype attribute   ndarray.dtype
 
Data-type of the array’s elements.  Parameters 
 None
  Returns 
 
dnumpy dtype object

    See also  numpy.dtype
  Examples >>> x
array([[0, 1],
       [2, 3]])
>>> x.dtype
dtype('int32')
>>> type(x.dtype)
<type 'numpy.dtype'>
numpy.ndarray.dump method   ndarray.dump(file)
 
Dump a pickle of the array to the specified file. The array can be read back with pickle.load or numpy.load.  Parameters 
 
filestr or Path


A string naming the dump file.  Changed in version 1.17.0: pathlib.Path objects are now accepted.
numpy.ndarray.dumps method   ndarray.dumps()
 
Returns the pickle of the array as a string. pickle.loads will convert the string back to an array.  Parameters 
 None
numpy.ndarray.fill method   ndarray.fill(value)
 
Fill the array with a scalar value.  Parameters 
 
valuescalar


All elements of a will be assigned this value.     Examples >>> a = np.array([1, 2])
>>> a.fill(0)
>>> a
array([0, 0])
>>> a = np.empty(2)
>>> a.fill(1)
>>> a
array([1.,  1.])
numpy.ndarray.flags attribute   ndarray.flags
 
Information about the memory layout of the array. Notes The flags object can be accessed dictionary-like (as in a.flags['WRITEABLE']), or by using lowercased attribute names (as in a.flags.writeable). Short flag names are only supported in dictionary access. Only the WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED flags can be changed by the user, via direct assignment to the attribute or dictionary entry, or by calling ndarray.setflags. The array flags cannot be set arbitrarily:  UPDATEIFCOPY can only be set False. WRITEBACKIFCOPY can only be set False. ALIGNED can only be set True if the data is truly aligned. WRITEABLE can only be set True if the array owns its own memory or the ultimate owner of the memory exposes a writeable buffer interface or is a string.  Arrays can be both C-style and Fortran-style contiguous simultaneously. This is clear for 1-dimensional arrays, but can also be true for higher dimensional arrays. Even for contiguous arrays a stride for a given dimension arr.strides[dim] may be arbitrary if arr.shape[dim] == 1 or the array has no elements. It does not generally hold that self.strides[-1] == self.itemsize for C-style contiguous arrays or self.strides[0] == self.itemsize for Fortran-style contiguous arrays is true.  Attributes 
 C_CONTIGUOUS (C)

The data is in a single, C-style contiguous segment.  F_CONTIGUOUS (F)

The data is in a single, Fortran-style contiguous segment.  OWNDATA (O)

The array owns the memory it uses or borrows it from another object.  WRITEABLE (W)

The data area can be written to. Setting this to False locks the data, making it read-only. A view (slice, etc.) inherits WRITEABLE from its base array at creation time, but a view of a writeable array may be subsequently locked while the base array remains writeable. (The opposite is not true, in that a view of a locked array may not be made writeable. However, currently, locking a base object does not lock any views that already reference it, so under that circumstance it is possible to alter the contents of a locked array via a previously created writeable view onto it.) Attempting to change a non-writeable array raises a RuntimeError exception.  ALIGNED (A)

The data and all elements are aligned appropriately for the hardware.  WRITEBACKIFCOPY (X)

This array is a copy of some other array. The C-API function PyArray_ResolveWritebackIfCopy must be called before deallocating to the base array will be updated with the contents of this array.  UPDATEIFCOPY (U)

(Deprecated, use WRITEBACKIFCOPY) This array is a copy of some other array. When this array is deallocated, the base array will be updated with the contents of this array.  FNC

F_CONTIGUOUS and not C_CONTIGUOUS.  FORC

F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).  BEHAVED (B)

ALIGNED and WRITEABLE.  CARRAY (CA)

BEHAVED and C_CONTIGUOUS.  FARRAY (FA)

BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.
numpy.ndarray.flat attribute   ndarray.flat
 
A 1-D iterator over the array. This is a numpy.flatiter instance, which acts similarly to, but is not a subclass of, Python’s built-in iterator object.  See also  flatten

Return a copy of the array collapsed into one dimension.  flatiter
  Examples >>> x = np.arange(1, 7).reshape(2, 3)
>>> x
array([[1, 2, 3],
       [4, 5, 6]])
>>> x.flat[3]
4
>>> x.T
array([[1, 4],
       [2, 5],
       [3, 6]])
>>> x.T.flat[3]
5
>>> type(x.flat)
<class 'numpy.flatiter'>
 An assignment example: >>> x.flat = 3; x
array([[3, 3, 3],
       [3, 3, 3]])
>>> x.flat[[1,4]] = 1; x
array([[3, 1, 3],
       [3, 1, 3]])
numpy.ndarray.flatten method   ndarray.flatten(order='C')
 
Return a copy of the array collapsed into one dimension.  Parameters 
 
order{‘C’, ‘F’, ‘A’, ‘K’}, optional


‘C’ means to flatten in row-major (C-style) order. ‘F’ means to flatten in column-major (Fortran- style) order. ‘A’ means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise. ‘K’ means to flatten a in the order the elements occur in memory. The default is ‘C’.    Returns 
 
yndarray


A copy of the input array, flattened to one dimension.      See also  ravel

Return a flattened array.  flat

A 1-D flat iterator over the array.    Examples >>> a = np.array([[1,2], [3,4]])
>>> a.flatten()
array([1, 2, 3, 4])
>>> a.flatten('F')
array([1, 3, 2, 4])
numpy.ndarray.getfield method   ndarray.getfield(dtype, offset=0)
 
Returns a field of the given array as a certain type. A field is a view of the array data with a given data-type. The values in the view are determined by the given type and the offset into the current array in bytes. The offset needs to be such that the view dtype fits in the array dtype; for example an array of dtype complex128 has 16-byte elements. If taking a view with a 32-bit integer (4 bytes), the offset needs to be between 0 and 12 bytes.  Parameters 
 
dtypestr or dtype


The data type of the view. The dtype size of the view can not be larger than that of the array itself.  
offsetint


Number of bytes to skip before beginning the element view.     Examples >>> x = np.diag([1.+1.j]*2)
>>> x[1, 1] = 2 + 4.j
>>> x
array([[1.+1.j,  0.+0.j],
       [0.+0.j,  2.+4.j]])
>>> x.getfield(np.float64)
array([[1.,  0.],
       [0.,  2.]])
 By choosing an offset of 8 bytes we can select the complex part of the array for our view: >>> x.getfield(np.float64, offset=8)
array([[1.,  0.],
       [0.,  4.]])
numpy.ndarray.imag attribute   ndarray.imag
 
The imaginary part of the array. Examples >>> x = np.sqrt([1+0j, 0+1j])
>>> x.imag
array([ 0.        ,  0.70710678])
>>> x.imag.dtype
dtype('float64')
numpy.ndarray.item method   ndarray.item(*args)
 
Copy an element of an array to a standard Python scalar and return it.  Parameters 
 
*argsArguments (variable number and type)


 none: in this case, the method only works for arrays with one element (a.size == 1), which element is copied into a standard Python scalar object and returned. int_type: this argument is interpreted as a flat index into the array, specifying which element to copy and return. tuple of int_types: functions as does a single int_type argument, except that the argument is interpreted as an nd-index into the array.     Returns 
 
zStandard Python scalar object


A copy of the specified element of the array as a suitable Python scalar     Notes When the data type of a is longdouble or clongdouble, item() returns a scalar array object because there is no available Python scalar that would not lose information. Void arrays return a buffer object for item(), unless fields are defined, in which case a tuple is returned. item is very similar to a[args], except, instead of an array scalar, a standard Python scalar is returned. This can be useful for speeding up access to elements of the array and doing arithmetic on elements of the array using Python’s optimized math. Examples >>> np.random.seed(123)
>>> x = np.random.randint(9, size=(3, 3))
>>> x
array([[2, 2, 6],
       [1, 3, 6],
       [1, 0, 1]])
>>> x.item(3)
1
>>> x.item(7)
0
>>> x.item((0, 1))
2
>>> x.item((2, 2))
1
numpy.ndarray.itemset method   ndarray.itemset(*args)
 
Insert scalar into an array (scalar is cast to array’s dtype, if possible) There must be at least 1 argument, and define the last argument as item. Then, a.itemset(*args) is equivalent to but faster than a[args] = item. The item should be a scalar value and args must select a single item in the array a.  Parameters 
 
*argsArguments


If one argument: a scalar, only used in case a is of size 1. If two arguments: the last argument is the value to be set and must be a scalar, the first argument specifies a single array element location. It is either an int or a tuple.     Notes Compared to indexing syntax, itemset provides some speed increase for placing a scalar into a particular location in an ndarray, if you must do this. However, generally this is discouraged: among other problems, it complicates the appearance of the code. Also, when using itemset (and item) inside a loop, be sure to assign the methods to a local variable to avoid the attribute look-up at each loop iteration. Examples >>> np.random.seed(123)
>>> x = np.random.randint(9, size=(3, 3))
>>> x
array([[2, 2, 6],
       [1, 3, 6],
       [1, 0, 1]])
>>> x.itemset(4, 0)
>>> x.itemset((2, 2), 9)
>>> x
array([[2, 2, 6],
       [1, 0, 6],
       [1, 0, 9]])
numpy.ndarray.itemsize attribute   ndarray.itemsize
 
Length of one array element in bytes. Examples >>> x = np.array([1,2,3], dtype=np.float64)
>>> x.itemsize
8
>>> x = np.array([1,2,3], dtype=np.complex128)
>>> x.itemsize
16
numpy.ndarray.max method   ndarray.max(axis=None, out=None, keepdims=False, initial=<no value>, where=True)
 
Return the maximum along a given axis. Refer to numpy.amax for full documentation.  See also  numpy.amax

equivalent function
numpy.ndarray.mean method   ndarray.mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)
 
Returns the average of the array elements along given axis. Refer to numpy.mean for full documentation.  See also  numpy.mean

equivalent function
numpy.ndarray.min method   ndarray.min(axis=None, out=None, keepdims=False, initial=<no value>, where=True)
 
Return the minimum along a given axis. Refer to numpy.amin for full documentation.  See also  numpy.amin

equivalent function
numpy.ndarray.nbytes attribute   ndarray.nbytes
 
Total bytes consumed by the elements of the array. Notes Does not include memory consumed by non-element attributes of the array object. Examples >>> x = np.zeros((3,5,2), dtype=np.complex128)
>>> x.nbytes
480
>>> np.prod(x.shape) * x.itemsize
480
numpy.ndarray.ndim attribute   ndarray.ndim
 
Number of array dimensions. Examples >>> x = np.array([1, 2, 3])
>>> x.ndim
1
>>> y = np.zeros((2, 3, 4))
>>> y.ndim
3
numpy.ndarray.newbyteorder method   ndarray.newbyteorder(new_order='S', /)
 
Return the array with the same data viewed with a different byte order. Equivalent to: arr.view(arr.dtype.newbytorder(new_order))
 Changes are also made in all fields and sub-arrays of the array data type.  Parameters 
 
new_orderstring, optional


Byte order to force; a value from the byte order specifications below. new_order codes can be any of:  ‘S’ - swap dtype from current to opposite endian {‘<’, ‘little’} - little endian {‘>’, ‘big’} - big endian {‘=’, ‘native’} - native order, equivalent to sys.byteorder
 {‘|’, ‘I’} - ignore (no change to byte order)  The default value (‘S’) results in swapping the current byte order.    Returns 
 
new_arrarray


New array object with the dtype reflecting given change to the byte order.
numpy.ndarray.nonzero method   ndarray.nonzero()
 
Return the indices of the elements that are non-zero. Refer to numpy.nonzero for full documentation.  See also  numpy.nonzero

equivalent function
numpy.ndarray.partition method   ndarray.partition(kth, axis=- 1, kind='introselect', order=None)
 
Rearranges the elements in the array in such a way that the value of the element in kth position is in the position it would be in a sorted array. All elements smaller than the kth element are moved before this element and all equal or greater are moved behind it. The ordering of the elements in the two partitions is undefined.  New in version 1.8.0.   Parameters 
 
kthint or sequence of ints


Element index to partition by. The kth element value will be in its final sorted position and all smaller elements will be moved before it and all equal or greater elements behind it. The order of all elements in the partitions is undefined. If provided with a sequence of kth it will partition all elements indexed by kth of them into their sorted position at once.  Deprecated since version 1.22.0: Passing booleans as index is deprecated.   
axisint, optional


Axis along which to sort. Default is -1, which means sort along the last axis.  
kind{‘introselect’}, optional


Selection algorithm. Default is ‘introselect’.  
orderstr or list of str, optional


When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need to be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties.      See also  numpy.partition

Return a parititioned copy of an array.  argpartition

Indirect partition.  sort

Full sort.    Notes See np.partition for notes on the different algorithms. Examples >>> a = np.array([3, 4, 2, 1])
>>> a.partition(3)
>>> a
array([2, 1, 3, 4])
 >>> a.partition((1, 3))
>>> a
array([1, 2, 3, 4])
numpy.ndarray.prod method   ndarray.prod(axis=None, dtype=None, out=None, keepdims=False, initial=1, where=True)
 
Return the product of the array elements over the given axis Refer to numpy.prod for full documentation.  See also  numpy.prod

equivalent function
numpy.ndarray.ptp method   ndarray.ptp(axis=None, out=None, keepdims=False)
 
Peak to peak (maximum - minimum) value along a given axis. Refer to numpy.ptp for full documentation.  See also  numpy.ptp

equivalent function
numpy.ndarray.put method   ndarray.put(indices, values, mode='raise')
 
Set a.flat[n] = values[n] for all n in indices. Refer to numpy.put for full documentation.  See also  numpy.put

equivalent function
numpy.ndarray.ravel method   ndarray.ravel([order])
 
Return a flattened array. Refer to numpy.ravel for full documentation.  See also  numpy.ravel

equivalent function  ndarray.flat

a flat iterator on the array.
numpy.ndarray.real attribute   ndarray.real
 
The real part of the array.  See also  numpy.real

equivalent function    Examples >>> x = np.sqrt([1+0j, 0+1j])
>>> x.real
array([ 1.        ,  0.70710678])
>>> x.real.dtype
dtype('float64')
numpy.ndarray.repeat method   ndarray.repeat(repeats, axis=None)
 
Repeat elements of an array. Refer to numpy.repeat for full documentation.  See also  numpy.repeat

equivalent function
numpy.ndarray.reshape method   ndarray.reshape(shape, order='C')
 
Returns an array containing the same data with a new shape. Refer to numpy.reshape for full documentation.  See also  numpy.reshape

equivalent function    Notes Unlike the free function numpy.reshape, this method on ndarray allows the elements of the shape parameter to be passed in as separate arguments. For example, a.reshape(10, 11) is equivalent to a.reshape((10, 11)).
numpy.ndarray.resize method   ndarray.resize(new_shape, refcheck=True)
 
Change shape and size of array in-place.  Parameters 
 
new_shapetuple of ints, or n ints


Shape of resized array.  
refcheckbool, optional


If False, reference count will not be checked. Default is True.    Returns 
 None
  Raises 
 ValueError

If a does not own its own data or references or views to it exist, and the data memory must be changed. PyPy only: will always raise if the data memory must be changed, since there is no reliable way to determine if references or views to it exist.  SystemError

If the order keyword argument is specified. This behaviour is a bug in NumPy.      See also  resize

Return a new array with the specified shape.    Notes This reallocates space for the data area if necessary. Only contiguous arrays (data elements consecutive in memory) can be resized. The purpose of the reference count check is to make sure you do not use this array as a buffer for another Python object and then reallocate the memory. However, reference counts can increase in other ways so if you are sure that you have not shared the memory for this array with another Python object, then you may safely set refcheck to False. Examples Shrinking an array: array is flattened (in the order that the data are stored in memory), resized, and reshaped: >>> a = np.array([[0, 1], [2, 3]], order='C')
>>> a.resize((2, 1))
>>> a
array([[0],
       [1]])
 >>> a = np.array([[0, 1], [2, 3]], order='F')
>>> a.resize((2, 1))
>>> a
array([[0],
       [2]])
 Enlarging an array: as above, but missing entries are filled with zeros: >>> b = np.array([[0, 1], [2, 3]])
>>> b.resize(2, 3) # new_shape parameter doesn't have to be a tuple
>>> b
array([[0, 1, 2],
       [3, 0, 0]])
 Referencing an array prevents resizing… >>> c = a
>>> a.resize((1, 1))
Traceback (most recent call last):
...
ValueError: cannot resize an array that references or is referenced ...
 Unless refcheck is False: >>> a.resize((1, 1), refcheck=False)
>>> a
array([[0]])
>>> c
array([[0]])
numpy.ndarray.round method   ndarray.round(decimals=0, out=None)
 
Return a with each element rounded to the given number of decimals. Refer to numpy.around for full documentation.  See also  numpy.around

equivalent function
numpy.ndarray.searchsorted method   ndarray.searchsorted(v, side='left', sorter=None)
 
Find indices where elements of v should be inserted in a to maintain order. For full documentation, see numpy.searchsorted  See also  numpy.searchsorted

equivalent function
numpy.ndarray.setfield method   ndarray.setfield(val, dtype, offset=0)
 
Put a value into a specified place in a field defined by a data-type. Place val into a’s field defined by dtype and beginning offset bytes into the field.  Parameters 
 
valobject


Value to be placed in field.  
dtypedtype object


Data-type of the field in which to place val.  
offsetint, optional


The number of bytes into the field at which to place val.    Returns 
 None
    See also  getfield
  Examples >>> x = np.eye(3)
>>> x.getfield(np.float64)
array([[1.,  0.,  0.],
       [0.,  1.,  0.],
       [0.,  0.,  1.]])
>>> x.setfield(3, np.int32)
>>> x.getfield(np.int32)
array([[3, 3, 3],
       [3, 3, 3],
       [3, 3, 3]], dtype=int32)
>>> x
array([[1.0e+000, 1.5e-323, 1.5e-323],
       [1.5e-323, 1.0e+000, 1.5e-323],
       [1.5e-323, 1.5e-323, 1.0e+000]])
>>> x.setfield(np.eye(3), np.int32)
>>> x
array([[1.,  0.,  0.],
       [0.,  1.,  0.],
       [0.,  0.,  1.]])
numpy.ndarray.setflags method   ndarray.setflags(write=None, align=None, uic=None)
 
Set array flags WRITEABLE, ALIGNED, (WRITEBACKIFCOPY and UPDATEIFCOPY), respectively. These Boolean-valued flags affect how numpy interprets the memory area used by a (see Notes below). The ALIGNED flag can only be set to True if the data is actually aligned according to the type. The WRITEBACKIFCOPY and (deprecated) UPDATEIFCOPY flags can never be set to True. The flag WRITEABLE can only be set to True if the array owns its own memory, or the ultimate owner of the memory exposes a writeable buffer interface, or is a string. (The exception for string is made so that unpickling can be done without copying memory.)  Parameters 
 
writebool, optional


Describes whether or not a can be written to.  
alignbool, optional


Describes whether or not a is aligned properly for its type.  
uicbool, optional


Describes whether or not a is a copy of another “base” array.     Notes Array flags provide information about how the memory area used for the array is to be interpreted. There are 7 Boolean flags in use, only four of which can be changed by the user: WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED. WRITEABLE (W) the data area can be written to; ALIGNED (A) the data and strides are aligned appropriately for the hardware (as determined by the compiler); UPDATEIFCOPY (U) (deprecated), replaced by WRITEBACKIFCOPY; WRITEBACKIFCOPY (X) this array is a copy of some other array (referenced by .base). When the C-API function PyArray_ResolveWritebackIfCopy is called, the base array will be updated with the contents of this array. All flags can be accessed using the single (upper case) letter as well as the full name. Examples >>> y = np.array([[3, 1, 7],
...               [2, 0, 0],
...               [8, 5, 9]])
>>> y
array([[3, 1, 7],
       [2, 0, 0],
       [8, 5, 9]])
>>> y.flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False
>>> y.setflags(write=0, align=0)
>>> y.flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : False
  ALIGNED : False
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False
>>> y.setflags(uic=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: cannot set WRITEBACKIFCOPY flag to True
numpy.ndarray.shape attribute   ndarray.shape
 
Tuple of array dimensions. The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of the array and the remaining dimensions. Reshaping an array in-place will fail if a copy is required.  See also  numpy.reshape

similar function  ndarray.reshape

similar method    Examples >>> x = np.array([1, 2, 3, 4])
>>> x.shape
(4,)
>>> y = np.zeros((2, 3, 4))
>>> y.shape
(2, 3, 4)
>>> y.shape = (3, 8)
>>> y
array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])
>>> y.shape = (3, 6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: total size of new array must be unchanged
>>> np.zeros((4,2))[::2].shape = (-1,)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: Incompatible shape for in-place modification. Use
`.reshape()` to make a copy with the desired shape.
numpy.ndarray.size attribute   ndarray.size
 
Number of elements in the array. Equal to np.prod(a.shape), i.e., the product of the array’s dimensions. Notes a.size returns a standard arbitrary precision Python integer. This may not be the case with other methods of obtaining the same value (like the suggested np.prod(a.shape), which returns an instance of np.int_), and may be relevant if the value is used further in calculations that may overflow a fixed size integer type. Examples >>> x = np.zeros((3, 5, 2), dtype=np.complex128)
>>> x.size
30
>>> np.prod(x.shape)
30