neulab/docprompting-conala huggingface dataset:
numpy.reshape   numpy.reshape(a, newshape, order='C')[source]
 
Gives a new shape to an array without changing its data.  Parameters 
 
aarray_like


Array to be reshaped.  
newshapeint or tuple of ints


The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.  
order{‘C’, ‘F’, ‘A’}, optional


Read the elements of a using this index order, and place the elements into the reshaped array using this index order. ‘C’ means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. ‘A’ means to read / write the elements in Fortran-like index order if a is Fortran contiguous in memory, C-like order otherwise.    Returns 
 
reshaped_arrayndarray


This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the memory layout (C- or Fortran- contiguous) of the returned array.      See also  ndarray.reshape

Equivalent method.    Notes It is not always possible to change the shape of an array without copying the data. If you want an error to be raised when the data is copied, you should assign the new shape to the shape attribute of the array: >>> a = np.zeros((10, 2))

# A transpose makes the array non-contiguous
>>> b = a.T

# Taking a view makes it possible to modify the shape without modifying
# the initial object.
>>> c = b.view()
>>> c.shape = (20)
Traceback (most recent call last):
   ...
AttributeError: Incompatible shape for in-place modification. Use
`.reshape()` to make a copy with the desired shape.
 The order keyword gives the index ordering both for fetching the values from a, and then placing the values into the output array. For example, let’s say you have an array: >>> a = np.arange(6).reshape((3, 2))
>>> a
array([[0, 1],
       [2, 3],
       [4, 5]])
 You can think of reshaping as first raveling the array (using the given index order), then inserting the elements from the raveled array into the new array using the same kind of index ordering as was used for the raveling. >>> np.reshape(a, (2, 3)) # C-like index ordering
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.reshape(a, (2, 3), order='F') # Fortran-like index ordering
array([[0, 4, 3],
       [2, 1, 5]])
>>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
array([[0, 4, 3],
       [2, 1, 5]])
 Examples >>> a = np.array([[1,2,3], [4,5,6]])
>>> np.reshape(a, 6)
array([1, 2, 3, 4, 5, 6])
>>> np.reshape(a, 6, order='F')
array([1, 4, 2, 5, 3, 6])
 >>> np.reshape(a, (3,-1))       # the unspecified value is inferred to be 2
array([[1, 2],
       [3, 4],
       [5, 6]])
numpy.resize   numpy.resize(a, new_shape)[source]
 
Return a new array with the specified shape. If the new array is larger than the original array, then the new array is filled with repeated copies of a. Note that this behavior is different from a.resize(new_shape) which fills with zeros instead of repeated copies of a.  Parameters 
 
aarray_like


Array to be resized.  
new_shapeint or tuple of int


Shape of resized array.    Returns 
 
reshaped_arrayndarray


The new array is formed from the data in the old array, repeated if necessary to fill out the required number of elements. The data are repeated iterating over the array in C-order.      See also  numpy.reshape

Reshape an array without changing the total size.  numpy.pad

Enlarge and pad an array.  numpy.repeat

Repeat elements of an array.  ndarray.resize

resize an array in-place.    Notes When the total size of the array does not change reshape should be used. In most other cases either indexing (to reduce the size) or padding (to increase the size) may be a more appropriate solution. Warning: This functionality does not consider axes separately, i.e. it does not apply interpolation/extrapolation. It fills the return array with the required number of elements, iterating over a in C-order, disregarding axes (and cycling back from the start if the new shape is larger). This functionality is therefore not suitable to resize images, or data where each axis represents a separate and distinct entity. Examples >>> a=np.array([[0,1],[2,3]])
>>> np.resize(a,(2,3))
array([[0, 1, 2],
       [3, 0, 1]])
>>> np.resize(a,(1,4))
array([[0, 1, 2, 3]])
>>> np.resize(a,(2,4))
array([[0, 1, 2, 3],
       [0, 1, 2, 3]])
numpy.result_type   numpy.result_type(*arrays_and_dtypes)
 
Returns the type that results from applying the NumPy type promotion rules to the arguments. Type promotion in NumPy works similarly to the rules in languages like C++, with some slight differences. When both scalars and arrays are used, the array’s type takes precedence and the actual value of the scalar is taken into account. For example, calculating 3*a, where a is an array of 32-bit floats, intuitively should result in a 32-bit float output. If the 3 is a 32-bit integer, the NumPy rules indicate it can’t convert losslessly into a 32-bit float, so a 64-bit float should be the result type. By examining the value of the constant, ‘3’, we see that it fits in an 8-bit integer, which can be cast losslessly into the 32-bit float.  Parameters 
 
arrays_and_dtypeslist of arrays and dtypes


The operands of some operation whose result type is needed.    Returns 
 
outdtype


The result type.      See also  
dtype, promote_types, min_scalar_type, can_cast

  Notes  New in version 1.6.0.  The specific algorithm used is as follows. Categories are determined by first checking which of boolean, integer (int/uint), or floating point (float/complex) the maximum kind of all the arrays and the scalars are. If there are only scalars or the maximum category of the scalars is higher than the maximum category of the arrays, the data types are combined with promote_types to produce the return value. Otherwise, min_scalar_type is called on each array, and the resulting data types are all combined with promote_types to produce the return value. The set of int values is not a subset of the uint values for types with the same number of bits, something not reflected in min_scalar_type, but handled as a special case in result_type. Examples >>> np.result_type(3, np.arange(7, dtype='i1'))
dtype('int8')
 >>> np.result_type('i4', 'c8')
dtype('complex128')
 >>> np.result_type(3.0, -2)
dtype('float64')
numpy.right_shift   numpy.right_shift(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'right_shift'>
 
Shift the bits of an integer to the right. Bits are shifted to the right x2. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing x1 by 2**x2.  Parameters 
 
x1array_like, int


Input values.  
x2array_like, int


Number of bits to remove at the right of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).  
outndarray, None, or tuple of ndarray and None, optional


A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.  
wherearray_like, optional


This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.  **kwargs

For other keyword-only arguments, see the ufunc docs.    Returns 
 
outndarray, int


Return x1 with bits shifted x2 times to the right. This is a scalar if both x1 and x2 are scalars.      See also  left_shift

Shift the bits of an integer to the left.  binary_repr

Return the binary representation of the input number as a string.    Examples >>> np.binary_repr(10)
'1010'
>>> np.right_shift(10, 1)
5
>>> np.binary_repr(5)
'101'
 >>> np.right_shift(10, [1,2,3])
array([5, 2, 1])
 The >> operator can be used as a shorthand for np.right_shift on ndarrays. >>> x1 = 10
>>> x2 = np.array([1,2,3])
>>> x1 >> x2
array([5, 2, 1])
numpy.rint   numpy.rint(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'rint'>
 
Round elements of the array to the nearest integer.  Parameters 
 
xarray_like


Input array.  
outndarray, None, or tuple of ndarray and None, optional


A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.  
wherearray_like, optional


This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.  **kwargs

For other keyword-only arguments, see the ufunc docs.    Returns 
 
outndarray or scalar


Output array is same shape and type as x. This is a scalar if x is a scalar.      See also  
fix, ceil, floor, trunc

  Notes For values exactly halfway between rounded decimal values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to 0.0, etc. Examples >>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
>>> np.rint(a)
array([-2., -2., -0.,  0.,  2.,  2.,  2.])
numpy.roll   numpy.roll(a, shift, axis=None)[source]
 
Roll array elements along a given axis. Elements that roll beyond the last position are re-introduced at the first.  Parameters 
 
aarray_like


Input array.  
shiftint or tuple of ints


The number of places by which elements are shifted. If a tuple, then axis must be a tuple of the same size, and each of the given axes is shifted by the corresponding number. If an int while axis is a tuple of ints, then the same value is used for all given axes.  
axisint or tuple of ints, optional


Axis or axes along which elements are shifted. By default, the array is flattened before shifting, after which the original shape is restored.    Returns 
 
resndarray


Output array, with the same shape as a.      See also  rollaxis

Roll the specified axis backwards, until it lies in a given position.    Notes  New in version 1.12.0.  Supports rolling over multiple dimensions simultaneously. Examples >>> x = np.arange(10)
>>> np.roll(x, 2)
array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
>>> np.roll(x, -2)
array([2, 3, 4, 5, 6, 7, 8, 9, 0, 1])
 >>> x2 = np.reshape(x, (2, 5))
>>> x2
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
>>> np.roll(x2, 1)
array([[9, 0, 1, 2, 3],
       [4, 5, 6, 7, 8]])
>>> np.roll(x2, -1)
array([[1, 2, 3, 4, 5],
       [6, 7, 8, 9, 0]])
>>> np.roll(x2, 1, axis=0)
array([[5, 6, 7, 8, 9],
       [0, 1, 2, 3, 4]])
>>> np.roll(x2, -1, axis=0)
array([[5, 6, 7, 8, 9],
       [0, 1, 2, 3, 4]])
>>> np.roll(x2, 1, axis=1)
array([[4, 0, 1, 2, 3],
       [9, 5, 6, 7, 8]])
>>> np.roll(x2, -1, axis=1)
array([[1, 2, 3, 4, 0],
       [6, 7, 8, 9, 5]])
>>> np.roll(x2, (1, 1), axis=(1, 0))
array([[9, 5, 6, 7, 8],
       [4, 0, 1, 2, 3]])
>>> np.roll(x2, (2, 1), axis=(1, 0))
array([[8, 9, 5, 6, 7],
       [3, 4, 0, 1, 2]])
numpy.rollaxis   numpy.rollaxis(a, axis, start=0)[source]
 
Roll the specified axis backwards, until it lies in a given position. This function continues to be supported for backward compatibility, but you should prefer moveaxis. The moveaxis function was added in NumPy 1.11.  Parameters 
 
andarray


Input array.  
axisint


The axis to be rolled. The positions of the other axes do not change relative to one another.  
startint, optional


When start <= axis, the axis is rolled back until it lies in this position. When start > axis, the axis is rolled until it lies before this position. The default, 0, results in a “complete” roll. The following table describes how negative values of start are interpreted:   
start Normalized start   
-(arr.ndim+1) raise AxisError  
-arr.ndim 0  
⋮ ⋮  
-1 arr.ndim-1  
0 0  
⋮ ⋮  
arr.ndim arr.ndim  
arr.ndim + 1 raise AxisError      Returns 
 
resndarray


For NumPy >= 1.10.0 a view of a is always returned. For earlier NumPy versions a view of a is returned only if the order of the axes is changed, otherwise the input array is returned.      See also  moveaxis

Move array axes to new positions.  roll

Roll the elements of an array by a number of positions along a given axis.    Examples >>> a = np.ones((3,4,5,6))
>>> np.rollaxis(a, 3, 1).shape
(3, 6, 4, 5)
>>> np.rollaxis(a, 2).shape
(5, 3, 4, 6)
>>> np.rollaxis(a, 1, 4).shape
(3, 5, 6, 4)
numpy.roots   numpy.roots(p)[source]
 
Return the roots of a polynomial with coefficients given in p.  Note This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in numpy.polynomial is preferred. A summary of the differences can be found in the transition guide.  The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is described by: p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
  Parameters 
 
parray_like


Rank-1 array of polynomial coefficients.    Returns 
 
outndarray


An array containing the roots of the polynomial.    Raises 
 ValueError

When p cannot be converted to a rank-1 array.      See also  poly

Find the coefficients of a polynomial with a given sequence of roots.  polyval

Compute polynomial values.  polyfit

Least squares polynomial fit.  poly1d

A one-dimensional polynomial class.    Notes The algorithm relies on computing the eigenvalues of the companion matrix [1]. References  1 
R. A. Horn & C. R. Johnson, Matrix Analysis. Cambridge, UK: Cambridge University Press, 1999, pp. 146-7.   Examples >>> coeff = [3.2, 2, 1]
>>> np.roots(coeff)
array([-0.3125+0.46351241j, -0.3125-0.46351241j])
numpy.rot90   numpy.rot90(m, k=1, axes=(0, 1))[source]
 
Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis.  Parameters 
 
marray_like


Array of two or more dimensions.  
kinteger


Number of times the array is rotated by 90 degrees.  axes: (2,) array_like

The array is rotated in the plane defined by the axes. Axes must be different.  New in version 1.12.0.     Returns 
 
yndarray


A rotated view of m.      See also  flip

Reverse the order of elements in an array along the given axis.  fliplr

Flip an array horizontally.  flipud

Flip an array vertically.    Notes rot90(m, k=1, axes=(1,0)) is the reverse of rot90(m, k=1, axes=(0,1)) rot90(m, k=1, axes=(1,0)) is equivalent to rot90(m, k=-1, axes=(0,1)) Examples >>> m = np.array([[1,2],[3,4]], int)
>>> m
array([[1, 2],
       [3, 4]])
>>> np.rot90(m)
array([[2, 4],
       [1, 3]])
>>> np.rot90(m, 2)
array([[4, 3],
       [2, 1]])
>>> m = np.arange(8).reshape((2,2,2))
>>> np.rot90(m, 1, (1,2))
array([[[1, 3],
        [0, 2]],
       [[5, 7],
        [4, 6]]])
numpy.round_   numpy.round_(a, decimals=0, out=None)[source]
 
Round an array to the given number of decimals.  See also  around

equivalent function; see for details.
numpy.row_stack   numpy.row_stack(tup)[source]
 
Stack arrays in sequence vertically (row wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape (N,) have been reshaped to (1,N). Rebuilds arrays divided by vsplit. This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.  Parameters 
 
tupsequence of ndarrays


The arrays must have the same shape along all but the first axis. 1-D arrays must have the same length.    Returns 
 
stackedndarray


The array formed by stacking the given arrays, will be at least 2-D.      See also  concatenate

Join a sequence of arrays along an existing axis.  stack

Join a sequence of arrays along a new axis.  block

Assemble an nd-array from nested lists of blocks.  hstack

Stack arrays in sequence horizontally (column wise).  dstack

Stack arrays in sequence depth wise (along third axis).  column_stack

Stack 1-D arrays as columns into a 2-D array.  vsplit

Split an array into multiple sub-arrays vertically (row-wise).    Examples >>> a = np.array([1, 2, 3])
>>> b = np.array([4, 5, 6])
>>> np.vstack((a,b))
array([[1, 2, 3],
       [4, 5, 6]])
 >>> a = np.array([[1], [2], [3]])
>>> b = np.array([[4], [5], [6]])
>>> np.vstack((a,b))
array([[1],
       [2],
       [3],
       [4],
       [5],
       [6]])
numpy.s_   numpy.s_ = <numpy.lib.index_tricks.IndexExpression object>
 
A nicer way to build up index tuples for arrays.  Note Use one of the two predefined instances index_exp or s_ rather than directly using IndexExpression.  For any index combination, including slicing and axis insertion, a[indices] is the same as a[np.index_exp[indices]] for any array a. However, np.index_exp[indices] can be used anywhere in Python code and returns a tuple of slice objects that can be used in the construction of complex index expressions.  Parameters 
 
maketuplebool


If True, always returns a tuple.      See also  index_exp

Predefined instance that always returns a tuple: index_exp = IndexExpression(maketuple=True).  s_

Predefined instance without tuple conversion: s_ = IndexExpression(maketuple=False).    Notes You can do all this with slice() plus a few special objects, but there’s a lot to remember and this version is simpler because it uses the standard array indexing syntax. Examples >>> np.s_[2::2]
slice(2, None, 2)
>>> np.index_exp[2::2]
(slice(2, None, 2),)
 >>> np.array([0, 1, 2, 3, 4])[np.s_[2::2]]
array([2, 4])
numpy.save   numpy.save(file, arr, allow_pickle=True, fix_imports=True)[source]
 
Save an array to a binary file in NumPy .npy format.  Parameters 
 
filefile, str, or pathlib.Path


File or filename to which the data is saved. If file is a file-object, then the filename is unchanged. If file is a string or Path, a .npy extension will be appended to the filename if it does not already have one.  
arrarray_like


Array data to be saved.  
allow_picklebool, optional


Allow saving object arrays using Python pickles. Reasons for disallowing pickles include security (loading pickled data can execute arbitrary code) and portability (pickled objects may not be loadable on different Python installations, for example if the stored objects require libraries that are not available, and not all pickled data is compatible between Python 2 and Python 3). Default: True  
fix_importsbool, optional


Only useful in forcing objects in object arrays on Python 3 to be pickled in a Python 2 compatible way. If fix_imports is True, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2.      See also  savez

Save several arrays into a .npz archive  
savetxt, load

  Notes For a description of the .npy format, see numpy.lib.format. Any data saved to the file is appended to the end of the file. Examples >>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile()
 >>> x = np.arange(10)
>>> np.save(outfile, x)
 >>> _ = outfile.seek(0) # Only needed here to simulate closing & reopening file
>>> np.load(outfile)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
 >>> with open('test.npy', 'wb') as f:
...     np.save(f, np.array([1, 2]))
...     np.save(f, np.array([1, 3]))
>>> with open('test.npy', 'rb') as f:
...     a = np.load(f)
...     b = np.load(f)
>>> print(a, b)
# [1 2] [1 3]
numpy.savez   numpy.savez(file, *args, **kwds)[source]
 
Save several arrays into a single file in uncompressed .npz format. Provide arrays as keyword arguments to store them under the corresponding name in the output file: savez(fn, x=x, y=y). If arrays are specified as positional arguments, i.e., savez(fn,
x, y), their names will be arr_0, arr_1, etc.  Parameters 
 
filestr or file


Either the filename (string) or an open file (file-like object) where the data will be saved. If file is a string or a Path, the .npz extension will be appended to the filename if it is not already there.  
argsArguments, optional


Arrays to save to the file. Please use keyword arguments (see kwds below) to assign names to arrays. Arrays specified as args will be named “arr_0”, “arr_1”, and so on.  
kwdsKeyword arguments, optional


Arrays to save to the file. Each array will be saved to the output file with its corresponding keyword name.    Returns 
 None
    See also  save

Save a single array to a binary file in NumPy format.  savetxt

Save an array to a file as plain text.  savez_compressed

Save several arrays into a compressed .npz archive    Notes The .npz file format is a zipped archive of files named after the variables they contain. The archive is not compressed and each file in the archive contains one variable in .npy format. For a description of the .npy format, see numpy.lib.format. When opening the saved .npz file with load a NpzFile object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the .files attribute), and for the arrays themselves. Keys passed in kwds are used as filenames inside the ZIP archive. Therefore, keys should be valid filenames; e.g., avoid keys that begin with / or contain .. When naming variables with keyword arguments, it is not possible to name a variable file, as this would cause the file argument to be defined twice in the call to savez. Examples >>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile()
>>> x = np.arange(10)
>>> y = np.sin(x)
 Using savez with *args, the arrays are saved with default names. >>> np.savez(outfile, x, y)
>>> _ = outfile.seek(0) # Only needed here to simulate closing & reopening file
>>> npzfile = np.load(outfile)
>>> npzfile.files
['arr_0', 'arr_1']
>>> npzfile['arr_0']
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
 Using savez with **kwds, the arrays are saved with the keyword names. >>> outfile = TemporaryFile()
>>> np.savez(outfile, x=x, y=y)
>>> _ = outfile.seek(0)
>>> npzfile = np.load(outfile)
>>> sorted(npzfile.files)
['x', 'y']
>>> npzfile['x']
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])