neulab/docprompting-conala huggingface dataset:
numpy.take_along_axis   numpy.take_along_axis(arr, indices, axis)[source]
 
Take values from the input array by matching 1d index and data slices. This iterates over matching 1d slices oriented along the specified axis in the index and data arrays, and uses the former to look up values in the latter. These slices can be different lengths. Functions returning an index along an axis, like argsort and argpartition, produce suitable indices for this function.  New in version 1.15.0.   Parameters 
 
arrndarray (Ni…, M, Nk…)


Source array  
indicesndarray (Ni…, J, Nk…)


Indices to take along each 1d slice of arr. This must match the dimension of arr, but dimensions Ni and Nj only need to broadcast against arr.  
axisint


The axis to take 1d slices along. If axis is None, the input array is treated as if it had first been flattened to 1d, for consistency with sort and argsort.    Returns 
 out: ndarray (Ni…, J, Nk…)

The indexed result.      See also  take

Take along an axis, using the same indices for every 1d slice  put_along_axis

Put values into the destination array by matching 1d index and data slices    Notes This is equivalent to (but faster than) the following use of ndindex and s_, which sets each of ii and kk to a tuple of indices: Ni, M, Nk = a.shape[:axis], a.shape[axis], a.shape[axis+1:]
J = indices.shape[axis]  # Need not equal M
out = np.empty(Ni + (J,) + Nk)

for ii in ndindex(Ni):
    for kk in ndindex(Nk):
        a_1d       = a      [ii + s_[:,] + kk]
        indices_1d = indices[ii + s_[:,] + kk]
        out_1d     = out    [ii + s_[:,] + kk]
        for j in range(J):
            out_1d[j] = a_1d[indices_1d[j]]
 Equivalently, eliminating the inner loop, the last two lines would be: out_1d[:] = a_1d[indices_1d]
 Examples For this sample array >>> a = np.array([[10, 30, 20], [60, 40, 50]])
 We can sort either by using sort directly, or argsort and this function >>> np.sort(a, axis=1)
array([[10, 20, 30],
       [40, 50, 60]])
>>> ai = np.argsort(a, axis=1); ai
array([[0, 2, 1],
       [1, 2, 0]])
>>> np.take_along_axis(a, ai, axis=1)
array([[10, 20, 30],
       [40, 50, 60]])
 The same works for max and min, if you expand the dimensions: >>> np.expand_dims(np.max(a, axis=1), axis=1)
array([[30],
       [60]])
>>> ai = np.expand_dims(np.argmax(a, axis=1), axis=1)
>>> ai
array([[1],
       [0]])
>>> np.take_along_axis(a, ai, axis=1)
array([[30],
       [60]])
 If we want to get the max and min at the same time, we can stack the indices first >>> ai_min = np.expand_dims(np.argmin(a, axis=1), axis=1)
>>> ai_max = np.expand_dims(np.argmax(a, axis=1), axis=1)
>>> ai = np.concatenate([ai_min, ai_max], axis=1)
>>> ai
array([[0, 1],
       [1, 0]])
>>> np.take_along_axis(a, ai, axis=1)
array([[10, 30],
       [40, 60]])
numpy.tan   numpy.tan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'tan'>
 
Compute tangent element-wise. Equivalent to np.sin(x)/np.cos(x) element-wise.  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 
 
yndarray


The corresponding tangent 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 >>> from math import pi
>>> np.tan(np.array([-pi,pi/2,pi]))
array([  1.22460635e-16,   1.63317787e+16,  -1.22460635e-16])
>>>
>>> # Example of providing the optional output parameter illustrating
>>> # that what is returned is a reference to said 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.tanh   numpy.tanh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'tanh'>
 
Compute hyperbolic tangent element-wise. Equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(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 
 
yndarray


The corresponding hyperbolic tangent 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  1 
M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972, pg. 83. https://personal.math.ubc.ca/~cbm/aands/page_83.htm  2 
Wikipedia, “Hyperbolic function”, https://en.wikipedia.org/wiki/Hyperbolic_function   Examples >>> np.tanh((0, np.pi*1j, np.pi*1j/2))
array([ 0. +0.00000000e+00j,  0. -1.22460635e-16j,  0. +1.63317787e+16j])
 >>> # Example of providing the optional output parameter illustrating
>>> # that what is returned is a reference to said parameter
>>> out1 = np.array([0], dtype='d')
>>> out2 = np.tanh([0.1], out1)
>>> out2 is out1
True
 >>> # Example of ValueError due to provision of shape mis-matched `out`
>>> np.tanh(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.testing.suppress_warnings   class numpy.testing.suppress_warnings(forwarding_rule='always')[source]
 
Context manager and decorator doing much the same as warnings.catch_warnings. However, it also provides a filter mechanism to work around https://bugs.python.org/issue4180. This bug causes Python before 3.4 to not reliably show warnings again after they have been ignored once (even within catch_warnings). It means that no “ignore” filter can be used easily, since following tests might need to see the warning. Additionally it allows easier specificity for testing warnings and can be nested.  Parameters 
 
forwarding_rulestr, optional


One of “always”, “once”, “module”, or “location”. Analogous to the usual warnings module filter mode, it is useful to reduce noise mostly on the outmost level. Unsuppressed and unrecorded warnings will be forwarded based on this rule. Defaults to “always”. “location” is equivalent to the warnings “default”, match by exact location the warning warning originated from.     Notes Filters added inside the context manager will be discarded again when leaving it. Upon entering all filters defined outside a context will be applied automatically. When a recording filter is added, matching warnings are stored in the log attribute as well as in the list returned by record. If filters are added and the module keyword is given, the warning registry of this module will additionally be cleared when applying it, entering the context, or exiting it. This could cause warnings to appear a second time after leaving the context if they were configured to be printed once (default) and were already printed before the context was entered. Nesting this context manager will work as expected when the forwarding rule is “always” (default). Unfiltered and unrecorded warnings will be passed out and be matched by the outer level. On the outmost level they will be printed (or caught by another warnings context). The forwarding rule argument can modify this behaviour. Like catch_warnings this context manager is not threadsafe. Examples With a context manager: with np.testing.suppress_warnings() as sup:
    sup.filter(DeprecationWarning, "Some text")
    sup.filter(module=np.ma.core)
    log = sup.record(FutureWarning, "Does this occur?")
    command_giving_warnings()
    # The FutureWarning was given once, the filtered warnings were
    # ignored. All other warnings abide outside settings (may be
    # printed/error)
    assert_(len(log) == 1)
    assert_(len(sup.log) == 1)  # also stored in log attribute
 Or as a decorator: sup = np.testing.suppress_warnings()
sup.filter(module=np.ma.core)  # module must match exactly
@sup
def some_function():
    # do something which causes a warning in np.ma.core
    pass
 Methods  
__call__(func) Function decorator to apply certain suppressions to a whole function.  
filter([category, message, module]) Add a new suppressing filter or apply it if the state is entered.  
record([category, message, module]) Append a new recording filter or apply it if the state is entered.
numpy.testing.Tester   numpy.testing.Tester[source]
 
alias of numpy.testing._private.nosetester.NoseTester
numpy.tile   numpy.tile(A, reps)[source]
 
Construct an array by repeating A the number of times given by reps. If reps has length d, the result will have dimension of max(d, A.ndim). If A.ndim < d, A is promoted to be d-dimensional by prepending new axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication, or shape (1, 1, 3) for 3-D replication. If this is not the desired behavior, promote A to d-dimensions manually before calling this function. If A.ndim > d, reps is promoted to A.ndim by pre-pending 1’s to it. Thus for an A of shape (2, 3, 4, 5), a reps of (2, 2) is treated as (1, 1, 2, 2). Note : Although tile may be used for broadcasting, it is strongly recommended to use numpy’s broadcasting operations and functions.  Parameters 
 
Aarray_like


The input array.  
repsarray_like


The number of repetitions of A along each axis.    Returns 
 
cndarray


The tiled output array.      See also  repeat

Repeat elements of an array.  broadcast_to

Broadcast an array to a new shape    Examples >>> a = np.array([0, 1, 2])
>>> np.tile(a, 2)
array([0, 1, 2, 0, 1, 2])
>>> np.tile(a, (2, 2))
array([[0, 1, 2, 0, 1, 2],
       [0, 1, 2, 0, 1, 2]])
>>> np.tile(a, (2, 1, 2))
array([[[0, 1, 2, 0, 1, 2]],
       [[0, 1, 2, 0, 1, 2]]])
 >>> b = np.array([[1, 2], [3, 4]])
>>> np.tile(b, 2)
array([[1, 2, 1, 2],
       [3, 4, 3, 4]])
>>> np.tile(b, (2, 1))
array([[1, 2],
       [3, 4],
       [1, 2],
       [3, 4]])
 >>> c = np.array([1,2,3,4])
>>> np.tile(c,(4,1))
array([[1, 2, 3, 4],
       [1, 2, 3, 4],
       [1, 2, 3, 4],
       [1, 2, 3, 4]])
class numpy.timedelta64[source]
 
A timedelta stored as a 64-bit integer. See Datetimes and Timedeltas for more information.  Character code 
'm'
numpy.trace   numpy.trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None)[source]
 
Return the sum along diagonals of the array. If a is 2-D, the sum along its diagonal with the given offset is returned, i.e., the sum of elements a[i,i+offset] for all i. If a has more than two dimensions, then the axes specified by axis1 and axis2 are used to determine the 2-D sub-arrays whose traces are returned. The shape of the resulting array is the same as that of a with axis1 and axis2 removed.  Parameters 
 
aarray_like


Input array, from which the diagonals are taken.  
offsetint, optional


Offset of the diagonal from the main diagonal. Can be both positive and negative. Defaults to 0.  
axis1, axis2int, optional


Axes to be used as the first and second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults are the first two axes of a.  
dtypedtype, optional


Determines the data-type of the returned array and of the accumulator where the elements are summed. If dtype has the value None and a is of integer type of precision less than the default integer precision, then the default integer precision is used. Otherwise, the precision is the same as that of a.  
outndarray, optional


Array into which the output is placed. Its type is preserved and it must be of the right shape to hold the output.    Returns 
 
sum_along_diagonalsndarray


If a is 2-D, the sum along the diagonal is returned. If a has larger dimensions, then an array of sums along diagonals is returned.      See also  
diag, diagonal, diagflat

  Examples >>> np.trace(np.eye(3))
3.0
>>> a = np.arange(8).reshape((2,2,2))
>>> np.trace(a)
array([6, 8])
 >>> a = np.arange(24).reshape((2,2,2,3))
>>> np.trace(a).shape
(2, 3)
numpy.transpose   numpy.transpose(a, axes=None)[source]
 
Reverse or permute the axes of an array; returns the modified array. For an array a with two axes, transpose(a) gives the matrix transpose. Refer to numpy.ndarray.transpose for full documentation.  Parameters 
 
aarray_like


Input array.  
axestuple or list of ints, optional


If specified, it must be a tuple or list which contains a permutation of [0,1,..,N-1] where N is the number of axes of a. The i’th axis of the returned array will correspond to the axis numbered axes[i] of the input. If not specified, defaults to range(a.ndim)[::-1], which reverses the order of the axes.    Returns 
 
pndarray


a with its axes permuted. A view is returned whenever possible.      See also  ndarray.transpose

Equivalent method  moveaxis
argsort
  Notes Use transpose(a, argsort(axes)) to invert the transposition of tensors when using the axes keyword argument. Transposing a 1-D array returns an unchanged view of the original array. Examples >>> x = np.arange(4).reshape((2,2))
>>> x
array([[0, 1],
       [2, 3]])
 >>> np.transpose(x)
array([[0, 2],
       [1, 3]])
 >>> x = np.ones((1, 2, 3))
>>> np.transpose(x, (1, 0, 2)).shape
(2, 1, 3)
 >>> x = np.ones((2, 3, 4, 5))
>>> np.transpose(x).shape
(5, 4, 3, 2)
numpy.trapz   numpy.trapz(y, x=None, dx=1.0, axis=- 1)[source]
 
Integrate along the given axis using the composite trapezoidal rule. If x is provided, the integration happens in sequence along its elements - they are not sorted. Integrate y (x) along each 1d slice on the given axis, compute \(\int y(x) dx\). When x is specified, this integrates along the parametric curve, computing \(\int_t y(t) dt = \int_t y(t) \left.\frac{dx}{dt}\right|_{x=x(t)} dt\).  Parameters 
 
yarray_like


Input array to integrate.  
xarray_like, optional


The sample points corresponding to the y values. If x is None, the sample points are assumed to be evenly spaced dx apart. The default is None.  
dxscalar, optional


The spacing between sample points when x is None. The default is 1.  
axisint, optional


The axis along which to integrate.    Returns 
 
trapzfloat or ndarray


Definite integral of ‘y’ = n-dimensional array as approximated along a single axis by the trapezoidal rule. If ‘y’ is a 1-dimensional array, then the result is a float. If ‘n’ is greater than 1, then the result is an ‘n-1’ dimensional array.      See also  
sum, cumsum

  Notes Image [2] illustrates trapezoidal rule – y-axis locations of points will be taken from y array, by default x-axis distances between points will be 1.0, alternatively they can be provided with x array or with dx scalar. Return value will be equal to combined area under the red lines. References  1 
Wikipedia page: https://en.wikipedia.org/wiki/Trapezoidal_rule  2 
Illustration image: https://en.wikipedia.org/wiki/File:Composite_trapezoidal_rule_illustration.png   Examples >>> np.trapz([1,2,3])
4.0
>>> np.trapz([1,2,3], x=[4,6,8])
8.0
>>> np.trapz([1,2,3], dx=2)
8.0
 Using a decreasing x corresponds to integrating in reverse: >>> np.trapz([1,2,3], x=[8,6,4])
-8.0
 More generally x is used to integrate along a parametric curve. This finds the area of a circle, noting we repeat the sample which closes the curve: >>> theta = np.linspace(0, 2 * np.pi, num=1000, endpoint=True)
>>> np.trapz(np.cos(theta), x=np.sin(theta))
3.141571941375841
 >>> a = np.arange(6).reshape(2, 3)
>>> a
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.trapz(a, axis=0)
array([1.5, 2.5, 3.5])
>>> np.trapz(a, axis=1)
array([2.,  8.])
numpy.tri   numpy.tri(N, M=None, k=0, dtype=<class 'float'>, *, like=None)[source]
 
An array with ones at and below the given diagonal and zeros elsewhere.  Parameters 
 
Nint


Number of rows in the array.  
Mint, optional


Number of columns in the array. By default, M is taken equal to N.  
kint, optional


The sub-diagonal at and below which the array is filled. k = 0 is the main diagonal, while k < 0 is below it, and k > 0 is above. The default is 0.  
dtypedtype, optional


Data type of the returned array. The default is float.  
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 
 
trindarray of shape (N, M)


Array with its lower triangle filled with ones and zero elsewhere; in other words T[i,j] == 1 for j <= i + k, 0 otherwise.     Examples >>> np.tri(3, 5, 2, dtype=int)
array([[1, 1, 1, 0, 0],
       [1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1]])
 >>> np.tri(3, 5, -1)
array([[0.,  0.,  0.,  0.,  0.],
       [1.,  0.,  0.,  0.,  0.],
       [1.,  1.,  0.,  0.,  0.]])
numpy.tril   numpy.tril(m, k=0)[source]
 
Lower triangle of an array. Return a copy of an array with elements above the k-th diagonal zeroed. For arrays with ndim exceeding 2, tril will apply to the final two axes.  Parameters 
 
marray_like, shape (…, M, N)


Input array.  
kint, optional


Diagonal above which to zero elements. k = 0 (the default) is the main diagonal, k < 0 is below it and k > 0 is above.    Returns 
 
trilndarray, shape (…, M, N)


Lower triangle of m, of same shape and data-type as m.      See also  triu

same thing, only for the upper triangle    Examples >>> np.tril([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)
array([[ 0,  0,  0],
       [ 4,  0,  0],
       [ 7,  8,  0],
       [10, 11, 12]])
 >>> np.tril(np.arange(3*4*5).reshape(3, 4, 5))
array([[[ 0,  0,  0,  0,  0],
        [ 5,  6,  0,  0,  0],
        [10, 11, 12,  0,  0],
        [15, 16, 17, 18,  0]],
       [[20,  0,  0,  0,  0],
        [25, 26,  0,  0,  0],
        [30, 31, 32,  0,  0],
        [35, 36, 37, 38,  0]],
       [[40,  0,  0,  0,  0],
        [45, 46,  0,  0,  0],
        [50, 51, 52,  0,  0],
        [55, 56, 57, 58,  0]]])
numpy.tril_indices   numpy.tril_indices(n, k=0, m=None)[source]
 
Return the indices for the lower-triangle of an (n, m) array.  Parameters 
 
nint


The row dimension of the arrays for which the returned indices will be valid.  
kint, optional


Diagonal offset (see tril for details).  
mint, optional


 New in version 1.9.0.  The column dimension of the arrays for which the returned arrays will be valid. By default m is taken equal to n.    Returns 
 
indstuple of arrays


The indices for the triangle. The returned tuple contains two arrays, each with the indices along one dimension of the array.      See also  triu_indices

similar function, for upper-triangular.  mask_indices

generic function accepting an arbitrary mask function.  
tril, triu

  Notes  New in version 1.4.0.  Examples Compute two different sets of indices to access 4x4 arrays, one for the lower triangular part starting at the main diagonal, and one starting two diagonals further right: >>> il1 = np.tril_indices(4)
>>> il2 = np.tril_indices(4, 2)
 Here is how they can be used with a sample array: >>> a = np.arange(16).reshape(4, 4)
>>> a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15]])
 Both for indexing: >>> a[il1]
array([ 0,  4,  5, ..., 13, 14, 15])
 And for assigning values: >>> a[il1] = -1
>>> a
array([[-1,  1,  2,  3],
       [-1, -1,  6,  7],
       [-1, -1, -1, 11],
       [-1, -1, -1, -1]])
 These cover almost the whole array (two diagonals right of the main one): >>> a[il2] = -10
>>> a
array([[-10, -10, -10,   3],
       [-10, -10, -10, -10],
       [-10, -10, -10, -10],
       [-10, -10, -10, -10]])
numpy.tril_indices_from   numpy.tril_indices_from(arr, k=0)[source]
 
Return the indices for the lower-triangle of arr. See tril_indices for full details.  Parameters 
 
arrarray_like


The indices will be valid for square arrays whose dimensions are the same as arr.  
kint, optional


Diagonal offset (see tril for details).      See also  
tril_indices, tril

  Notes  New in version 1.4.0.
numpy.trim_zeros   numpy.trim_zeros(filt, trim='fb')[source]
 
Trim the leading and/or trailing zeros from a 1-D array or sequence.  Parameters 
 
filt1-D array or sequence


Input array.  
trimstr, optional


A string with ‘f’ representing trim from front and ‘b’ to trim from back. Default is ‘fb’, trim zeros from both front and back of the array.    Returns 
 
trimmed1-D array or sequence


The result of trimming the input. The input data type is preserved.     Examples >>> a = np.array((0, 0, 0, 1, 2, 3, 0, 2, 1, 0))
>>> np.trim_zeros(a)
array([1, 2, 3, 0, 2, 1])
 >>> np.trim_zeros(a, 'b')
array([0, 0, 0, ..., 0, 2, 1])
 The input data type is preserved, list/tuple in means list/tuple out. >>> np.trim_zeros([0, 1, 2, 0])
[1, 2]
numpy.triu   numpy.triu(m, k=0)[source]
 
Upper triangle of an array. Return a copy of an array with the elements below the k-th diagonal zeroed. For arrays with ndim exceeding 2, triu will apply to the final two axes. Please refer to the documentation for tril for further details.  See also  tril

lower triangle of an array    Examples >>> np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)
array([[ 1,  2,  3],
       [ 4,  5,  6],
       [ 0,  8,  9],
       [ 0,  0, 12]])
 >>> np.triu(np.arange(3*4*5).reshape(3, 4, 5))
array([[[ 0,  1,  2,  3,  4],
        [ 0,  6,  7,  8,  9],
        [ 0,  0, 12, 13, 14],
        [ 0,  0,  0, 18, 19]],
       [[20, 21, 22, 23, 24],
        [ 0, 26, 27, 28, 29],
        [ 0,  0, 32, 33, 34],
        [ 0,  0,  0, 38, 39]],
       [[40, 41, 42, 43, 44],
        [ 0, 46, 47, 48, 49],
        [ 0,  0, 52, 53, 54],
        [ 0,  0,  0, 58, 59]]])