neulab/docprompting-conala huggingface dataset:
numpy.record.T attribute   record.T
 
Scalar attribute identical to the corresponding array attribute. Please see ndarray.T.
numpy.record.take method   record.take()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.take.
numpy.record.tofile method   record.tofile()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.tofile.
numpy.record.tolist method   record.tolist()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.tolist.
numpy.record.tostring method   record.tostring()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.tostring.
numpy.record.trace method   record.trace()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.trace.
numpy.record.transpose method   record.transpose()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.transpose.
numpy.record.var method   record.var()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.var.
numpy.record.view method   record.view()
 
Scalar method identical to the corresponding array attribute. Please see ndarray.view.
NumPy Reference  Release 
1.22  Date 
December 31, 2021   This reference manual details functions, modules, and objects included in NumPy, describing what they are and what they do. For learning how to use NumPy, see the complete documentation.  
Array objects The N-dimensional array (ndarray) Scalars Data type objects (dtype) Indexing routines Iterating Over Arrays Standard array subclasses Masked arrays The Array Interface Datetimes and Timedeltas   Constants 
Universal functions (ufunc) ufunc Available ufuncs   
Routines Array creation routines Array manipulation routines Binary operations String operations C-Types Foreign Function Interface (numpy.ctypeslib) Datetime Support Functions Data type routines Optionally SciPy-accelerated routines (numpy.dual) Mathematical functions with automatic domain (numpy.emath) Floating point error handling Discrete Fourier Transform (numpy.fft) Functional programming NumPy-specific help functions Input and output Linear algebra (numpy.linalg) Logic functions Masked array operations Mathematical functions Matrix library (numpy.matlib) Miscellaneous routines Padding Arrays Polynomials Random sampling (numpy.random) Set routines Sorting, searching, and counting Statistics Test Support (numpy.testing) Window functions   
Typing (numpy.typing) Mypy plugin Differences from the runtime NumPy API API   
Global State Performance-Related Options Interoperability-Related Options Debugging-Related Options   
Packaging (numpy.distutils) Modules in numpy.distutils Configuration class Building Installable C libraries Conversion of .src files   
NumPy Distutils - Users Guide SciPy structure Requirements for SciPy packages The setup.py file The __init__.py file Extra features in NumPy Distutils   
NumPy C-API Python Types and C-Structures System configuration Data Type API Array API Array Iterator API UFunc API Generalized Universal Function API NumPy core libraries C API Deprecations Memory management in NumPy   
SIMD Optimizations Build options for compilation Understanding CPU Dispatching, How the NumPy dispatcher works? Dive into the CPU dispatcher   
NumPy and SWIG numpy.i: a SWIG Interface File for NumPy Testing the numpy.i Typemaps     Acknowledgements Large parts of this manual originate from Travis E. Oliphant’s book Guide to NumPy (which generously entered Public Domain in August 2008). The reference documentation for many of the functions are written by numerous contributors and developers of NumPy.
setup.py #!/usr/bin/env python3
"""
Build the Cython demonstrations of low-level access to NumPy random

Usage: python setup.py build_ext -i
"""
import setuptools  # triggers monkeypatching distutils
from distutils.core import setup
from os.path import dirname, join, abspath

import numpy as np
from Cython.Build import cythonize
from numpy.distutils.misc_util import get_info
from setuptools.extension import Extension

path = dirname(__file__)
src_dir = join(dirname(path), '..', 'src')
defs = [('NPY_NO_DEPRECATED_API', 0)]
inc_path = np.get_include()
lib_path = [abspath(join(np.get_include(), '..', '..', 'random', 'lib'))]
lib_path += get_info('npymath')['library_dirs']

extending = Extension("extending",
                      sources=[join('.', 'extending.pyx')],
                      include_dirs=[
                            np.get_include(),
                            join(path, '..', '..')
                        ],
                      define_macros=defs,
                      )
distributions = Extension("extending_distributions",
                          sources=[join('.', 'extending_distributions.pyx')],
                          include_dirs=[inc_path],
                          library_dirs=lib_path,
                          libraries=['npyrandom', 'npymath'],
                          define_macros=defs,
                          )

extensions = [extending, distributions]

setup(
    ext_modules=cythonize(extensions)
)
Statistics  Order statistics  
ptp(a[, axis, out, keepdims]) Range of values (maximum - minimum) along an axis.  
percentile(a, q[, axis, out, ...]) Compute the q-th percentile of the data along the specified axis.  
nanpercentile(a, q[, axis, out, ...]) Compute the qth percentile of the data along the specified axis, while ignoring nan values.  
quantile(a, q[, axis, out, overwrite_input, ...]) Compute the q-th quantile of the data along the specified axis.  
nanquantile(a, q[, axis, out, ...]) Compute the qth quantile of the data along the specified axis, while ignoring nan values.     Averages and variances  
median(a[, axis, out, overwrite_input, keepdims]) Compute the median along the specified axis.  
average(a[, axis, weights, returned]) Compute the weighted average along the specified axis.  
mean(a[, axis, dtype, out, keepdims, where]) Compute the arithmetic mean along the specified axis.  
std(a[, axis, dtype, out, ddof, keepdims, where]) Compute the standard deviation along the specified axis.  
var(a[, axis, dtype, out, ddof, keepdims, where]) Compute the variance along the specified axis.  
nanmedian(a[, axis, out, overwrite_input, ...]) Compute the median along the specified axis, while ignoring NaNs.  
nanmean(a[, axis, dtype, out, keepdims, where]) Compute the arithmetic mean along the specified axis, ignoring NaNs.  
nanstd(a[, axis, dtype, out, ddof, ...]) Compute the standard deviation along the specified axis, while ignoring NaNs.  
nanvar(a[, axis, dtype, out, ddof, ...]) Compute the variance along the specified axis, while ignoring NaNs.     Correlating  
corrcoef(x[, y, rowvar, bias, ddof, dtype]) Return Pearson product-moment correlation coefficients.  
correlate(a, v[, mode]) Cross-correlation of two 1-dimensional sequences.  
cov(m[, y, rowvar, bias, ddof, fweights, ...]) Estimate a covariance matrix, given data and weights.     Histograms  
histogram(a[, bins, range, normed, weights, ...]) Compute the histogram of a dataset.  
histogram2d(x, y[, bins, range, normed, ...]) Compute the bi-dimensional histogram of two data samples.  
histogramdd(sample[, bins, range, normed, ...]) Compute the multidimensional histogram of some data.  
bincount(x, /[, weights, minlength]) Count number of occurrences of each value in array of non-negative ints.  
histogram_bin_edges(a[, bins, range, weights]) Function to calculate only the edges of the bins used by the histogram function.  
digitize(x, bins[, right]) Return the indices of the bins to which each value in input array belongs.
numpy.testing.assert_allclose   testing.assert_allclose(actual, desired, rtol=1e-07, atol=0, equal_nan=True, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two objects are not equal up to desired tolerance. The test is equivalent to allclose(actual, desired, rtol, atol) (note that allclose has different default values). It compares the difference between actual and desired to atol + rtol * abs(desired).  New in version 1.5.0.   Parameters 
 
actualarray_like


Array obtained.  
desiredarray_like


Array desired.  
rtolfloat, optional


Relative tolerance.  
atolfloat, optional


Absolute tolerance.  
equal_nanbool, optional.


If True, NaNs will compare equal.  
err_msgstr, optional


The error message to be printed in case of failure.  
verbosebool, optional


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired are not equal up to specified precision.      See also  
assert_array_almost_equal_nulp, assert_array_max_ulp

  Examples >>> x = [1e-5, 1e-3, 1e-1]
>>> y = np.arccos(np.cos(x))
>>> np.testing.assert_allclose(x, y, rtol=1e-5, atol=0)
numpy.testing.assert_almost_equal   testing.assert_almost_equal(actual, desired, decimal=7, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two items are not equal up to desired precision.  Note It is recommended to use one of assert_allclose, assert_array_almost_equal_nulp or assert_array_max_ulp instead of this function for more consistent floating point comparisons.  The test verifies that the elements of actual and desired satisfy. abs(desired-actual) < 1.5 * 10**(-decimal) That is a looser test than originally documented, but agrees with what the actual implementation in assert_array_almost_equal did up to rounding vagaries. An exception is raised at conflicting values. For ndarrays this delegates to assert_array_almost_equal  Parameters 
 
actualarray_like


The object to check.  
desiredarray_like


The expected object.  
decimalint, optional


Desired precision, default is 7.  
err_msgstr, optional


The error message to be printed in case of failure.  
verbosebool, optional


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired are not equal up to specified precision.      See also  assert_allclose

Compare two array_like objects for equality with desired relative and/or absolute precision.  
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

  Examples >>> from numpy.testing import assert_almost_equal
>>> assert_almost_equal(2.3333333333333, 2.33333334)
>>> assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 10 decimals
 ACTUAL: 2.3333333333333
 DESIRED: 2.33333334
 >>> assert_almost_equal(np.array([1.0,2.3333333333333]),
...                     np.array([1.0,2.33333334]), decimal=9)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 9 decimals

Mismatched elements: 1 / 2 (50%)
Max absolute difference: 6.66669964e-09
Max relative difference: 2.85715698e-09
 x: array([1.         , 2.333333333])
 y: array([1.        , 2.33333334])
numpy.testing.assert_approx_equal   testing.assert_approx_equal(actual, desired, significant=7, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two items are not equal up to significant digits.  Note It is recommended to use one of assert_allclose, assert_array_almost_equal_nulp or assert_array_max_ulp instead of this function for more consistent floating point comparisons.  Given two numbers, check that they are approximately equal. Approximately equal is defined as the number of significant digits that agree.  Parameters 
 
actualscalar


The object to check.  
desiredscalar


The expected object.  
significantint, optional


Desired precision, default is 7.  
err_msgstr, optional


The error message to be printed in case of failure.  
verbosebool, optional


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired are not equal up to specified precision.      See also  assert_allclose

Compare two array_like objects for equality with desired relative and/or absolute precision.  
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

  Examples >>> np.testing.assert_approx_equal(0.12345677777777e-20, 0.1234567e-20)
>>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345671e-20,
...                                significant=8)
>>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345672e-20,
...                                significant=8)
Traceback (most recent call last):
    ...
AssertionError:
Items are not equal to 8 significant digits:
 ACTUAL: 1.234567e-21
 DESIRED: 1.2345672e-21
 the evaluated condition that raises the exception is >>> abs(0.12345670e-20/1e-21 - 0.12345672e-20/1e-21) >= 10**-(8-1)
True
numpy.testing.assert_array_almost_equal   testing.assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two objects are not equal up to desired precision.  Note It is recommended to use one of assert_allclose, assert_array_almost_equal_nulp or assert_array_max_ulp instead of this function for more consistent floating point comparisons.  The test verifies identical shapes and that the elements of actual and desired satisfy. abs(desired-actual) < 1.5 * 10**(-decimal) That is a looser test than originally documented, but agrees with what the actual implementation did up to rounding vagaries. An exception is raised at shape mismatch or conflicting values. In contrast to the standard usage in numpy, NaNs are compared like numbers, no assertion is raised if both objects have NaNs in the same positions.  Parameters 
 
xarray_like


The actual object to check.  
yarray_like


The desired, expected object.  
decimalint, optional


Desired precision, default is 6.  
err_msgstr, optional


The error message to be printed in case of failure.  
verbosebool, optional


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired are not equal up to specified precision.      See also  assert_allclose

Compare two array_like objects for equality with desired relative and/or absolute precision.  
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

  Examples the first assert does not raise an exception >>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan],
...                                      [1.0,2.333,np.nan])
 >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
...                                      [1.0,2.33339,np.nan], decimal=5)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 5 decimals

Mismatched elements: 1 / 3 (33.3%)
Max absolute difference: 6.e-05
Max relative difference: 2.57136612e-05
 x: array([1.     , 2.33333,     nan])
 y: array([1.     , 2.33339,     nan])
 >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
...                                      [1.0,2.33333, 5], decimal=5)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 5 decimals

x and y nan location mismatch:
 x: array([1.     , 2.33333,     nan])
 y: array([1.     , 2.33333, 5.     ])
numpy.testing.assert_array_almost_equal_nulp   testing.assert_array_almost_equal_nulp(x, y, nulp=1)[source]
 
Compare two arrays relatively to their spacing. This is a relatively robust method to compare two arrays whose amplitude is variable.  Parameters 
 
x, yarray_like


Input arrays.  
nulpint, optional


The maximum number of unit in the last place for tolerance (see Notes). Default is 1.    Returns 
 None
  Raises 
 AssertionError

If the spacing between x and y for one or more elements is larger than nulp.      See also  assert_array_max_ulp

Check that all items of arrays differ in at most N Units in the Last Place.  spacing

Return the distance between x and the nearest adjacent number.    Notes An assertion is raised if the following condition is not met: abs(x - y) <= nulps * spacing(maximum(abs(x), abs(y)))
 Examples >>> x = np.array([1., 1e-10, 1e-20])
>>> eps = np.finfo(x.dtype).eps
>>> np.testing.assert_array_almost_equal_nulp(x, x*eps/2 + x)
 >>> np.testing.assert_array_almost_equal_nulp(x, x*eps + x)
Traceback (most recent call last):
  ...
AssertionError: X and Y are not equal to 1 ULP (max is 2)
numpy.testing.assert_array_equal   testing.assert_array_equal(x, y, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two array_like objects are not equal. Given two array_like objects, check that the shape is equal and all elements of these objects are equal (but see the Notes for the special handling of a scalar). An exception is raised at shape mismatch or conflicting values. In contrast to the standard usage in numpy, NaNs are compared like numbers, no assertion is raised if both objects have NaNs in the same positions. The usual caution for verifying equality with floating point numbers is advised.  Parameters 
 
xarray_like


The actual object to check.  
yarray_like


The desired, expected object.  
err_msgstr, optional


The error message to be printed in case of failure.  
verbosebool, optional


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired objects are not equal.      See also  assert_allclose

Compare two array_like objects for equality with desired relative and/or absolute precision.  
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

  Notes When one of x and y is a scalar and the other is array_like, the function checks that each element of the array_like object is equal to the scalar. Examples The first assert does not raise an exception: >>> np.testing.assert_array_equal([1.0,2.33333,np.nan],
...                               [np.exp(0),2.33333, np.nan])
 Assert fails with numerical imprecision with floats: >>> np.testing.assert_array_equal([1.0,np.pi,np.nan],
...                               [1, np.sqrt(np.pi)**2, np.nan])
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not equal

Mismatched elements: 1 / 3 (33.3%)
Max absolute difference: 4.4408921e-16
Max relative difference: 1.41357986e-16
 x: array([1.      , 3.141593,      nan])
 y: array([1.      , 3.141593,      nan])
 Use assert_allclose or one of the nulp (number of floating point values) functions for these cases instead: >>> np.testing.assert_allclose([1.0,np.pi,np.nan],
...                            [1, np.sqrt(np.pi)**2, np.nan],
...                            rtol=1e-10, atol=0)
 As mentioned in the Notes section, assert_array_equal has special handling for scalars. Here the test checks that each value in x is 3: >>> x = np.full((2, 5), fill_value=3)
>>> np.testing.assert_array_equal(x, 3)
numpy.testing.assert_array_less   testing.assert_array_less(x, y, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two array_like objects are not ordered by less than. Given two array_like objects, check that the shape is equal and all elements of the first object are strictly smaller than those of the second object. An exception is raised at shape mismatch or incorrectly ordered values. Shape mismatch does not raise if an object has zero dimension. In contrast to the standard usage in numpy, NaNs are compared, no assertion is raised if both objects have NaNs in the same positions.  Parameters 
 
xarray_like


The smaller object to check.  
yarray_like


The larger object to compare.  
err_msgstring


The error message to be printed in case of failure.  
verbosebool


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired objects are not equal.      See also  assert_array_equal

tests objects for equality  assert_array_almost_equal

test objects for equality up to precision    Examples >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1.1, 2.0, np.nan])
>>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1, 2.0, np.nan])
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not less-ordered

Mismatched elements: 1 / 3 (33.3%)
Max absolute difference: 1.
Max relative difference: 0.5
 x: array([ 1.,  1., nan])
 y: array([ 1.,  2., nan])
 >>> np.testing.assert_array_less([1.0, 4.0], 3)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not less-ordered

Mismatched elements: 1 / 2 (50%)
Max absolute difference: 2.
Max relative difference: 0.66666667
 x: array([1., 4.])
 y: array(3)
 >>> np.testing.assert_array_less([1.0, 2.0, 3.0], [4])
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not less-ordered

(shapes (3,), (1,) mismatch)
 x: array([1., 2., 3.])
 y: array([4])
numpy.testing.assert_array_max_ulp   testing.assert_array_max_ulp(a, b, maxulp=1, dtype=None)[source]
 
Check that all items of arrays differ in at most N Units in the Last Place.  Parameters 
 
a, barray_like


Input arrays to be compared.  
maxulpint, optional


The maximum number of units in the last place that elements of a and b can differ. Default is 1.  
dtypedtype, optional


Data-type to convert a and b to if given. Default is None.    Returns 
 
retndarray


Array containing number of representable floating point numbers between items in a and b.    Raises 
 AssertionError

If one or more elements differ by more than maxulp.      See also  assert_array_almost_equal_nulp

Compare two arrays relatively to their spacing.    Notes For computing the ULP difference, this API does not differentiate between various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000 is zero). Examples >>> a = np.linspace(0., 1., 100)
>>> res = np.testing.assert_array_max_ulp(a, np.arcsin(np.sin(a)))
numpy.testing.assert_equal   testing.assert_equal(actual, desired, err_msg='', verbose=True)[source]
 
Raises an AssertionError if two objects are not equal. Given two objects (scalars, lists, tuples, dictionaries or numpy arrays), check that all elements of these objects are equal. An exception is raised at the first conflicting values. When one of actual and desired is a scalar and the other is array_like, the function checks that each element of the array_like object is equal to the scalar. This function handles NaN comparisons as if NaN was a “normal” number. That is, AssertionError is not raised if both objects have NaNs in the same positions. This is in contrast to the IEEE standard on NaNs, which says that NaN compared to anything must return False.  Parameters 
 
actualarray_like


The object to check.  
desiredarray_like


The expected object.  
err_msgstr, optional


The error message to be printed in case of failure.  
verbosebool, optional


If True, the conflicting values are appended to the error message.    Raises 
 AssertionError

If actual and desired are not equal.     Examples >>> np.testing.assert_equal([4,5], [4,6])
Traceback (most recent call last):
    ...
AssertionError:
Items are not equal:
item=1
 ACTUAL: 5
 DESIRED: 6
 The following comparison does not raise an exception. There are NaNs in the inputs, but they are in the same positions. >>> np.testing.assert_equal(np.array([1.0, 2.0, np.nan]), [1, 2, np.nan])
numpy.testing.assert_raises   testing.assert_raises(exception_class, callable, *args, **kwargs) assert_raises(exception_class)[source]
  testing.assert_raises(exception_class) → None
 
Fail unless an exception of class exception_class is thrown by callable when invoked with arguments args and keyword arguments kwargs. If a different type of exception is thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception. Alternatively, assert_raises can be used as a context manager: >>> from numpy.testing import assert_raises
>>> with assert_raises(ZeroDivisionError):
...     1 / 0
 is equivalent to >>> def div(x, y):
...     return x / y
>>> assert_raises(ZeroDivisionError, div, 1, 0)
numpy.testing.assert_raises_regex   testing.assert_raises_regex(exception_class, expected_regexp, callable, *args, **kwargs) assert_raises_regex(exception_class, expected_regexp)[source]
 
Fail unless an exception of class exception_class and with message that matches expected_regexp is thrown by callable when invoked with arguments args and keyword arguments kwargs. Alternatively, can be used as a context manager like assert_raises. Name of this function adheres to Python 3.2+ reference, but should work in all versions down to 2.6. Notes  New in version 1.9.0.