neulab/docprompting-conala huggingface dataset:
numpy.convolve   numpy.convolve(a, v, mode='full')[source]
 
Returns the discrete, linear convolution of two one-dimensional sequences. The convolution operator is often seen in signal processing, where it models the effect of a linear time-invariant system on a signal [1]. In probability theory, the sum of two independent random variables is distributed according to the convolution of their individual distributions. If v is longer than a, the arrays are swapped before computation.  Parameters 
 
a(N,) array_like


First one-dimensional input array.  
v(M,) array_like


Second one-dimensional input array.  
mode{‘full’, ‘valid’, ‘same’}, optional


 ‘full’:

By default, mode is ‘full’. This returns the convolution at each point of overlap, with an output shape of (N+M-1,). At the end-points of the convolution, the signals do not overlap completely, and boundary effects may be seen.  ‘same’:

Mode ‘same’ returns output of length max(M, N). Boundary effects are still visible.  ‘valid’:

Mode ‘valid’ returns output of length max(M, N) - min(M, N) + 1. The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect.      Returns 
 
outndarray


Discrete, linear convolution of a and v.      See also  scipy.signal.fftconvolve

Convolve two arrays using the Fast Fourier Transform.  scipy.linalg.toeplitz

Used to construct the convolution operator.  polymul

Polynomial multiplication. Same output as convolve, but also accepts poly1d objects as input.    Notes The discrete convolution operation is defined as  \[(a * v)[n] = \sum_{m = -\infty}^{\infty} a[m] v[n - m]\] It can be shown that a convolution \(x(t) * y(t)\) in time/space is equivalent to the multiplication \(X(f) Y(f)\) in the Fourier domain, after appropriate padding (padding is necessary to prevent circular convolution). Since multiplication is more efficient (faster) than convolution, the function scipy.signal.fftconvolve exploits the FFT to calculate the convolution of large data-sets. References  1 
Wikipedia, “Convolution”, https://en.wikipedia.org/wiki/Convolution   Examples Note how the convolution operator flips the second array before “sliding” the two across one another: >>> np.convolve([1, 2, 3], [0, 1, 0.5])
array([0. , 1. , 2.5, 4. , 1.5])
 Only return the middle values of the convolution. Contains boundary effects, where zeros are taken into account: >>> np.convolve([1,2,3],[0,1,0.5], 'same')
array([1. ,  2.5,  4. ])
 The two arrays are of the same length, so there is only one position where they completely overlap: >>> np.convolve([1,2,3],[0,1,0.5], 'valid')
array([2.5])
numpy.copy   numpy.copy(a, order='K', subok=False)[source]
 
Return an array copy of the given object.  Parameters 
 
aarray_like


Input data.  
order{‘C’, ‘F’, ‘A’, ‘K’}, optional


Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and ndarray.copy are very similar, but have different default values for their order= arguments.)  
subokbool, optional


If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (defaults to False).  New in version 1.19.0.     Returns 
 
arrndarray


Array interpretation of a.      See also  ndarray.copy

Preferred method for creating an array copy    Notes This is equivalent to: >>> np.array(a, copy=True)  
 Examples Create an array x, with a reference y and a copy z: >>> x = np.array([1, 2, 3])
>>> y = x
>>> z = np.copy(x)
 Note that, when we modify x, y changes, but not z: >>> x[0] = 10
>>> x[0] == y[0]
True
>>> x[0] == z[0]
False
 Note that, np.copy clears previously set WRITEABLE=False flag. >>> a = np.array([1, 2, 3])
>>> a.flags["WRITEABLE"] = False
>>> b = np.copy(a)
>>> b.flags["WRITEABLE"]
True
>>> b[0] = 3
>>> b
array([3, 2, 3])
 Note that np.copy is a shallow copy and will not copy object elements within arrays. This is mainly important for arrays containing Python objects. The new array will contain the same object which may lead to surprises if that object can be modified (is mutable): >>> a = np.array([1, 'm', [2, 3, 4]], dtype=object)
>>> b = np.copy(a)
>>> b[2][0] = 10
>>> a
array([1, 'm', list([10, 3, 4])], dtype=object)
 To ensure all elements within an object array are copied, use copy.deepcopy: >>> import copy
>>> a = np.array([1, 'm', [2, 3, 4]], dtype=object)
>>> c = copy.deepcopy(a)
>>> c[2][0] = 10
>>> c
array([1, 'm', list([10, 3, 4])], dtype=object)
>>> a
array([1, 'm', list([2, 3, 4])], dtype=object)
numpy.copysign   numpy.copysign(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'copysign'>
 
Change the sign of x1 to that of x2, element-wise. If x2 is a scalar, its sign will be copied to all elements of x1.  Parameters 
 
x1array_like


Values to change the sign of.  
x2array_like


The sign of x2 is copied to 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 or scalar


The values of x1 with the sign of x2. This is a scalar if both x1 and x2 are scalars.     Examples >>> np.copysign(1.3, -1)
-1.3
>>> 1/np.copysign(0, 1)
inf
>>> 1/np.copysign(0, -1)
-inf
 >>> np.copysign([-1, 0, 1], -1.1)
array([-1., -0., -1.])
>>> np.copysign([-1, 0, 1], np.arange(3)-1)
array([-1.,  0.,  1.])
numpy.copyto   numpy.copyto(dst, src, casting='same_kind', where=True)
 
Copies values from one array to another, broadcasting as necessary. Raises a TypeError if the casting rule is violated, and if where is provided, it selects which elements to copy.  New in version 1.7.0.   Parameters 
 
dstndarray


The array into which values are copied.  
srcarray_like


The array from which values are copied.  
casting{‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional


Controls what kind of data casting may occur when copying.  ‘no’ means the data types should not be cast at all. ‘equiv’ means only byte-order changes are allowed. ‘safe’ means only casts which can preserve values are allowed. ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed. ‘unsafe’ means any data conversions may be done.   
wherearray_like of bool, optional


A boolean array which is broadcasted to match the dimensions of dst, and selects elements to copy from src to dst wherever it contains the value True.
numpy.correlate   numpy.correlate(a, v, mode='valid')[source]
 
Cross-correlation of two 1-dimensional sequences. This function computes the correlation as generally defined in signal processing texts: c_{av}[k] = sum_n a[n+k] * conj(v[n])
 with a and v sequences being zero-padded where necessary and conj being the conjugate.  Parameters 
 
a, varray_like


Input sequences.  
mode{‘valid’, ‘same’, ‘full’}, optional


Refer to the convolve docstring. Note that the default is ‘valid’, unlike convolve, which uses ‘full’.  
old_behaviorbool


old_behavior was removed in NumPy 1.10. If you need the old behavior, use multiarray.correlate.    Returns 
 
outndarray


Discrete cross-correlation of a and v.      See also  convolve

Discrete, linear convolution of two one-dimensional sequences.  multiarray.correlate

Old, no conjugate, version of correlate.  scipy.signal.correlate

uses FFT which has superior performance on large arrays.    Notes The definition of correlation above is not unique and sometimes correlation may be defined differently. Another common definition is: c'_{av}[k] = sum_n a[n] conj(v[n+k])
 which is related to c_{av}[k] by c'_{av}[k] = c_{av}[-k]. numpy.correlate may perform slowly in large arrays (i.e. n = 1e5) because it does not use the FFT to compute the convolution; in that case, scipy.signal.correlate might be preferable. Examples >>> np.correlate([1, 2, 3], [0, 1, 0.5])
array([3.5])
>>> np.correlate([1, 2, 3], [0, 1, 0.5], "same")
array([2. ,  3.5,  3. ])
>>> np.correlate([1, 2, 3], [0, 1, 0.5], "full")
array([0.5,  2. ,  3.5,  3. ,  0. ])
 Using complex sequences: >>> np.correlate([1+1j, 2, 3-1j], [0, 1, 0.5j], 'full')
array([ 0.5-0.5j,  1.0+0.j ,  1.5-1.5j,  3.0-1.j ,  0.0+0.j ])
 Note that you get the time reversed, complex conjugated result when the two input sequences change places, i.e., c_{va}[k] = c^{*}_{av}[-k]: >>> np.correlate([0, 1, 0.5j], [1+1j, 2, 3-1j], 'full')
array([ 0.0+0.j ,  3.0+1.j ,  1.5+1.5j,  1.0+0.j ,  0.5+0.5j])
numpy.cos   numpy.cos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'cos'>
 
Cosine element-wise.  Parameters 
 
xarray_like


Input array in radians.  
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 
 
yndarray


The corresponding cosine values. This is a scalar if x is a scalar.     Notes If out is provided, the function writes the result into it, and returns a reference to out. (See Examples) References M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972. Examples >>> np.cos(np.array([0, np.pi/2, np.pi]))
array([  1.00000000e+00,   6.12303177e-17,  -1.00000000e+00])
>>>
>>> # Example of providing the optional output parameter
>>> out1 = np.array([0], dtype='d')
>>> out2 = np.cos([0.1], out1)
>>> out2 is out1
True
>>>
>>> # Example of ValueError due to provision of shape mis-matched `out`
>>> np.cos(np.zeros((3,3)),np.zeros((2,2)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: operands could not be broadcast together with shapes (3,3) (2,2)
numpy.cosh   numpy.cosh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'cosh'>
 
Hyperbolic cosine, element-wise. Equivalent to 1/2 * (np.exp(x) + np.exp(-x)) and np.cos(1j*x).  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 of same shape as x. This is a scalar if x is a scalar.     Examples >>> np.cosh(0)
1.0
 The hyperbolic cosine describes the shape of a hanging cable: >>> import matplotlib.pyplot as plt
>>> x = np.linspace(-4, 4, 1000)
>>> plt.plot(x, np.cosh(x))
>>> plt.show()
numpy.count_nonzero   numpy.count_nonzero(a, axis=None, *, keepdims=False)[source]
 
Counts the number of non-zero values in the array a. The word “non-zero” is in reference to the Python 2.x built-in method __nonzero__() (renamed __bool__() in Python 3.x) of Python objects that tests an object’s “truthfulness”. For example, any number is considered truthful if it is nonzero, whereas any string is considered truthful if it is not the empty string. Thus, this function (recursively) counts how many elements in a (and in sub-arrays thereof) have their __nonzero__() or __bool__() method evaluated to True.  Parameters 
 
aarray_like


The array for which to count non-zeros.  
axisint or tuple, optional


Axis or tuple of axes along which to count non-zeros. Default is None, meaning that non-zeros will be counted along a flattened version of a.  New in version 1.12.0.   
keepdimsbool, optional


If this is set to True, the axes that are counted are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.  New in version 1.19.0.     Returns 
 
countint or array of int


Number of non-zero values in the array along a given axis. Otherwise, the total number of non-zero values in the array is returned.      See also  nonzero

Return the coordinates of all the non-zero values.    Examples >>> np.count_nonzero(np.eye(4))
4
>>> a = np.array([[0, 1, 7, 0],
...               [3, 0, 2, 19]])
>>> np.count_nonzero(a)
5
>>> np.count_nonzero(a, axis=0)
array([1, 1, 2, 1])
>>> np.count_nonzero(a, axis=1)
array([2, 3])
>>> np.count_nonzero(a, axis=1, keepdims=True)
array([[2],
       [3]])
numpy.cross   numpy.cross(a, b, axisa=- 1, axisb=- 1, axisc=- 1, axis=None)[source]
 
Return the cross product of two (arrays of) vectors. The cross product of a and b in \(R^3\) is a vector perpendicular to both a and b. If a and b are arrays of vectors, the vectors are defined by the last axis of a and b by default, and these axes can have dimensions 2 or 3. Where the dimension of either a or b is 2, the third component of the input vector is assumed to be zero and the cross product calculated accordingly. In cases where both input vectors have dimension 2, the z-component of the cross product is returned.  Parameters 
 
aarray_like


Components of the first vector(s).  
barray_like


Components of the second vector(s).  
axisaint, optional


Axis of a that defines the vector(s). By default, the last axis.  
axisbint, optional


Axis of b that defines the vector(s). By default, the last axis.  
axiscint, optional


Axis of c containing the cross product vector(s). Ignored if both input vectors have dimension 2, as the return is scalar. By default, the last axis.  
axisint, optional


If defined, the axis of a, b and c that defines the vector(s) and cross product(s). Overrides axisa, axisb and axisc.    Returns 
 
cndarray


Vector cross product(s).    Raises 
 ValueError

When the dimension of the vector(s) in a and/or b does not equal 2 or 3.      See also  inner

Inner product  outer

Outer product.  ix_

Construct index arrays.    Notes  New in version 1.9.0.  Supports full broadcasting of the inputs. Examples Vector cross-product. >>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> np.cross(x, y)
array([-3,  6, -3])
 One vector with dimension 2. >>> x = [1, 2]
>>> y = [4, 5, 6]
>>> np.cross(x, y)
array([12, -6, -3])
 Equivalently: >>> x = [1, 2, 0]
>>> y = [4, 5, 6]
>>> np.cross(x, y)
array([12, -6, -3])
 Both vectors with dimension 2. >>> x = [1,2]
>>> y = [4,5]
>>> np.cross(x, y)
array(-3)
 Multiple vector cross-products. Note that the direction of the cross product vector is defined by the right-hand rule. >>> x = np.array([[1,2,3], [4,5,6]])
>>> y = np.array([[4,5,6], [1,2,3]])
>>> np.cross(x, y)
array([[-3,  6, -3],
       [ 3, -6,  3]])
 The orientation of c can be changed using the axisc keyword. >>> np.cross(x, y, axisc=0)
array([[-3,  3],
       [ 6, -6],
       [-3,  3]])
 Change the vector definition of x and y using axisa and axisb. >>> x = np.array([[1,2,3], [4,5,6], [7, 8, 9]])
>>> y = np.array([[7, 8, 9], [4,5,6], [1,2,3]])
>>> np.cross(x, y)
array([[ -6,  12,  -6],
       [  0,   0,   0],
       [  6, -12,   6]])
>>> np.cross(x, y, axisa=0, axisb=0)
array([[-24,  48, -24],
       [-30,  60, -30],
       [-36,  72, -36]])
class numpy.csingle[source]
 
Complex number type composed of two single-precision floating-point numbers.  Character code 
'F'  Alias 
numpy.singlecomplex  Alias on this platform (Linux x86_64) 
numpy.complex64: Complex number type composed of 2 32-bit-precision floating-point numbers.
numpy.ctypeslib.as_ctypes(obj)[source]
 
Create and return a ctypes object from a numpy array. Actually anything that exposes the __array_interface__ is accepted.
numpy.ctypeslib.as_ctypes_type(dtype)[source]
 
Convert a dtype into a ctypes type.  Parameters 
 
dtypedtype


The dtype to convert    Returns 
 ctype

A ctype scalar, union, array, or struct    Raises 
 NotImplementedError

If the conversion is not possible     Notes This function does not losslessly round-trip in either direction. np.dtype(as_ctypes_type(dt)) will:  insert padding fields reorder fields to be sorted by offset discard field titles  as_ctypes_type(np.dtype(ctype)) will:  discard the class names of ctypes.Structures and ctypes.Unions convert single-element ctypes.Unions into single-element ctypes.Structures insert padding fields
class numpy.ctypeslib.c_intp
 
A ctypes signed integer type of the same size as numpy.intp. Depending on the platform, it can be an alias for either c_int, c_long or c_longlong.
numpy.ctypeslib.load_library(libname, loader_path)[source]
 
It is possible to load a library using >>> lib = ctypes.cdll[<full_path_name>] 
 But there are cross-platform considerations, such as library file extensions, plus the fact Windows will just load the first library it finds with that name. NumPy supplies the load_library function as a convenience.  Changed in version 1.20.0: Allow libname and loader_path to take any path-like object.   Parameters 
 
libnamepath-like


Name of the library, which can have ‘lib’ as a prefix, but without an extension.  
loader_pathpath-like


Where the library can be found.    Returns 
 
ctypes.cdll[libpath]library object


A ctypes library object    Raises 
 OSError

If there is no library with the expected extension, or the library is defective and cannot be loaded.
numpy.ctypeslib.ndpointer(dtype=None, ndim=None, shape=None, flags=None)[source]
 
Array-checking restype/argtypes. An ndpointer instance is used to describe an ndarray in restypes and argtypes specifications. This approach is more flexible than using, for example, POINTER(c_double), since several restrictions can be specified, which are verified upon calling the ctypes function. These include data type, number of dimensions, shape and flags. If a given array does not satisfy the specified restrictions, a TypeError is raised.  Parameters 
 
dtypedata-type, optional


Array data-type.  
ndimint, optional


Number of array dimensions.  
shapetuple of ints, optional


Array shape.  
flagsstr or tuple of str


Array flags; may be one or more of:  C_CONTIGUOUS / C / CONTIGUOUS F_CONTIGUOUS / F / FORTRAN OWNDATA / O WRITEABLE / W ALIGNED / A WRITEBACKIFCOPY / X UPDATEIFCOPY / U     Returns 
 
klassndpointer type object


A type object, which is an _ndtpr instance containing dtype, ndim, shape and flags information.    Raises 
 TypeError

If a given array does not satisfy the specified restrictions.     Examples >>> clib.somefunc.argtypes = [np.ctypeslib.ndpointer(dtype=np.float64,
...                                                  ndim=1,
...                                                  flags='C_CONTIGUOUS')]
... 
>>> clib.somefunc(np.array([1, 2, 3], dtype=np.float64))
...
numpy.cumprod   numpy.cumprod(a, axis=None, dtype=None, out=None)[source]
 
Return the cumulative product of elements along a given axis.  Parameters 
 
aarray_like


Input array.  
axisint, optional


Axis along which the cumulative product is computed. By default the input is flattened.  
dtypedtype, optional


Type of the returned array, as well as of the accumulator in which the elements are multiplied. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used instead.  
outndarray, optional


Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type of the resulting values will be cast if necessary.    Returns 
 
cumprodndarray


A new array holding the result is returned unless out is specified, in which case a reference to out is returned.      See also  Output type determination
  Notes Arithmetic is modular when using integer types, and no error is raised on overflow. Examples >>> a = np.array([1,2,3])
>>> np.cumprod(a) # intermediate results 1, 1*2
...               # total product 1*2*3 = 6
array([1, 2, 6])
>>> a = np.array([[1, 2, 3], [4, 5, 6]])
>>> np.cumprod(a, dtype=float) # specify type of output
array([   1.,    2.,    6.,   24.,  120.,  720.])
 The cumulative product for each column (i.e., over the rows) of a: >>> np.cumprod(a, axis=0)
array([[ 1,  2,  3],
       [ 4, 10, 18]])
 The cumulative product for each row (i.e. over the columns) of a: >>> np.cumprod(a,axis=1)
array([[  1,   2,   6],
       [  4,  20, 120]])
numpy.cumsum   numpy.cumsum(a, axis=None, dtype=None, out=None)[source]
 
Return the cumulative sum of the elements along a given axis.  Parameters 
 
aarray_like


Input array.  
axisint, optional


Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array.  
dtypedtype, optional


Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.  
outndarray, optional


Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. See Output type determination for more details.    Returns 
 
cumsum_along_axisndarray.


A new array holding the result is returned unless out is specified, in which case a reference to out is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.      See also  sum

Sum array elements.  trapz

Integration of array values using the composite trapezoidal rule.  diff

Calculate the n-th discrete difference along given axis.    Notes Arithmetic is modular when using integer types, and no error is raised on overflow. cumsum(a)[-1] may not be equal to sum(a) for floating-point values since sum may use a pairwise summation routine, reducing the roundoff-error. See sum for more information. Examples >>> a = np.array([[1,2,3], [4,5,6]])
>>> a
array([[1, 2, 3],
       [4, 5, 6]])
>>> np.cumsum(a)
array([ 1,  3,  6, 10, 15, 21])
>>> np.cumsum(a, dtype=float)     # specifies type of output value(s)
array([  1.,   3.,   6.,  10.,  15.,  21.])
 >>> np.cumsum(a,axis=0)      # sum over rows for each of the 3 columns
array([[1, 2, 3],
       [5, 7, 9]])
>>> np.cumsum(a,axis=1)      # sum over columns for each of the 2 rows
array([[ 1,  3,  6],
       [ 4,  9, 15]])
 cumsum(b)[-1] may not be equal to sum(b) >>> b = np.array([1, 2e-9, 3e-9] * 1000000)
>>> b.cumsum()[-1]
1000000.0050045159
>>> b.sum()
1000000.0050000029