neulab/docprompting-conala huggingface dataset:
numpy.polysub   numpy.polysub(a1, a2)[source]
 
Difference (subtraction) of two polynomials.  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.  Given two polynomials a1 and a2, returns a1 - a2. a1 and a2 can be either array_like sequences of the polynomials’ coefficients (including coefficients equal to zero), or poly1d objects.  Parameters 
 
a1, a2array_like or poly1d


Minuend and subtrahend polynomials, respectively.    Returns 
 
outndarray or poly1d


Array or poly1d object of the difference polynomial’s coefficients.      See also  
polyval, polydiv, polymul, polyadd

  Examples  \[(2 x^2 + 10 x - 2) - (3 x^2 + 10 x -4) = (-x^2 + 2)\] >>> np.polysub([2, 10, -2], [3, 10, -4])
array([-1,  0,  2])
numpy.polyval   numpy.polyval(p, x)[source]
 
Evaluate a polynomial at specific values.  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.  If p is of length N, this function returns the value: p[0]*x**(N-1) + p[1]*x**(N-2) + ... + p[N-2]*x + p[N-1] If x is a sequence, then p(x) is returned for each element of x. If x is another polynomial then the composite polynomial p(x(t)) is returned.  Parameters 
 
parray_like or poly1d object


1D array of polynomial coefficients (including coefficients equal to zero) from highest degree to the constant term, or an instance of poly1d.  
xarray_like or poly1d object


A number, an array of numbers, or an instance of poly1d, at which to evaluate p.    Returns 
 
valuesndarray or poly1d


If x is a poly1d instance, the result is the composition of the two polynomials, i.e., x is “substituted” in p and the simplified result is returned. In addition, the type of x - array_like or poly1d - governs the type of the output: x array_like => values array_like, x a poly1d object => values is also.      See also  poly1d

A polynomial class.    Notes Horner’s scheme [1] is used to evaluate the polynomial. Even so, for polynomials of high degree the values may be inaccurate due to rounding errors. Use carefully. If x is a subtype of ndarray the return value will be of the same type. References  1 
I. N. Bronshtein, K. A. Semendyayev, and K. A. Hirsch (Eng. trans. Ed.), Handbook of Mathematics, New York, Van Nostrand Reinhold Co., 1985, pg. 720.   Examples >>> np.polyval([3,0,1], 5)  # 3 * 5**2 + 0 * 5**1 + 1
76
>>> np.polyval([3,0,1], np.poly1d(5))
poly1d([76])
>>> np.polyval(np.poly1d([3,0,1]), 5)
76
>>> np.polyval(np.poly1d([3,0,1]), np.poly1d(5))
poly1d([76])
numpy.positive   numpy.positive(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'positive'>
 
Numerical positive, element-wise.  New in version 1.13.0.   Parameters 
 
xarray_like or scalar


Input array.    Returns 
 
yndarray or scalar


Returned array or scalar: y = +x. This is a scalar if x is a scalar.     Notes Equivalent to x.copy(), but only defined for types that support arithmetic. Examples >>> x1 = np.array(([1., -1.]))
>>> np.positive(x1)
array([ 1., -1.])
 The unary + operator can be used as a shorthand for np.positive on ndarrays. >>> x1 = np.array(([1., -1.]))
>>> +x1
array([ 1., -1.])
numpy.power   numpy.power(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'power'>
 
First array elements raised to powers from second array, element-wise. Raise each base in x1 to the positionally-corresponding power in x2. x1 and x2 must be broadcastable to the same shape. An integer type raised to a negative integer power will raise a ValueError. Negative values raised to a non-integral value will return nan. To get complex results, cast the input to complex, or specify the dtype to be complex (see the example below).  Parameters 
 
x1array_like


The bases.  
x2array_like


The exponents. 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 
 
yndarray


The bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars.      See also  float_power

power function that promotes integers to float    Examples Cube each element in an array. >>> x1 = np.arange(6)
>>> x1
[0, 1, 2, 3, 4, 5]
>>> np.power(x1, 3)
array([  0,   1,   8,  27,  64, 125])
 Raise the bases to different exponents. >>> x2 = [1.0, 2.0, 3.0, 3.0, 2.0, 1.0]
>>> np.power(x1, x2)
array([  0.,   1.,   8.,  27.,  16.,   5.])
 The effect of broadcasting. >>> x2 = np.array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]])
>>> x2
array([[1, 2, 3, 3, 2, 1],
       [1, 2, 3, 3, 2, 1]])
>>> np.power(x1, x2)
array([[ 0,  1,  8, 27, 16,  5],
       [ 0,  1,  8, 27, 16,  5]])
 The ** operator can be used as a shorthand for np.power on ndarrays. >>> x2 = np.array([1, 2, 3, 3, 2, 1])
>>> x1 = np.arange(6)
>>> x1 ** x2
array([ 0,  1,  8, 27, 16,  5])
 Negative values raised to a non-integral value will result in nan (and a warning will be generated). >>> x3 = np.array([-1.0, -4.0])
>>> with np.errstate(invalid='ignore'):
...     p = np.power(x3, 1.5)
...
>>> p
array([nan, nan])
 To get complex results, give the argument dtype=complex. >>> np.power(x3, 1.5, dtype=complex)
array([-1.83697020e-16-1.j, -1.46957616e-15-8.j])
numpy.printoptions   numpy.printoptions(*args, **kwargs)[source]
 
Context manager for setting print options. Set print options for the scope of the with block, and restore the old options at the end. See set_printoptions for the full description of available options.  See also  
set_printoptions, get_printoptions

  Examples >>> from numpy.testing import assert_equal
>>> with np.printoptions(precision=2):
...     np.array([2.0]) / 3
array([0.67])
 The as-clause of the with-statement gives the current print options: >>> with np.printoptions(precision=2) as opts:
...      assert_equal(opts, np.get_printoptions())
numpy.promote_types   numpy.promote_types(type1, type2)
 
Returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 may be safely cast. The returned data type is always in native byte order. This function is symmetric, but rarely associative.  Parameters 
 
type1dtype or dtype specifier


First data type.  
type2dtype or dtype specifier


Second data type.    Returns 
 
outdtype


The promoted data type.      See also  
result_type, dtype, can_cast

  Notes  New in version 1.6.0.  Starting in NumPy 1.9, promote_types function now returns a valid string length when given an integer or float dtype as one argument and a string dtype as another argument. Previously it always returned the input string dtype, even if it wasn’t long enough to store the max integer/float value converted to a string. Examples >>> np.promote_types('f4', 'f8')
dtype('float64')
 >>> np.promote_types('i8', 'f4')
dtype('float64')
 >>> np.promote_types('>i8', '<c8')
dtype('complex128')
 >>> np.promote_types('i4', 'S8')
dtype('S11')
 An example of a non-associative case: >>> p = np.promote_types
>>> p('S', p('i1', 'u1'))
dtype('S6')
>>> p(p('S', 'i1'), 'u1')
dtype('S4')
numpy.ptp   numpy.ptp(a, axis=None, out=None, keepdims=<no value>)[source]
 
Range of values (maximum - minimum) along an axis. The name of the function comes from the acronym for ‘peak to peak’.  Warning ptp preserves the data type of the array. This means the return value for an input of signed integers with n bits (e.g. np.int8, np.int16, etc) is also a signed integer with n bits. In that case, peak-to-peak values greater than 2**(n-1)-1 will be returned as negative values. An example with a work-around is shown below.   Parameters 
 
aarray_like


Input values.  
axisNone or int or tuple of ints, optional


Axis along which to find the peaks. By default, flatten the array. axis may be negative, in which case it counts from the last to the first axis.  New in version 1.15.0.  If this is a tuple of ints, a reduction is performed on multiple axes, instead of a single axis or all the axes as before.  
outarray_like


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 output values will be cast if necessary.  
keepdimsbool, optional


If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the ptp method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.    Returns 
 
ptpndarray


A new array holding the result, unless out was specified, in which case a reference to out is returned.     Examples >>> x = np.array([[4, 9, 2, 10],
...               [6, 9, 7, 12]])
 >>> np.ptp(x, axis=1)
array([8, 6])
 >>> np.ptp(x, axis=0)
array([2, 0, 5, 2])
 >>> np.ptp(x)
10
 This example shows that a negative value can be returned when the input is an array of signed integers. >>> y = np.array([[1, 127],
...               [0, 127],
...               [-1, 127],
...               [-2, 127]], dtype=np.int8)
>>> np.ptp(y, axis=1)
array([ 126,  127, -128, -127], dtype=int8)
 A work-around is to use the view() method to view the result as unsigned integers with the same bit width: >>> np.ptp(y, axis=1).view(np.uint8)
array([126, 127, 128, 129], dtype=uint8)
numpy.put   numpy.put(a, ind, v, mode='raise')[source]
 
Replaces specified elements of an array with given values. The indexing works on the flattened target array. put is roughly equivalent to: a.flat[ind] = v
  Parameters 
 
andarray


Target array.  
indarray_like


Target indices, interpreted as integers.  
varray_like


Values to place in a at target indices. If v is shorter than ind it will be repeated as necessary.  
mode{‘raise’, ‘wrap’, ‘clip’}, optional


Specifies how out-of-bounds indices will behave.  ‘raise’ – raise an error (default) ‘wrap’ – wrap around ‘clip’ – clip to the range  ‘clip’ mode means that all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers. In ‘raise’ mode, if an exception occurs the target array may still be modified.      See also  
putmask, place

put_along_axis

Put elements by matching the array and the index arrays    Examples >>> a = np.arange(5)
>>> np.put(a, [0, 2], [-44, -55])
>>> a
array([-44,   1, -55,   3,   4])
 >>> a = np.arange(5)
>>> np.put(a, 22, -5, mode='clip')
>>> a
array([ 0,  1,  2,  3, -5])
numpy.put_along_axis   numpy.put_along_axis(arr, indices, values, axis)[source]
 
Put values into the destination 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 place values into 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…)


Destination array.  
indicesndarray (Ni…, J, Nk…)


Indices to change along each 1d slice of arr. This must match the dimension of arr, but dimensions in Ni and Nj may be 1 to broadcast against arr.  
valuesarray_like (Ni…, J, Nk…)


values to insert at those indices. Its shape and dimension are broadcast to match that of indices.  
axisint


The axis to take 1d slices along. If axis is None, the destination array is treated as if a flattened 1d view had been created of it.      See also  take_along_axis

Take values from the input 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

for ii in ndindex(Ni):
    for kk in ndindex(Nk):
        a_1d       = a      [ii + s_[:,] + kk]
        indices_1d = indices[ii + s_[:,] + kk]
        values_1d  = values [ii + s_[:,] + kk]
        for j in range(J):
            a_1d[indices_1d[j]] = values_1d[j]
 Equivalently, eliminating the inner loop, the last two lines would be: a_1d[indices_1d] = values_1d
 Examples For this sample array >>> a = np.array([[10, 30, 20], [60, 40, 50]])
 We can replace the maximum values with: >>> ai = np.expand_dims(np.argmax(a, axis=1), axis=1)
>>> ai
array([[1],
       [0]])
>>> np.put_along_axis(a, ai, 99, axis=1)
>>> a
array([[10, 99, 20],
       [99, 40, 50]])
numpy.putmask   numpy.putmask(a, mask, values)
 
Changes elements of an array based on conditional and input values. Sets a.flat[n] = values[n] for each n where mask.flat[n]==True. If values is not the same size as a and mask then it will repeat. This gives behavior different from a[mask] = values.  Parameters 
 
andarray


Target array.  
maskarray_like


Boolean mask array. It has to be the same shape as a.  
valuesarray_like


Values to put into a where mask is True. If values is smaller than a it will be repeated.      See also  
place, put, take, copyto

  Examples >>> x = np.arange(6).reshape(2, 3)
>>> np.putmask(x, x>2, x**2)
>>> x
array([[ 0,  1,  2],
       [ 9, 16, 25]])
 If values is smaller than a it is repeated: >>> x = np.arange(5)
>>> np.putmask(x, x>1, [-33, -44])
>>> x
array([  0,   1, -33, -44, -33])
numpy.PZERO
 
IEEE 754 floating point representation of positive zero. Returns  yfloat


A floating point representation of positive zero.   See Also NZERO : Defines negative zero. isinf : Shows which elements are positive or negative infinity. isposinf : Shows which elements are positive infinity. isneginf : Shows which elements are negative infinity. isnan : Shows which elements are Not a Number.  isfiniteShows which elements are finite - not one of


Not a Number, positive infinity and negative infinity.   Notes NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). Positive zero is considered to be a finite number. Examples >>> np.PZERO
0.0
>>> np.NZERO
-0.0
 >>> np.isfinite([np.PZERO])
array([ True])
>>> np.isnan([np.PZERO])
array([False])
>>> np.isinf([np.PZERO])
array([False])
numpy.rad2deg   numpy.rad2deg(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'rad2deg'>
 
Convert angles from radians to degrees.  Parameters 
 
xarray_like


Angle 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 angle in degrees. This is a scalar if x is a scalar.      See also  deg2rad

Convert angles from degrees to radians.  unwrap

Remove large jumps in angle by wrapping.    Notes  New in version 1.3.0.  rad2deg(x) is 180 * x / pi. Examples >>> np.rad2deg(np.pi/2)
90.0
numpy.radians   numpy.radians(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'radians'>
 
Convert angles from degrees to radians.  Parameters 
 
xarray_like


Input array in degrees.  
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 radian values. This is a scalar if x is a scalar.      See also  deg2rad

equivalent function    Examples Convert a degree array to radians >>> deg = np.arange(12.) * 30.
>>> np.radians(deg)
array([ 0.        ,  0.52359878,  1.04719755,  1.57079633,  2.0943951 ,
        2.61799388,  3.14159265,  3.66519143,  4.1887902 ,  4.71238898,
        5.23598776,  5.75958653])
 >>> out = np.zeros((deg.shape))
>>> ret = np.radians(deg, out)
>>> ret is out
True
numpy.random.BitGenerator   class numpy.random.BitGenerator(seed=None)
 
Base Class for generic BitGenerators, which provide a stream of random bits based on different algorithms. Must be overridden.  Parameters 
 
seed{None, int, array_like[ints], SeedSequence}, optional


A seed to initialize the BitGenerator. If None, then fresh, unpredictable entropy will be pulled from the OS. If an int or array_like[ints] is passed, then it will be passed to ~`numpy.random.SeedSequence` to derive the initial BitGenerator state. One may also pass in a SeedSequence instance.      See also  SeedSequence
   Attributes 
 
lockthreading.Lock


Lock instance that is shared so that the same BitGenerator can be used in multiple Generators without corrupting the state. Code that generates values from a bit generator should hold the bit generator’s lock.     Methods  
random_raw(self[, size]) Return randoms as generated by the underlying BitGenerator
class numpy.random.Generator(bit_generator)
 
Container for the BitGenerators. Generator exposes a number of methods for generating random numbers drawn from a variety of probability distributions. In addition to the distribution-specific arguments, each method takes a keyword argument size that defaults to None. If size is None, then a single value is generated and returned. If size is an integer, then a 1-D array filled with generated values is returned. If size is a tuple, then an array with that shape is filled and returned. The function numpy.random.default_rng will instantiate a Generator with numpy’s default BitGenerator. No Compatibility Guarantee Generator does not provide a version compatibility guarantee. In particular, as better algorithms evolve the bit stream may change.  Parameters 
 
bit_generatorBitGenerator


BitGenerator to use as the core generator.      See also  default_rng

Recommended constructor for Generator.    Notes The Python stdlib module random contains pseudo-random number generator with a number of methods that are similar to the ones available in Generator. It uses Mersenne Twister, and this bit generator can be accessed using MT19937. Generator, besides being NumPy-aware, has the advantage that it provides a much larger number of probability distributions to choose from. Examples >>> from numpy.random import Generator, PCG64
>>> rng = Generator(PCG64())
>>> rng.standard_normal()
-0.203  # random
Mersenne Twister (MT19937)   class numpy.random.MT19937(seed=None)
 
Container for the Mersenne Twister pseudo-random number generator.  Parameters 
 
seed{None, int, array_like[ints], SeedSequence}, optional


A seed to initialize the BitGenerator. If None, then fresh, unpredictable entropy will be pulled from the OS. If an int or array_like[ints] is passed, then it will be passed to SeedSequence to derive the initial BitGenerator state. One may also pass in a SeedSequence instance.     Notes MT19937 provides a capsule containing function pointers that produce doubles, and unsigned 32 and 64- bit integers [1]. These are not directly consumable in Python and must be consumed by a Generator or similar object that supports low-level access. The Python stdlib module “random” also contains a Mersenne Twister pseudo-random number generator. State and Seeding The MT19937 state vector consists of a 624-element array of 32-bit unsigned integers plus a single integer value between 0 and 624 that indexes the current position within the main array. The input seed is processed by SeedSequence to fill the whole state. The first element is reset such that only its most significant bit is set. Parallel Features The preferred way to use a BitGenerator in parallel applications is to use the SeedSequence.spawn method to obtain entropy values, and to use these to generate new BitGenerators: >>> from numpy.random import Generator, MT19937, SeedSequence
>>> sg = SeedSequence(1234)
>>> rg = [Generator(MT19937(s)) for s in sg.spawn(10)]
 Another method is to use MT19937.jumped which advances the state as-if \(2^{128}\) random numbers have been generated ([1], [2]). This allows the original sequence to be split so that distinct segments can be used in each worker process. All generators should be chained to ensure that the segments come from the same sequence. >>> from numpy.random import Generator, MT19937, SeedSequence
>>> sg = SeedSequence(1234)
>>> bit_generator = MT19937(sg)
>>> rg = []
>>> for _ in range(10):
...    rg.append(Generator(bit_generator))
...    # Chain the BitGenerators
...    bit_generator = bit_generator.jumped()
 Compatibility Guarantee MT19937 makes a guarantee that a fixed seed and will always produce the same random integer stream. References  
1(1,2)
 
Hiroshi Haramoto, Makoto Matsumoto, and Pierre L’Ecuyer, “A Fast Jump Ahead Algorithm for Linear Recurrences in a Polynomial Space”, Sequences and Their Applications - SETA, 290–298, 2008.  2 
Hiroshi Haramoto, Makoto Matsumoto, Takuji Nishimura, François Panneton, Pierre L’Ecuyer, “Efficient Jump Ahead for F2-Linear Random Number Generators”, INFORMS JOURNAL ON COMPUTING, Vol. 20, No. 3, Summer 2008, pp. 385-390.    Attributes 
 lock: threading.Lock

Lock instance that is shared so that the same bit git generator can be used in multiple Generators without corrupting the state. Code that generates values from a bit generator should hold the bit generator’s lock.     
  State  
state Get or set the PRNG state     Parallel generation  
jumped([jumps]) Returns a new bit generator with the state jumped     Extending  
cffi CFFI interface  
ctypes ctypes interface