neulab/docprompting-conala huggingface dataset:
numpy.linalg.solve   linalg.solve(a, b)[source]
 
Solve a linear matrix equation, or system of linear scalar equations. Computes the “exact” solution, x, of the well-determined, i.e., full rank, linear matrix equation ax = b.  Parameters 
 
a(…, M, M) array_like


Coefficient matrix.  
b{(…, M,), (…, M, K)}, array_like


Ordinate or “dependent variable” values.    Returns 
 
x{(…, M,), (…, M, K)} ndarray


Solution to the system a x = b. Returned shape is identical to b.    Raises 
 LinAlgError

If a is singular or not square.      See also  scipy.linalg.solve

Similar function in SciPy.    Notes  New in version 1.8.0.  Broadcasting rules apply, see the numpy.linalg documentation for details. The solutions are computed using LAPACK routine _gesv. a must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent; if either is not true, use lstsq for the least-squares best “solution” of the system/equation. References  1 
G. Strang, Linear Algebra and Its Applications, 2nd Ed., Orlando, FL, Academic Press, Inc., 1980, pg. 22.   Examples Solve the system of equations x0 + 2 * x1 = 1 and 3 * x0 + 5 * x1 = 2: >>> a = np.array([[1, 2], [3, 5]])
>>> b = np.array([1, 2])
>>> x = np.linalg.solve(a, b)
>>> x
array([-1.,  1.])
 Check that the solution is correct: >>> np.allclose(np.dot(a, x), b)
True
numpy.linalg.tensorinv   linalg.tensorinv(a, ind=2)[source]
 
Compute the ‘inverse’ of an N-dimensional array. The result is an inverse for a relative to the tensordot operation tensordot(a, b, ind), i. e., up to floating-point accuracy, tensordot(tensorinv(a), a, ind) is the “identity” tensor for the tensordot operation.  Parameters 
 
aarray_like


Tensor to ‘invert’. Its shape must be ‘square’, i. e., prod(a.shape[:ind]) == prod(a.shape[ind:]).  
indint, optional


Number of first indices that are involved in the inverse sum. Must be a positive integer, default is 2.    Returns 
 
bndarray


a’s tensordot inverse, shape a.shape[ind:] + a.shape[:ind].    Raises 
 LinAlgError

If a is singular or not ‘square’ (in the above sense).      See also  
numpy.tensordot, tensorsolve

  Examples >>> a = np.eye(4*6)
>>> a.shape = (4, 6, 8, 3)
>>> ainv = np.linalg.tensorinv(a, ind=2)
>>> ainv.shape
(8, 3, 4, 6)
>>> b = np.random.randn(4, 6)
>>> np.allclose(np.tensordot(ainv, b), np.linalg.tensorsolve(a, b))
True
 >>> a = np.eye(4*6)
>>> a.shape = (24, 8, 3)
>>> ainv = np.linalg.tensorinv(a, ind=1)
>>> ainv.shape
(8, 3, 24)
>>> b = np.random.randn(24)
>>> np.allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b))
True
numpy.linalg.tensorsolve   linalg.tensorsolve(a, b, axes=None)[source]
 
Solve the tensor equation a x = b for x. It is assumed that all indices of x are summed over in the product, together with the rightmost indices of a, as is done in, for example, tensordot(a, x, axes=b.ndim).  Parameters 
 
aarray_like


Coefficient tensor, of shape b.shape + Q. Q, a tuple, equals the shape of that sub-tensor of a consisting of the appropriate number of its rightmost indices, and must be such that prod(Q) == prod(b.shape) (in which sense a is said to be ‘square’).  
barray_like


Right-hand tensor, which can be of any shape.  
axestuple of ints, optional


Axes in a to reorder to the right, before inversion. If None (default), no reordering is done.    Returns 
 
xndarray, shape Q

  Raises 
 LinAlgError

If a is singular or not ‘square’ (in the above sense).      See also  
numpy.tensordot, tensorinv, numpy.einsum

  Examples >>> a = np.eye(2*3*4)
>>> a.shape = (2*3, 4, 2, 3, 4)
>>> b = np.random.randn(2*3, 4)
>>> x = np.linalg.tensorsolve(a, b)
>>> x.shape
(2, 3, 4)
>>> np.allclose(np.tensordot(a, x, axes=3), b)
True
numpy.ma.all   ma.all(self, axis=None, out=None, keepdims=<no value>) = <numpy.ma.core._frommethod object>
 
Returns True if all elements evaluate to True. The output array is masked where all the values along the given axis are masked: if the output would have been a scalar and that all the values are masked, then the output is masked. Refer to numpy.all for full documentation.  See also  numpy.ndarray.all

corresponding function for ndarrays  numpy.all

equivalent function    Examples >>> np.ma.array([1,2,3]).all()
True
>>> a = np.ma.array([1,2,3], mask=True)
>>> (a.all() is np.ma.masked)
True
numpy.ma.allclose   ma.allclose(a, b, masked_equal=True, rtol=1e-05, atol=1e-08)[source]
 
Returns True if two arrays are element-wise equal within a tolerance. This function is equivalent to allclose except that masked values are treated as equal (default) or unequal, depending on the masked_equal argument.  Parameters 
 
a, barray_like


Input arrays to compare.  
masked_equalbool, optional


Whether masked values in a and b are considered equal (True) or not (False). They are considered equal by default.  
rtolfloat, optional


Relative tolerance. The relative difference is equal to rtol * b. Default is 1e-5.  
atolfloat, optional


Absolute tolerance. The absolute difference is equal to atol. Default is 1e-8.    Returns 
 
ybool


Returns True if the two arrays are equal within the given tolerance, False otherwise. If either array contains NaN, then False is returned.      See also  
all, any

numpy.allclose

the non-masked allclose.    Notes If the following equation is element-wise True, then allclose returns True: absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
 Return True if all elements of a and b are equal subject to given tolerances. Examples >>> a = np.ma.array([1e10, 1e-7, 42.0], mask=[0, 0, 1])
>>> a
masked_array(data=[10000000000.0, 1e-07, --],
             mask=[False, False,  True],
       fill_value=1e+20)
>>> b = np.ma.array([1e10, 1e-8, -42.0], mask=[0, 0, 1])
>>> np.ma.allclose(a, b)
False
 >>> a = np.ma.array([1e10, 1e-8, 42.0], mask=[0, 0, 1])
>>> b = np.ma.array([1.00001e10, 1e-9, -42.0], mask=[0, 0, 1])
>>> np.ma.allclose(a, b)
True
>>> np.ma.allclose(a, b, masked_equal=False)
False
 Masked values are not compared directly. >>> a = np.ma.array([1e10, 1e-8, 42.0], mask=[0, 0, 1])
>>> b = np.ma.array([1.00001e10, 1e-9, 42.0], mask=[0, 0, 1])
>>> np.ma.allclose(a, b)
True
>>> np.ma.allclose(a, b, masked_equal=False)
False
numpy.ma.allequal   ma.allequal(a, b, fill_value=True)[source]
 
Return True if all entries of a and b are equal, using fill_value as a truth value where either or both are masked.  Parameters 
 
a, barray_like


Input arrays to compare.  
fill_valuebool, optional


Whether masked values in a or b are considered equal (True) or not (False).    Returns 
 
ybool


Returns True if the two arrays are equal within the given tolerance, False otherwise. If either array contains NaN, then False is returned.      See also  
all, any

numpy.ma.allclose
  Examples >>> a = np.ma.array([1e10, 1e-7, 42.0], mask=[0, 0, 1])
>>> a
masked_array(data=[10000000000.0, 1e-07, --],
             mask=[False, False,  True],
       fill_value=1e+20)
 >>> b = np.array([1e10, 1e-7, -42.0])
>>> b
array([  1.00000000e+10,   1.00000000e-07,  -4.20000000e+01])
>>> np.ma.allequal(a, b, fill_value=False)
False
>>> np.ma.allequal(a, b)
True
numpy.ma.anom   ma.anom(self, axis=None, dtype=None) = <numpy.ma.core._frommethod object>
 
Compute the anomalies (deviations from the arithmetic mean) along the given axis. Returns an array of anomalies, with the same shape as the input and where the arithmetic mean is computed along the given axis.  Parameters 
 
axisint, optional


Axis over which the anomalies are taken. The default is to use the mean of the flattened array as reference.  
dtypedtype, optional


 Type to use in computing the variance. For arrays of integer type

the default is float32; for arrays of float types it is the same as the array type.        See also  mean

Compute the mean of the array.    Examples >>> a = np.ma.array([1,2,3])
>>> a.anom()
masked_array(data=[-1.,  0.,  1.],
             mask=False,
       fill_value=1e+20)
numpy.ma.anomalies   ma.anomalies(self, axis=None, dtype=None) = <numpy.ma.core._frommethod object>
 
Compute the anomalies (deviations from the arithmetic mean) along the given axis. Returns an array of anomalies, with the same shape as the input and where the arithmetic mean is computed along the given axis.  Parameters 
 
axisint, optional


Axis over which the anomalies are taken. The default is to use the mean of the flattened array as reference.  
dtypedtype, optional


 Type to use in computing the variance. For arrays of integer type

the default is float32; for arrays of float types it is the same as the array type.        See also  mean

Compute the mean of the array.    Examples >>> a = np.ma.array([1,2,3])
>>> a.anom()
masked_array(data=[-1.,  0.,  1.],
             mask=False,
       fill_value=1e+20)
numpy.ma.any   ma.any(self, axis=None, out=None, keepdims=<no value>) = <numpy.ma.core._frommethod object>
 
Returns True if any of the elements of a evaluate to True. Masked values are considered as False during computation. Refer to numpy.any for full documentation.  See also  numpy.ndarray.any

corresponding function for ndarrays  numpy.any

equivalent function
numpy.ma.append   ma.append(a, b, axis=None)[source]
 
Append values to the end of an array.  New in version 1.9.0.   Parameters 
 
aarray_like


Values are appended to a copy of this array.  
barray_like


These values are appended to a copy of a. It must be of the correct shape (the same shape as a, excluding axis). If axis is not specified, b can be any shape and will be flattened before use.  
axisint, optional


The axis along which v are appended. If axis is not given, both a and b are flattened before use.    Returns 
 
appendMaskedArray


A copy of a with b appended to axis. Note that append does not occur in-place: a new array is allocated and filled. If axis is None, the result is a flattened array.      See also  numpy.append

Equivalent function in the top-level NumPy module.    Examples >>> import numpy.ma as ma
>>> a = ma.masked_values([1, 2, 3], 2)
>>> b = ma.masked_values([[4, 5, 6], [7, 8, 9]], 7)
>>> ma.append(a, b)
masked_array(data=[1, --, 3, 4, 5, 6, --, 8, 9],
             mask=[False,  True, False, False, False, False,  True, False,
                   False],
       fill_value=999999)
numpy.ma.apply_along_axis   ma.apply_along_axis(func1d, axis, arr, *args, **kwargs)[source]
 
Apply a function to 1-D slices along the given axis. Execute func1d(a, *args, **kwargs) where func1d operates on 1-D arrays and a is a 1-D slice of arr along axis. This is equivalent to (but faster than) the following use of ndindex and s_, which sets each of ii, jj, and kk to a tuple of indices: Ni, Nk = a.shape[:axis], a.shape[axis+1:]
for ii in ndindex(Ni):
    for kk in ndindex(Nk):
        f = func1d(arr[ii + s_[:,] + kk])
        Nj = f.shape
        for jj in ndindex(Nj):
            out[ii + jj + kk] = f[jj]
 Equivalently, eliminating the inner loop, this can be expressed as: Ni, Nk = a.shape[:axis], a.shape[axis+1:]
for ii in ndindex(Ni):
    for kk in ndindex(Nk):
        out[ii + s_[...,] + kk] = func1d(arr[ii + s_[:,] + kk])
  Parameters 
 
func1dfunction (M,) -> (Nj…)


This function should accept 1-D arrays. It is applied to 1-D slices of arr along the specified axis.  
axisinteger


Axis along which arr is sliced.  
arrndarray (Ni…, M, Nk…)


Input array.  
argsany


Additional arguments to func1d.  
kwargsany


Additional named arguments to func1d.  New in version 1.9.0.     Returns 
 
outndarray (Ni…, Nj…, Nk…)


The output array. The shape of out is identical to the shape of arr, except along the axis dimension. This axis is removed, and replaced with new dimensions equal to the shape of the return value of func1d. So if func1d returns a scalar out will have one fewer dimensions than arr.      See also  apply_over_axes

Apply a function repeatedly over multiple axes.    Examples >>> def my_func(a):
...     """Average first and last element of a 1-D array"""
...     return (a[0] + a[-1]) * 0.5
>>> b = np.array([[1,2,3], [4,5,6], [7,8,9]])
>>> np.apply_along_axis(my_func, 0, b)
array([4., 5., 6.])
>>> np.apply_along_axis(my_func, 1, b)
array([2.,  5.,  8.])
 For a function that returns a 1D array, the number of dimensions in outarr is the same as arr. >>> b = np.array([[8,1,7], [4,3,9], [5,2,6]])
>>> np.apply_along_axis(sorted, 1, b)
array([[1, 7, 8],
       [3, 4, 9],
       [2, 5, 6]])
 For a function that returns a higher dimensional array, those dimensions are inserted in place of the axis dimension. >>> b = np.array([[1,2,3], [4,5,6], [7,8,9]])
>>> np.apply_along_axis(np.diag, -1, b)
array([[[1, 0, 0],
        [0, 2, 0],
        [0, 0, 3]],
       [[4, 0, 0],
        [0, 5, 0],
        [0, 0, 6]],
       [[7, 0, 0],
        [0, 8, 0],
        [0, 0, 9]]])
numpy.ma.apply_over_axes   ma.apply_over_axes(func, a, axes)[source]
 
Apply a function repeatedly over multiple axes. func is called as res = func(a, axis), where axis is the first element of axes. The result res of the function call must have either the same dimensions as a or one less dimension. If res has one less dimension than a, a dimension is inserted before axis. The call to func is then repeated for each axis in axes, with res as the first argument.  Parameters 
 
funcfunction


This function must take two arguments, func(a, axis).  
aarray_like


Input array.  
axesarray_like


Axes over which func is applied; the elements must be integers.    Returns 
 
apply_over_axisndarray


The output array. The number of dimensions is the same as a, but the shape can be different. This depends on whether func changes the shape of its output with respect to its input.      See also  apply_along_axis

Apply a function to 1-D slices of an array along the given axis.    Examples >>> a = np.ma.arange(24).reshape(2,3,4)
>>> a[:,0,1] = np.ma.masked
>>> a[:,1,:] = np.ma.masked
>>> a
masked_array(
  data=[[[0, --, 2, 3],
         [--, --, --, --],
         [8, 9, 10, 11]],
        [[12, --, 14, 15],
         [--, --, --, --],
         [20, 21, 22, 23]]],
  mask=[[[False,  True, False, False],
         [ True,  True,  True,  True],
         [False, False, False, False]],
        [[False,  True, False, False],
         [ True,  True,  True,  True],
         [False, False, False, False]]],
  fill_value=999999)
>>> np.ma.apply_over_axes(np.ma.sum, a, [0,2])
masked_array(
  data=[[[46],
         [--],
         [124]]],
  mask=[[[False],
         [ True],
         [False]]],
  fill_value=999999)
 Tuple axis arguments to ufuncs are equivalent: >>> np.ma.sum(a, axis=(0,2)).reshape((1,-1,1))
masked_array(
  data=[[[46],
         [--],
         [124]]],
  mask=[[[False],
         [ True],
         [False]]],
  fill_value=999999)
numpy.ma.arange   ma.arange([start, ]stop, [step, ]dtype=None, *, like=None) = <numpy.ma.core._convert2ma object>
 
Return evenly spaced values within a given interval. Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments the function is equivalent to the Python built-in range function, but returns an ndarray rather than a list. When using a non-integer step, such as 0.1, it is often better to use numpy.linspace. See the warnings section below for more information.  Parameters 
 
startinteger or real, optional


Start of interval. The interval includes this value. The default start value is 0.  
stopinteger or real


End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out.  
stepinteger or real, optional


Spacing between values. For any output out, this is the distance between two adjacent values, out[i+1] - out[i]. The default step size is 1. If step is specified as a position argument, start must also be given.  
dtypedtype


The type of the output array. If dtype is not given, infer the data type from the other input arguments.  
likearray_like


Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.  New in version 1.20.0.     Returns 
 
arangeMaskedArray


Array of evenly spaced values. For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.      Warning The length of the output might not be numerically stable. Another stability issue is due to the internal implementation of numpy.arange. The actual step value used to populate the array is dtype(start + step) - dtype(start) and not step. Precision loss can occur here, due to casting or due to using floating points when start is much larger than step. This can lead to unexpected behaviour. For example: >>> np.arange(0, 5, 0.5, dtype=int)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
>>> np.arange(-3, 3, 0.5, dtype=int)
array([-3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7,  8])
 In such cases, the use of numpy.linspace should be preferred.   See also  numpy.linspace

Evenly spaced numbers with careful handling of endpoints.  numpy.ogrid

Arrays of evenly spaced numbers in N-dimensions.  numpy.mgrid

Grid-shaped arrays of evenly spaced numbers in N-dimensions.    Examples >>> np.arange(3)
array([0, 1, 2])
>>> np.arange(3.0)
array([ 0.,  1.,  2.])
>>> np.arange(3,7)
array([3, 4, 5, 6])
>>> np.arange(3,7,2)
array([3, 5])
numpy.ma.argmax   ma.argmax(self, axis=None, fill_value=None, out=None) = <numpy.ma.core._frommethod object>
 
Returns array of indices of the maximum values along the given axis. Masked values are treated as if they had the value fill_value.  Parameters 
 
axis{None, integer}


If None, the index is into the flattened array, otherwise along the specified axis  
fill_valuescalar or None, optional


Value used to fill in the masked values. If None, the output of maximum_fill_value(self._data) is used instead.  
out{None, array}, optional


Array into which the result can be placed. Its type is preserved and it must be of the right shape to hold the output.    Returns 
 
index_array{integer_array}

   Examples >>> a = np.arange(6).reshape(2,3)
>>> a.argmax()
5
>>> a.argmax(0)
array([1, 1, 1])
>>> a.argmax(1)
array([2, 2])
numpy.ma.argmin   ma.argmin(self, axis=None, fill_value=None, out=None) = <numpy.ma.core._frommethod object>
 
Return array of indices to the minimum values along the given axis.  Parameters 
 
axis{None, integer}


If None, the index is into the flattened array, otherwise along the specified axis  
fill_valuescalar or None, optional


Value used to fill in the masked values. If None, the output of minimum_fill_value(self._data) is used instead.  
out{None, array}, optional


Array into which the result can be placed. Its type is preserved and it must be of the right shape to hold the output.    Returns 
 ndarray or scalar

If multi-dimension input, returns a new ndarray of indices to the minimum values along the given axis. Otherwise, returns a scalar of index to the minimum values along the given axis.     Examples >>> x = np.ma.array(np.arange(4), mask=[1,1,0,0])
>>> x.shape = (2,2)
>>> x
masked_array(
  data=[[--, --],
        [2, 3]],
  mask=[[ True,  True],
        [False, False]],
  fill_value=999999)
>>> x.argmin(axis=0, fill_value=-1)
array([0, 0])
>>> x.argmin(axis=0, fill_value=9)
array([1, 1])
numpy.ma.argsort   ma.argsort(a, axis=<no value>, kind=None, order=None, endwith=True, fill_value=None)[source]
 
Return an ndarray of indices that sort the array along the specified axis. Masked values are filled beforehand to fill_value.  Parameters 
 
axisint, optional


Axis along which to sort. If None, the default, the flattened array is used.  Changed in version 1.13.0: Previously, the default was documented to be -1, but that was in error. At some future date, the default will change to -1, as originally intended. Until then, the axis should be given explicitly when arr.ndim > 1, to avoid a FutureWarning.   
kind{‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’}, optional


The sorting algorithm used.  
orderlist, optional


When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. Not all fields need be specified.  
endwith{True, False}, optional


Whether missing values (if any) should be treated as the largest values (True) or the smallest values (False) When the array contains unmasked values at the same extremes of the datatype, the ordering of these values and the masked values is undefined.  
fill_valuescalar or None, optional


Value used internally for the masked values. If fill_value is not None, it supersedes endwith.    Returns 
 
index_arrayndarray, int


Array of indices that sort a along the specified axis. In other words, a[index_array] yields a sorted a.      See also  ma.MaskedArray.sort

Describes sorting algorithms used.  lexsort

Indirect stable sort with multiple keys.  numpy.ndarray.sort

Inplace sort.    Notes See sort for notes on the different sorting algorithms. Examples >>> a = np.ma.array([3,2,1], mask=[False, False, True])
>>> a
masked_array(data=[3, 2, --],
             mask=[False, False,  True],
       fill_value=999999)
>>> a.argsort()
array([1, 0, 2])
numpy.ma.around   ma.around = <numpy.ma.core._MaskedUnaryOperation object>
 
Round an array to the given number of decimals.  See also  around

equivalent function; see for details.
numpy.ma.asanyarray   ma.asanyarray(a, dtype=None)[source]
 
Convert the input to a masked array, conserving subclasses. If a is a subclass of MaskedArray, its class is conserved. No copy is performed if the input is already an ndarray.  Parameters 
 
aarray_like


Input data, in any form that can be converted to an array.  
dtypedtype, optional


By default, the data-type is inferred from the input data.  
order{‘C’, ‘F’}, optional


Whether to use row-major (‘C’) or column-major (‘FORTRAN’) memory representation. Default is ‘C’.    Returns 
 
outMaskedArray


MaskedArray interpretation of a.      See also  asarray

Similar to asanyarray, but does not conserve subclass.    Examples >>> x = np.arange(10.).reshape(2, 5)
>>> x
array([[0., 1., 2., 3., 4.],
       [5., 6., 7., 8., 9.]])
>>> np.ma.asanyarray(x)
masked_array(
  data=[[0., 1., 2., 3., 4.],
        [5., 6., 7., 8., 9.]],
  mask=False,
  fill_value=1e+20)
>>> type(np.ma.asanyarray(x))
<class 'numpy.ma.core.MaskedArray'>
numpy.ma.asarray   ma.asarray(a, dtype=None, order=None)[source]
 
Convert the input to a masked array of the given data-type. No copy is performed if the input is already an ndarray. If a is a subclass of MaskedArray, a base class MaskedArray is returned.  Parameters 
 
aarray_like


Input data, in any form that can be converted to a masked array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists, ndarrays and masked arrays.  
dtypedtype, optional


By default, the data-type is inferred from the input data.  
order{‘C’, ‘F’}, optional


Whether to use row-major (‘C’) or column-major (‘FORTRAN’) memory representation. Default is ‘C’.    Returns 
 
outMaskedArray


Masked array interpretation of a.      See also  asanyarray

Similar to asarray, but conserves subclasses.    Examples >>> x = np.arange(10.).reshape(2, 5)
>>> x
array([[0., 1., 2., 3., 4.],
       [5., 6., 7., 8., 9.]])
>>> np.ma.asarray(x)
masked_array(
  data=[[0., 1., 2., 3., 4.],
        [5., 6., 7., 8., 9.]],
  mask=False,
  fill_value=1e+20)
>>> type(np.ma.asarray(x))
<class 'numpy.ma.core.MaskedArray'>