neulab/docprompting-conala huggingface dataset:
numpy.format_parser   class numpy.format_parser(formats, names, titles, aligned=False, byteorder=None)[source]
 
Class to convert formats, names, titles description to a dtype. After constructing the format_parser object, the dtype attribute is the converted data-type: dtype = format_parser(formats, names, titles).dtype  Parameters 
 
formatsstr or list of str


The format description, either specified as a string with comma-separated format descriptions in the form 'f8, i4, a5', or a list of format description strings in the form ['f8', 'i4', 'a5'].  
namesstr or list/tuple of str


The field names, either specified as a comma-separated string in the form 'col1, col2, col3', or as a list or tuple of strings in the form ['col1', 'col2', 'col3']. An empty list can be used, in that case default field names (‘f0’, ‘f1’, …) are used.  
titlessequence


Sequence of title strings. An empty list can be used to leave titles out.  
alignedbool, optional


If True, align the fields by padding as the C-compiler would. Default is False.  
byteorderstr, optional


If specified, all the fields will be changed to the provided byte-order. Otherwise, the default byte-order is used. For all available string specifiers, see dtype.newbyteorder.      See also  
dtype, typename, sctype2char

  Examples >>> np.format_parser(['<f8', '<i4', '<a5'], ['col1', 'col2', 'col3'],
...                  ['T1', 'T2', 'T3']).dtype
dtype([(('T1', 'col1'), '<f8'), (('T2', 'col2'), '<i4'), (('T3', 'col3'), 'S5')])
 names and/or titles can be empty lists. If titles is an empty list, titles will simply not appear. If names is empty, default field names will be used. >>> np.format_parser(['f8', 'i4', 'a5'], ['col1', 'col2', 'col3'],
...                  []).dtype
dtype([('col1', '<f8'), ('col2', '<i4'), ('col3', '<S5')])
>>> np.format_parser(['<f8', '<i4', '<a5'], [], []).dtype
dtype([('f0', '<f8'), ('f1', '<i4'), ('f2', 'S5')])
  Attributes 
 
dtypedtype


The converted data-type.
numpy.frexp   numpy.frexp(x, [out1, out2, ]/, [out=(None, None), ]*, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'frexp'>
 
Decompose the elements of x into mantissa and twos exponent. Returns (mantissa, exponent), where x = mantissa * 2**exponent`. The mantissa lies in the open interval(-1, 1), while the twos exponent is a signed integer.  Parameters 
 
xarray_like


Array of numbers to be decomposed.  
out1ndarray, optional


Output array for the mantissa. Must have the same shape as x.  
out2ndarray, optional


Output array for the exponent. Must have the same shape as x.  
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 
 
mantissandarray


Floating values between -1 and 1. This is a scalar if x is a scalar.  
exponentndarray


Integer exponents of 2. This is a scalar if x is a scalar.      See also  ldexp

Compute y = x1 * 2**x2, the inverse of frexp.    Notes Complex dtypes are not supported, they will raise a TypeError. Examples >>> x = np.arange(9)
>>> y1, y2 = np.frexp(x)
>>> y1
array([ 0.   ,  0.5  ,  0.5  ,  0.75 ,  0.5  ,  0.625,  0.75 ,  0.875,
        0.5  ])
>>> y2
array([0, 1, 2, 2, 3, 3, 3, 3, 4])
>>> y1 * 2**y2
array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.])
numpy.frombuffer   numpy.frombuffer(buffer, dtype=float, count=- 1, offset=0, *, like=None)
 
Interpret a buffer as a 1-dimensional array.  Parameters 
 
bufferbuffer_like


An object that exposes the buffer interface.  
dtypedata-type, optional


Data-type of the returned array; default: float.  
countint, optional


Number of items to read. -1 means all data in the buffer.  
offsetint, optional


Start reading the buffer from this offset (in bytes); default: 0.  
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 
 
outndarray

   Notes If the buffer has data that is not in machine byte-order, this should be specified as part of the data-type, e.g.: >>> dt = np.dtype(int)
>>> dt = dt.newbyteorder('>')
>>> np.frombuffer(buf, dtype=dt) 
 The data of the resulting array will not be byteswapped, but will be interpreted correctly. Examples >>> s = b'hello world'
>>> np.frombuffer(s, dtype='S1', count=5, offset=6)
array([b'w', b'o', b'r', b'l', b'd'], dtype='|S1')
 >>> np.frombuffer(b'\x01\x02', dtype=np.uint8)
array([1, 2], dtype=uint8)
>>> np.frombuffer(b'\x01\x02\x03\x04\x05', dtype=np.uint8, count=3)
array([1, 2, 3], dtype=uint8)
numpy.fromfile   numpy.fromfile(file, dtype=float, count=- 1, sep='', offset=0, *, like=None)
 
Construct an array from data in a text or binary file. A highly efficient way of reading binary data with a known data-type, as well as parsing simply formatted text files. Data written using the tofile method can be read using this function.  Parameters 
 
filefile or str or Path


Open file object or filename.  Changed in version 1.17.0: pathlib.Path objects are now accepted.   
dtypedata-type


Data type of the returned array. For binary files, it is used to determine the size and byte-order of the items in the file. Most builtin numeric types are supported and extension types may be supported.  New in version 1.18.0: Complex dtypes.   
countint


Number of items to read. -1 means all items (i.e., the complete file).  
sepstr


Separator between items if file is a text file. Empty (“”) separator means the file should be treated as binary. Spaces (” “) in the separator match zero or more whitespace characters. A separator consisting only of spaces must match at least one whitespace.  
offsetint


The offset (in bytes) from the file’s current position. Defaults to 0. Only permitted for binary files.  New in version 1.17.0.   
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.       See also  
load, save

ndarray.tofile
loadtxt

More flexible way of loading data from a text file.    Notes Do not rely on the combination of tofile and fromfile for data storage, as the binary files generated are not platform independent. In particular, no byte-order or data-type information is saved. Data can be stored in the platform independent .npy format using save and load instead. Examples Construct an ndarray: >>> dt = np.dtype([('time', [('min', np.int64), ('sec', np.int64)]),
...                ('temp', float)])
>>> x = np.zeros((1,), dtype=dt)
>>> x['time']['min'] = 10; x['temp'] = 98.25
>>> x
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i8'), ('sec', '<i8')]), ('temp', '<f8')])
 Save the raw data to disk: >>> import tempfile
>>> fname = tempfile.mkstemp()[1]
>>> x.tofile(fname)
 Read the raw data from disk: >>> np.fromfile(fname, dtype=dt)
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i8'), ('sec', '<i8')]), ('temp', '<f8')])
 The recommended way to store and load data: >>> np.save(fname, x)
>>> np.load(fname + '.npy')
array([((10, 0), 98.25)],
      dtype=[('time', [('min', '<i8'), ('sec', '<i8')]), ('temp', '<f8')])
numpy.fromfunction   numpy.fromfunction(function, shape, *, dtype=<class 'float'>, like=None, **kwargs)[source]
 
Construct an array by executing a function over each coordinate. The resulting array therefore has a value fn(x, y, z) at coordinate (x, y, z).  Parameters 
 
functioncallable


The function is called with N parameters, where N is the rank of shape. Each parameter represents the coordinates of the array varying along a specific axis. For example, if shape were (2, 2), then the parameters would be array([[0, 0], [1, 1]]) and array([[0, 1], [0, 1]])  
shape(N,) tuple of ints


Shape of the output array, which also determines the shape of the coordinate arrays passed to function.  
dtypedata-type, optional


Data-type of the coordinate arrays passed to function. By default, dtype 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 
 
fromfunctionany


The result of the call to function is passed back directly. Therefore the shape of fromfunction is completely determined by function. If function returns a scalar value, the shape of fromfunction would not match the shape parameter.      See also  
indices, meshgrid

  Notes Keywords other than dtype are passed to function. Examples >>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
array([[ True, False, False],
       [False,  True, False],
       [False, False,  True]])
 >>> np.fromfunction(lambda i, j: i + j, (3, 3), dtype=int)
array([[0, 1, 2],
       [1, 2, 3],
       [2, 3, 4]])
numpy.fromiter   numpy.fromiter(iter, dtype, count=- 1, *, like=None)
 
Create a new 1-dimensional array from an iterable object.  Parameters 
 
iteriterable object


An iterable object providing data for the array.  
dtypedata-type


The data-type of the returned array.  
countint, optional


The number of items to read from iterable. The default is -1, which means all data is read.  
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 
 
outndarray


The output array.     Notes Specify count to improve performance. It allows fromiter to pre-allocate the output array, instead of resizing it on demand. Examples >>> iterable = (x*x for x in range(5))
>>> np.fromiter(iterable, float)
array([  0.,   1.,   4.,   9.,  16.])
numpy.frompyfunc   numpy.frompyfunc(func, /, nin, nout, *[, identity])
 
Takes an arbitrary Python function and returns a NumPy ufunc. Can be used, for example, to add broadcasting to a built-in Python function (see Examples section).  Parameters 
 
funcPython function object


An arbitrary Python function.  
ninint


The number of input arguments.  
noutint


The number of objects returned by func.  
identityobject, optional


The value to use for the identity attribute of the resulting object. If specified, this is equivalent to setting the underlying C identity field to PyUFunc_IdentityValue. If omitted, the identity is set to PyUFunc_None. Note that this is _not_ equivalent to setting the identity to None, which implies the operation is reorderable.    Returns 
 
outufunc


Returns a NumPy universal function (ufunc) object.      See also  vectorize

Evaluates pyfunc over input arrays using broadcasting rules of numpy.    Notes The returned ufunc always returns PyObject arrays. Examples Use frompyfunc to add broadcasting to the Python function oct: >>> oct_array = np.frompyfunc(oct, 1, 1)
>>> oct_array(np.array((10, 30, 100)))
array(['0o12', '0o36', '0o144'], dtype=object)
>>> np.array((oct(10), oct(30), oct(100))) # for comparison
array(['0o12', '0o36', '0o144'], dtype='<U5')
numpy.fromregex   numpy.fromregex(file, regexp, dtype, encoding=None)[source]
 
Construct an array from a text file, using regular expression parsing. The returned array is always a structured array, and is constructed from all matches of the regular expression in the file. Groups in the regular expression are converted to fields of the structured array.  Parameters 
 
filepath or file


Filename or file object to read.  Changed in version 1.22.0: Now accepts os.PathLike implementations.   
regexpstr or regexp


Regular expression used to parse the file. Groups in the regular expression correspond to fields in the dtype.  
dtypedtype or list of dtypes


Dtype for the structured array; must be a structured datatype.  
encodingstr, optional


Encoding used to decode the inputfile. Does not apply to input streams.  New in version 1.14.0.     Returns 
 
outputndarray


The output array, containing the part of the content of file that was matched by regexp. output is always a structured array.    Raises 
 TypeError

When dtype is not a valid dtype for a structured array.      See also  
fromstring, loadtxt

  Notes Dtypes for structured arrays can be specified in several forms, but all forms specify at least the data type and field name. For details see basics.rec. Examples >>> from io import StringIO
>>> text = StringIO("1312 foo\n1534  bar\n444   qux")
 >>> regexp = r"(\d+)\s+(...)"  # match [digits, whitespace, anything]
>>> output = np.fromregex(text, regexp,
...                       [('num', np.int64), ('key', 'S3')])
>>> output
array([(1312, b'foo'), (1534, b'bar'), ( 444, b'qux')],
      dtype=[('num', '<i8'), ('key', 'S3')])
>>> output['num']
array([1312, 1534,  444])
numpy.fromstring   numpy.fromstring(string, dtype=float, count=- 1, *, sep, like=None)
 
A new 1-D array initialized from text data in a string.  Parameters 
 
stringstr


A string containing the data.  
dtypedata-type, optional


The data type of the array; default: float. For binary input data, the data must be in exactly this format. Most builtin numeric types are supported and extension types may be supported.  New in version 1.18.0: Complex dtypes.   
countint, optional


Read this number of dtype elements from the data. If this is negative (the default), the count will be determined from the length of the data.  
sepstr, optional


The string separating numbers in the data; extra whitespace between elements is also ignored.  Deprecated since version 1.14: Passing sep='', the default, is deprecated since it will trigger the deprecated binary mode of this function. This mode interprets string as binary bytes, rather than ASCII text with decimal numbers, an operation which is better spelt frombuffer(string, dtype, count). If string contains unicode text, the binary mode of fromstring will first encode it into bytes using either utf-8 (python 3) or the default encoding (python 2), neither of which produce sane results.   
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 
 
arrndarray


The constructed array.    Raises 
 ValueError

If the string is not the correct size to satisfy the requested dtype and count.      See also  
frombuffer, fromfile, fromiter

  Examples >>> np.fromstring('1 2', dtype=int, sep=' ')
array([1, 2])
>>> np.fromstring('1, 2', dtype=int, sep=',')
array([1, 2])
numpy.full   numpy.full(shape, fill_value, dtype=None, order='C', *, like=None)[source]
 
Return a new array of given shape and type, filled with fill_value.  Parameters 
 
shapeint or sequence of ints


Shape of the new array, e.g., (2, 3) or 2.  
fill_valuescalar or array_like


Fill value.  
dtypedata-type, optional


 The desired data-type for the array The default, None, means

np.array(fill_value).dtype.    
order{‘C’, ‘F’}, optional


Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory.  
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 
 
outndarray


Array of fill_value with the given shape, dtype, and order.      See also  full_like

Return a new array with shape of input filled with value.  empty

Return a new uninitialized array.  ones

Return a new array setting values to one.  zeros

Return a new array setting values to zero.    Examples >>> np.full((2, 2), np.inf)
array([[inf, inf],
       [inf, inf]])
>>> np.full((2, 2), 10)
array([[10, 10],
       [10, 10]])
 >>> np.full((2, 2), [1, 2])
array([[1, 2],
       [1, 2]])
numpy.full_like   numpy.full_like(a, fill_value, dtype=None, order='K', subok=True, shape=None)[source]
 
Return a full array with the same shape and type as a given array.  Parameters 
 
aarray_like


The shape and data-type of a define these same attributes of the returned array.  
fill_valuescalar


Fill value.  
dtypedata-type, optional


Overrides the data type of the result.  
order{‘C’, ‘F’, ‘A’, or ‘K’}, optional


Overrides the memory layout of the result. ‘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.  
subokbool, optional.


If True, then the newly created array will use the sub-class type of a, otherwise it will be a base-class array. Defaults to True.  
shapeint or sequence of ints, optional.


Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.  New in version 1.17.0.     Returns 
 
outndarray


Array of fill_value with the same shape and type as a.      See also  empty_like

Return an empty array with shape and type of input.  ones_like

Return an array of ones with shape and type of input.  zeros_like

Return an array of zeros with shape and type of input.  full

Return a new array of given shape filled with value.    Examples >>> x = np.arange(6, dtype=int)
>>> np.full_like(x, 1)
array([1, 1, 1, 1, 1, 1])
>>> np.full_like(x, 0.1)
array([0, 0, 0, 0, 0, 0])
>>> np.full_like(x, 0.1, dtype=np.double)
array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
>>> np.full_like(x, np.nan, dtype=np.double)
array([nan, nan, nan, nan, nan, nan])
 >>> y = np.arange(6, dtype=np.double)
>>> np.full_like(y, 0.1)
array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
numpy.gcd   numpy.gcd(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'gcd'>
 
Returns the greatest common divisor of |x1| and |x2|  Parameters 
 
x1, x2array_like, int


Arrays of values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).    Returns 
 
yndarray or scalar


The greatest common divisor of the absolute value of the inputs This is a scalar if both x1 and x2 are scalars.      See also  lcm

The lowest common multiple    Examples >>> np.gcd(12, 20)
4
>>> np.gcd.reduce([15, 25, 35])
5
>>> np.gcd(np.arange(6), 20)
array([20,  1,  2,  1,  4,  5])
numpy.get_include   numpy.get_include()[source]
 
Return the directory that contains the NumPy *.h header files. Extension modules that need to compile against NumPy should use this function to locate the appropriate include directory. Notes When using distutils, for example in setup.py. import numpy as np
...
Extension('extension_name', ...
        include_dirs=[np.get_include()])
...
numpy.get_printoptions   numpy.get_printoptions()[source]
 
Return the current print options.  Returns 
 
print_optsdict


Dictionary of current print options with keys  precision : int threshold : int edgeitems : int linewidth : int suppress : bool nanstr : str infstr : str formatter : dict of callables sign : str  For a full description of these options, see set_printoptions.      See also  
set_printoptions, printoptions, set_string_function
numpy.getbufsize   numpy.getbufsize()[source]
 
Return the size of the buffer used in ufuncs.  Returns 
 
getbufsizeint


Size of ufunc buffer in bytes.
numpy.geterr   numpy.geterr()[source]
 
Get the current way of handling floating-point errors.  Returns 
 
resdict


A dictionary with keys “divide”, “over”, “under”, and “invalid”, whose values are from the strings “ignore”, “print”, “log”, “warn”, “raise”, and “call”. The keys represent possible floating-point exceptions, and the values define how these exceptions are handled.      See also  
geterrcall, seterr, seterrcall

  Notes For complete documentation of the types of floating-point exceptions and treatment options, see seterr. Examples >>> np.geterr()
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
>>> np.arange(3.) / np.arange(3.)
array([nan,  1.,  1.])
 >>> oldsettings = np.seterr(all='warn', over='raise')
>>> np.geterr()
{'divide': 'warn', 'over': 'raise', 'under': 'warn', 'invalid': 'warn'}
>>> np.arange(3.) / np.arange(3.)
array([nan,  1.,  1.])
numpy.geterrcall   numpy.geterrcall()[source]
 
Return the current callback function used on floating-point errors. When the error handling for a floating-point error (one of “divide”, “over”, “under”, or “invalid”) is set to ‘call’ or ‘log’, the function that is called or the log instance that is written to is returned by geterrcall. This function or log instance has been set with seterrcall.  Returns 
 
errobjcallable, log instance or None


The current error handler. If no handler was set through seterrcall, None is returned.      See also  
seterrcall, seterr, geterr

  Notes For complete documentation of the types of floating-point exceptions and treatment options, see seterr. Examples >>> np.geterrcall()  # we did not yet set a handler, returns None
 >>> oldsettings = np.seterr(all='call')
>>> def err_handler(type, flag):
...     print("Floating point error (%s), with flag %s" % (type, flag))
>>> oldhandler = np.seterrcall(err_handler)
>>> np.array([1, 2, 3]) / 0.0
Floating point error (divide by zero), with flag 1
array([inf, inf, inf])
 >>> cur_handler = np.geterrcall()
>>> cur_handler is err_handler
True
numpy.geterrobj   numpy.geterrobj()
 
Return the current object that defines floating-point error handling. The error object contains all information that defines the error handling behavior in NumPy. geterrobj is used internally by the other functions that get and set error handling behavior (geterr, seterr, geterrcall, seterrcall).  Returns 
 
errobjlist


The error object, a list containing three elements: [internal numpy buffer size, error mask, error callback function]. The error mask is a single integer that holds the treatment information on all four floating point errors. The information for each error type is contained in three bits of the integer. If we print it in base 8, we can see what treatment is set for “invalid”, “under”, “over”, and “divide” (in that order). The printed string can be interpreted with  0 : ‘ignore’ 1 : ‘warn’ 2 : ‘raise’ 3 : ‘call’ 4 : ‘print’ 5 : ‘log’       See also  
seterrobj, seterr, geterr, seterrcall, geterrcall


getbufsize, setbufsize

  Notes For complete documentation of the types of floating-point exceptions and treatment options, see seterr. Examples >>> np.geterrobj()  # first get the defaults
[8192, 521, None]
 >>> def err_handler(type, flag):
...     print("Floating point error (%s), with flag %s" % (type, flag))
...
>>> old_bufsize = np.setbufsize(20000)
>>> old_err = np.seterr(divide='raise')
>>> old_handler = np.seterrcall(err_handler)
>>> np.geterrobj()
[8192, 521, <function err_handler at 0x91dcaac>]
 >>> old_err = np.seterr(all='ignore')
>>> np.base_repr(np.geterrobj()[1], 8)
'0'
>>> old_err = np.seterr(divide='warn', over='log', under='call',
...                     invalid='print')
>>> np.base_repr(np.geterrobj()[1], 8)
'4351'