Search
Search Results
Search finished, found 189 page(s) matching the search query.
- Performance
...NumPy reference NumPy’s module structure Random sampling (numpy.random) Performance...
- Miscellaneous routines > Performance tuning
...Miscellaneous routines Performance tuning setbufsize(size) Set the size of the buffer used in ufuncs. getbufsize() Return the size of the bu...
- Global Configuration Options
...t-time, compile-time, or runtime configuration options which change the global behaviour. Most of these are related to performance or for debugging purposes and will not be interesting to the vast majority of users. Performance-related op...
- Miscellaneous routines
...Miscellaneous routines Performance tuning setbufsize(size) Set the size of the buffer used in ufuncs. getbufsize() Return the size of the bu...
- NumPy 1.12.0 Release Notes
...which is regular quicksort but changing to a heapsort when not enough progress is made. This retains the good quicksort performance while changing the worst case runtime from O(N^2) to O(N*log(N)). ediff1d improved performance and subclas...
- NumPy 1.13.0 Release Notes
...pression involving basic numeric types. For example d = a + b + c is transformed to d = a + b; d += c which can improve performance for large arrays as less memory bandwidth is required to perform the operation. axes argument for unique I...
- NumPy 1.15.0 Release Notes
...rFunction now defaults to using user-defined copyswapn / copyswap for user-defined dtypes. If this causes a significant performance hit, consider implementing copyswapn to reflect the implementation of PyArray_GetStridedCopyFn. See #10898....
- NumPy 1.17.0 Release Notes
...NumPy 1.17.0 Release Notes This NumPy release contains a number of new features that should substantially improve its performance and usefulness, see Highlights below for a summary. The Python versions supported are 3.5-3.7, note that Pyt...
- NumPy 1.20.0 Release Notes
...s from symmetry due to numerical precision that are now avoided by better arrangement of the computation. (gh-17195) Performance improvements and changes Enable multi-platform SIMD compiler optimizations A series of improvements for Num...
- NumPy 1.21.0 Release Notes
...r implementation used by default_rng in future releases. PCG64DXSM solves the statistical weakness while preserving the performance and the features of PCG64. See Upgrading PCG64 with PCG64DXSM for more details. (gh-18906) Expired deprec...
- NumPy 1.23.0 Release Notes
...documentation, and expire old deprecations. The highlights are: Implementation of loadtxt in C, greatly improving its performance. Exposing DLPack at the Python level for easy data exchange. Changes to the promotion and comparisons of str...
- NumPy 1.24 Release Notes
...pport for SIMD extensions of zSystem (z13, z14, z15), through the universal intrinsics interface. This support leads to performance improvements for all SIMD kernels implemented using the universal intrinsics, including the following operat...
- NumPy 1.25.0 Release Notes
...rrays, much like np.dot and np.matmul. (gh-18053) Add support for inplace matrix multiplication It is now possible to perform inplace matrix multiplication via the @= operator. >>> import numpy as np >>> a = np.arange(6).reshape(3, 2) >>...
- NumPy 1.8.0 Release Notes
...s to create value initialized arrays. New, PyUFunc_RegisterLoopForDescr, better ufunc support for user dtypes. Numerous performance improvements in many areas. Dropped Support Support for Python versions 2.4 and 2.5 has been dropped, Sup...
- NumPy 1.9.0 Release Notes
...NumPy 1.9.0 Release Notes This release supports Python 2.6 - 2.7 and 3.2 - 3.4. Highlights Numerous performance improvements in various areas, most notably indexing and operations on small arrays are significantly faster...
- NumPy 2.1.0 Release Notes
...n now matches other reference implementations. (gh-26656) lapack_lite is now thread safe NumPy provides a minimal low-performance version of LAPACK named lapack_lite that can be used if no BLAS/LAPACK system is detected at build time. Unt...
- NumPy 2.2.0 Release Notes
...ly assignments, and also fixes situations where multiple modules are present within a single source file. (gh-27695) Performance improvements and changes Improved multithreaded scaling on the free-threaded build when many threads simult...
- Performance
...NumPy reference NumPy’s module structure Random sampling (numpy.random) Performance...
numpy.distutils
user guide...ng of generically-typed C source files (whether in NumPy proper or in any third party package using NumPy Distutils) is performed by conv_template.py. The type-specific C files generated (extension: .c) by these modules during the build pro...
numpy.polynomial
...le to the specific module in question, e.g., polynomial (which “wraps” the “standard” basis) or chebyshev. For optimal performance, all operations on polynomials, including evaluation at an argument, are implemented as operations on the co...
- Array API
...ay_CopyInto(PyArrayObject *dest, PyArrayObject *src) Copy from the source array, src, into the destination array, dest, performing a data-type conversion if necessary. If an error occurs return -1 (otherwise 0). The shape of src must be bro...
- Array creation
...g the int8 array to integers outside of this range results in overflow. This feature can often be misunderstood. If you perform calculations with mismatching dtypes, you can get unwanted results, for example: >>> import numpy as np >>> a =...
- Array iterator API
...order NPY_KEEPORDER * - Visit elements in memory order, regardless of strides. * This is good for performance when the specific order * elements are visited is unimportant. * casting NPY_NO_CASTING...
- Beyond the basics
...ptr */ dptr++; } Iterating over all but one axis A common algorithm is to loop over all elements of an array and perform some function with each element by issuing a function call. As function calls can be time consuming, one way to...
- BLAS and LAPACK
...ystem will attempt to locate a suitable library, and try a number of known libraries in a certain order - most to least performant. A typical order is: MKL, Accelerate, OpenBLAS, FlexiBLAS, BLIS, plain libblas/liblapack. This may vary per p...
- C API deprecations
...eding direct, easy, access to the data of ndarrays, this will not remove this ability. Rather, there are many potential performance optimizations which require changing the implementation details, and NumPy developers have been unable to tr...
- Compatibility policy
...ity from run to run under certain conditions. If you create a Generator with the same BitGenerator, with the same seed, perform the same sequence of method calls with the same arguments, on the same build of numpy, in the same environment,...
- Copies and views
...it is possible to access the internal data buffer directly using a view without copying data around. This ensures good performance but can also cause unwanted problems if the user is not aware of how this works. Hence, it is important to k...
- CPU build options
...or build). They accept a set of CPU features or groups of features that gather several features or special options that perform a series of procedures. To customize CPU/build options: pip install . -Csetup-args=-Dcpu-baseline="avx2 fma3" -C...
- CPU/SIMD optimizations
...working mechanism that allows it to harness the SIMD features that CPUs own, in order to provide faster and more stable performance on all popular platforms. Currently, NumPy supports the X86, IBM/Power, ARM7 and ARM8 architectures. The opt...
- Data type promotion in NumPy
...orking with low precision dtypes. First, since the Python value is converted to a NumPy one before the operation can by performed, operations can fail with an error when the result seems obvious. For instance, np.int8(1) + 1000 cannot conti...
- Data types
...ithmetic, which can introduce small inaccuracies due to the way computers represent decimal numbers. For instance, when performing basic arithmetic operations involving floating-point numbers: >>> 0.3 - 0.2 - 0.1 # This does not equal 0 du...
- Datetimes and timedeltas
...rt numpy as np >>> np.busday_offset('2012-05', 1, roll='forward', weekmask='Sun') np.datetime64('2012-05-13') When performance is important for manipulating many business dates with one particular choice of weekmask and holidays, there...
- Extending
...Extending The BitGenerators have been designed to be extendable using standard tools for high-performance Python – numba and Cython. The Generator object can also be used with user-provided BitGenerators as long a...
- Generalized universal function API
...same label in the signature (e.g. the i in inner1d’s (i),(i)->()) must have exactly matching sizes, no broadcasting is performed. The core dimensions are removed from all inputs and the remaining dimensions are broadcast together, defining...
- Glossary
...ke one array appear to change its datatype and shape. An array created this way is a view, and NumPy often exploits the performance gain of using a view versus making a new array. A potential drawback is that writing to a view can alter the...
- How does the CPU dispatcher work?
...patch-able source. Policies: collections of options used for changing the default behaviors or forcing the compilers to perform certain things. “baseline”: a unique keyword represents the minimal optimizations that configured through --cpu-...
- How to extend NumPy
...e have been defined. The last thing that must be done to finish the extension module is to actually write the code that performs the desired functions. There are two kinds of functions: those that don’t accept keyword arguments, and those t...
- Importing data with
genfromtxt
...be an integer which corresponds to the number of lines to skip at the beginning of the file, before any other action is performed. Similarly, we can skip the last n lines of the file by using the skip_footer attribute and giving it a value...
- Internal organization of NumPy arrays
...vention, thus the ‘C’ and ‘FORTRAN’ order options for array ordering in NumPy.) The drawback of doing this is potential performance penalties. It’s common to access the data sequentially, either implicitly in array operations or explicitly...
- Interoperability with NumPy
...erwise, this copies the data into a new ndarray object. This is not optimal, as coercing arrays into ndarrays may cause performance problems or create the need for copies and loss of metadata, as the original object and any attributes/behav...
- Iterating over arrays
...ide. When writing C code, this is generally fine, however in pure Python code this can cause a significant reduction in performance. By enabling buffering mode, the chunks provided by the iterator to the inner loop can be made larger, signi...
- Legacy fixed-width string functionality
...Unlike the standard numpy comparison operators, the ones in the char module strip trailing whitespace characters before performing the comparison. equal(x1, x2) Return (x1 == x2) element-wise. not_equal(x1, x2) Return (x1 != x2) element-...
- Miscellaneous
...large (many functions) existing C libraries Minuses: generates lots of code between Python and the C code can cause performance problems that are nearly impossible to optimize out interface files can be hard to write doesn’t necessarily...
- NumPy 1.10.0 Release Notes
...s that used to return scalars now issue FutureWarning or DeprecationWarning, and in the future will be change to either perform elementwise comparisons or raise an error. In np.lib.split an empty array in the result always had dimension (0,...
- NumPy 1.10.2 Release Notes
...pr fails for structured array with multi-dimensional column. gh-6462 Median of empty array produces IndexError. gh-6467 Performance regression for record array access. gh-6468 numpy.interp uses ‘left’ value even when x[0]==xp[0]. gh-6475 np...
- NumPy 1.11.0 Release Notes
...trix products. Now, if the matrix product is between a matrix and its transpose, it will use syrk BLAS operations for a performance boost. This optimization has been extended to @, numpy.dot, numpy.inner, and numpy.matmul. Note: Requires th...
- NumPy 1.13.2 Release Notes
...previous versions of Python 3.6. The Windows wheels are now built with OpenBlas instead ATLAS, which should improve the performance of the linear algebra functions. Contributors A total of 12 people contributed to this release. People wit...
- NumPy 1.13.3 Release Notes
...ing compatible with Python 3.7-dev. The Windows wheels were built with OpenBlas instead ATLAS, which should improve the performance of the linear algebra functions. The NumPy 1.13.3 release is a re-release of 1.13.2, which suffered from a b...
- NumPy 1.16.0 Release Notes
...for overriding numpy functions, see __array_function__ below. The matmul function is now a ufunc. This provides better performance and allows overriding with __array_ufunc__. Improved support for the ARM and POWER architectures. Improved s...
- NumPy 1.18.2 Release Notes
...NumPy 1.18.2 Release Notes This small release contains a fix for a performance regression in numpy/random and several bug/maintenance updates. The Python versions supported in this releas...
- NumPy 1.19.0 Release Notes
...p.exp when input is np.float64 Use AVX512 intrinsic to implement np.exp when input is np.float64, which can improve the performance of np.exp with np.float64 input 5-7x faster than before. The _multiarray_umath.so module has grown about 63...
- NumPy 1.26.0 Release Notes
...ary, including ILP64 (64-bit integer) support, in macOS 13.3 has been added. This brings arm64 support, and significant performance improvements of up to 10x for commonly used linear algebra operations. When Accelerate is selected at build...
- NumPy 1.6.0 Release Notes
...f datetime dtype support to deal with dates in arrays. A new 16-bit floating point type. A new iterator, which improves performance of many functions. New features New 16-bit floating point type This release adds support for the IEEE 75...
- NumPy 1.7.0 Release Notes
...functions evaluate some reductions in a different order than in previous versions of NumPy, generally providing higher performance. Because of the nature of floating-point arithmetic, this may subtly change some results, just as linking Nu...
- NumPy 1.7.2 Release Notes
...s expected gh-2495: np.ma.compress treated inputs in wrong order gh-576: add __len__ method to ma.mvoid gh-3364: reduce performance regression of mmap slicing gh-3421: fix non-swapping strided copies in GetStridedCopySwap gh-3373: fix small...
- NumPy 2.0 migration guide
...ted as ufuncs. The old numpy.char namespace still is available, and, wherever possible, uses the new ufuncs for greater performance. We recommend using the strings functions going forward. The char namespace may be deprecated in the future....
- NumPy 2.0.0 Release Notes
...release include: New features: A new variable-length string dtype, StringDType and a new numpy.strings namespace with performant ufuncs for string operations, Support for float32 and longdouble in all numpy.fft functions, Support for the...
- NumPy 2.1.3 Release Notes
...ypes using the string ufuncs should now generate much more uniform results. (gh-27636) Changes numpy.fix now won’t perform casting to a floating data-type for integer and boolean data-type input arrays. (gh-26766) Contributors A to...
- NumPy C code explanations
...atatype access are implemented for the void type. A common idiom is to cycle through the elements of the dictionary and perform a specific operation based on the datatype object stored at the given offset. These offsets can be arbitrary num...
- NumPy for MATLAB users
...the minimum type required to hold the objects in sequence, unless you specify the number of dimensions and type. NumPy performs operations element-by-element, so multiplying 2D arrays with * is not a matrix multiplication – it’s an element...
- NumPy quickstart
...Unlike in many matrix languages, the product operator * operates elementwise in NumPy arrays. The matrix product can be performed using the @ operator (in python >=3.5) or the dot function or method: >>> A = np.array([[1, 1], ......
- numpy.all
...e converted to an array. axisNone or int or tuple of ints, optionalAxis or axes along which a logical AND reduction is performed. The default (axis=None) is to perform a logical AND over all the dimensions of the input array. axis may be n...
- numpy.any
...be converted to an array. axisNone or int or tuple of ints, optionalAxis or axes along which a logical OR reduction is performed. The default (axis=None) is to perform a logical OR over all the dimensions of the input array. axis may be ne...
- numpy.argpartition
...numpy.argpartition numpy.argpartition(a, kth, axis=-1, kind='introselect', order=None)[source] Perform an indirect partition along the given axis using the algorithm specified by the kind keyword. It returns an arra...
- numpy.argsort
...numpy.argsort(a, axis=-1, kind=None, order=None, *, stable=None)[source] Returns the indices that would sort an array. Perform an indirect sort along the given axis using the algorithm specified by the kind keyword. It returns an array of...
- numpy.asanyarray
...ay subclassArray interpretation of a. If a is an ndarray or a subclass of ndarray, it is returned as-is and no copy is performed. See also asarraySimilar function which always returns ndarrays. ascontiguousarrayConvert input to a co...
- numpy.asarray
...hat passed in via this argument. New in version 1.20.0. Returns: outndarrayArray interpretation of a. No copy is performed if the input is already an ndarray with matching dtype and order. If a is a subclass of ndarray, a base class...
- numpy.asarray_chkfinite
...therwise ‘K’ (keep) preserve input order Defaults to ‘C’. Returns: outndarrayArray interpretation of a. No copy is performed if the input is already an ndarray. If a is a subclass of ndarray, a base class ndarray is returned. Raise...
- numpy.average
...he input array. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, averaging is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before. weightsarray_li...
- numpy.bincount
...cast array data from dtype('float64') to dtype('int64') according to the rule 'safe' A possible use of bincount is to perform sums over variable-size chunks of an array, using the weights keyword. >>> w = np.array([0.3, 0.5, 0.2, 0.7, 1.,...
- numpy.char.compare_chararrays
...numpy.char.compare_chararrays char.compare_chararrays(a1, a2, cmp, rstrip) Performs element-wise comparison of two string arrays using the comparison operator specified by cmp. Parameters: a1,...
- numpy.char.equal
...numpy.char.equal char.equal(x1, x2)[source] Return (x1 == x2) element-wise. Unlike numpy.equal, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-c...
- numpy.char.greater
...mpy.char.greater char.greater(x1, x2)[source] Return (x1 > x2) element-wise. Unlike numpy.greater, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-c...
- numpy.char.greater_equal
...ual char.greater_equal(x1, x2)[source] Return (x1 >= x2) element-wise. Unlike numpy.greater_equal, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-co...
- numpy.char.less
...numpy.char.less char.less(x1, x2)[source] Return (x1 < x2) element-wise. Unlike numpy.greater, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-c...
- numpy.char.less_equal
...ess_equal char.less_equal(x1, x2)[source] Return (x1 <= x2) element-wise. Unlike numpy.less_equal, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-c...
- numpy.char.not_equal
...r.not_equal char.not_equal(x1, x2)[source] Return (x1 != x2) element-wise. Unlike numpy.not_equal, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-c...
- numpy.choose
...uld be of the appropriate shape and dtype. Note that out is always buffered if mode='raise'; use other modes for better performance. mode{‘raise’ (default), ‘wrap’, ‘clip’}, optionalSpecifies how indices outside [0, n-1] will be treated:...
- numpy.clip
..., and values larger than 1 become 1. Equivalent to but faster than np.minimum(a_max, np.maximum(a, a_min)). No check is performed to ensure a_min < a_max. Parameters: aarray_likeArray containing elements to clip. a_min, a_maxarray_like o...
- numpy.correlate
...nvolveDiscrete, linear convolution of two one-dimensional sequences. scipy.signal.correlateuses FFT which has superior performance on large arrays. Notes The definition of correlation above is not unique and sometimes correlation may be...
- numpy.diff
...ken, default is the last axis. prepend, appendarray_like, optionalValues to prepend or append to a along axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of...
- numpy.dot
...ve the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a,b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be fle...
- numpy.einsum
...ts for summation as comma separated list of subscript labels. An implicit (classical Einstein summation) calculation is performed unless the explicit indicator ‘->’ is included as well as subscript labels of the precise output form. operan...
- numpy.fft.fft2
...ute the FFT. If not given, the last two axes are used. A repeated index in axes means the transform over that axis is performed multiple times. A one-element sequence means that a one-dimensional FFT is performed. Default: (-2, -1). Dep...
- numpy.fft.fftn
...s are used, or all axes if s is also not specified. Repeated indices in axes means that the transform over that axis is performed multiple times. Deprecated since version 2.0: If s is specified, the corresponding axes to be transformed mus...
- numpy.fft.ifft
...though this is the common approach, it might lead to surprising results. If a different padding is desired, it must be performed before calling ifft. Examples >>> import numpy as np >>> np.fft.ifft([0, 4, 0, 0]) array([ 1.+0.j, 0.+1.j, -1...
- numpy.fft.ifft2
...ute the FFT. If not given, the last two axes are used. A repeated index in axes means the transform over that axis is performed multiple times. A one-element sequence means that a one-dimensional FFT is performed. Default: (-2, -1). Dep...
- numpy.fft.ifftn
...ed, or all axes if s is also not specified. Repeated indices in axes means that the inverse transform over that axis is performed multiple times. Deprecated since version 2.0: If s is specified, the corresponding axes to be transformed mus...
- numpy.fft.irfftn
...ed, or all axes if s is also not specified. Repeated indices in axes means that the inverse transform over that axis is performed multiple times. Deprecated since version 2.0: If s is specified, the corresponding axes to be transformed mus...
- numpy.fft.rfftn
...real array by means of the Fast Fourier Transform (FFT). By default, all axes are transformed, with the real transform performed over the last axis, while the remaining transforms are complex. Parameters: aarray_likeInput array, taken to...
- numpy.flip
...the input array. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, flipping is performed on all of the axes specified in the tuple. Returns: outarray_likeA view of m with the entries of axis reve...
- numpy.fromiter
...via this argument. New in version 1.20.0. Returns: outndarrayThe output array. Notes Specify count to improve performance. It allows fromiter to pre-allocate the output array, instead of resizing it on demand. Examples >>> import...
- numpy.histogram_bin_edges
...omated bin size selection. ‘auto’Minimum bin width between the ‘sturges’ and ‘fd’ estimators. Provides good all-around performance. ‘fd’ (Freedman Diaconis Estimator)Robust (resilient to outliers) estimator that takes into account data va...
- numpy.i: a SWIG interface file for NumPy
...xtract the data buffer and length in lines 19 and 20 so that we can call the underlying C function at line 22. Line 25 performs memory management for the case where we have created a new array that is no longer needed. This code has a sign...
- numpy.lexsort
...numpy.lexsort numpy.lexsort(keys, axis=-1) Perform an indirect stable sort using a sequence of keys. Given multiple sorting keys, lexsort returns an array of integ...
- numpy.lib.array_utils.normalize_axis_tuple
...ment into a tuple of non-negative integer axes. This handles shorthands such as 1 and converts them to (1,), as well as performing the handling of negative indices covered by normalize_axis_index. By default, this forbids axes from being sp...
- numpy.lib.npyio.NpzFile
...le instanceThe ZipFile object initialized with the zipped archive. fBagObj instanceAn object on which attribute can be performed as an alternative to getitem access on the NpzFile instance itself. allow_picklebool, optionalAllow loading p...
- numpy.linalg.cholesky
...ry transpose if a is real-valued). a must be Hermitian (symmetric if real-valued) and positive-definite. No checking is performed to verify whether a is Hermitian or not. In addition, only the lower or upper-triangular and diagonal elements...
- numpy.linalg.multi_dot
...e the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a, b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be fle...
- numpy.linalg.svd
...g.svdSimilar function in SciPy. scipy.linalg.svdvalsCompute singular values of a matrix. Notes The decomposition is performed using LAPACK routine _gesdd. SVD is usually described for the factorization of a 2D matrix \(A\). The higher-d...
- numpy.linalg.svdvals
...eters: x(…, M, N) array_likeInput array having shape (…, M, N) and whose last two dimensions form matrices on which to perform singular value decomposition. Should have a floating-point data type. Returns: outndarrayAn array with shape...
- numpy.ma.array
...None, the type of the data argument (data.dtype) is used. If dtype is not None and different from data.dtype, a copy is performed. copybool, optionalWhether to copy the input data (True), or to use a reference instead. Default is False. s...
- numpy.ma.asanyarray
...e input to a masked array, conserving subclasses. If a is a subclass of MaskedArray, its class is conserved. No copy is performed if the input is already an ndarray. Parameters: aarray_likeInput data, in any form that can be converted to...
- numpy.ma.asarray
...ma.asarray(a, dtype=None, order=None)[source] Convert the input to a masked array of the given data-type. No copy is performed if the input is already an ndarray. If a is a subclass of MaskedArray, a base class MaskedArray is returned....
- numpy.ma.average
...default, axis=None, will average over all of the elements of the input array. If axis is a tuple of ints, averaging is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before. weightsarray_li...
- numpy.ma.clip
..., and values larger than 1 become 1. Equivalent to but faster than np.minimum(a_max, np.maximum(a, a_min)). No check is performed to ensure a_min < a_max. Parameters: aarray_likeArray containing elements to clip. a_min, a_maxarray_like o...
- numpy.ma.compress_rowcols
...), x is interpreted as a MaskedArray with mask set to nomask. Must be a 2D array. axisint, optionalAxis along which to perform the operation. Default is None. Returns: compressed_arrayndarrayThe compressed array. Examples >>> impor...
- numpy.ma.count
...ray along the given axis. Parameters: axisNone or int or tuple of ints, optionalAxis or axes along which the count is performed. The default, None, performs the count over all the dimensions of the input array. axis may be negative, in wh...
- numpy.ma.diff
...ken, default is the last axis. prepend, appendarray_like, optionalValues to prepend or append to a along axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of...
- numpy.ma.dot
...ve the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a,b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be fle...
- numpy.ma.fix_invalid
...case the a.fill_value is used. Returns: bMaskedArrayThe input array with invalid entries fixed. Notes A copy is performed by default. Examples >>> import numpy as np >>> x = np.ma.array([1., -1, np.nan, np.inf], mask=[1] + [0]*3) >>...
- numpy.ma.mask_rowcols
...the result is a MaskedArray with mask set to nomask (False). Must be a 2D array. axisint, optionalAxis along which to perform the operation. If None, applies to a flattened version of the array. Returns: aMaskedArrayA modified version...
- numpy.ma.masked_array.compress
...then output is truncated to length of condition array. axis{None, int}, optionalAxis along which the operation must be performed. out{None, ndarray}, optionalAlternative output array in which to place the result. It must have the same sha...
- numpy.ma.masked_array.count
...ray along the given axis. Parameters: axisNone or int or tuple of ints, optionalAxis or axes along which the count is performed. The default, None, performs the count over all the dimensions of the input array. axis may be negative, in wh...
- numpy.ma.masked_array.dot
...the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for ma.dot(a,b). This is a performance feature. Therefore, if these conditions are not met, an exception is raised, instead of attempting to be fle...
- numpy.ma.masked_array.take
...uld be of the appropriate shape and dtype. Note that out is always buffered if mode=’raise’; use other modes for better performance. mode{‘raise’, ‘wrap’, ‘clip’}, optionalSpecifies how out-of-bounds indices will behave. ‘raise’ – raise a...
- numpy.ma.masked_array.var
...is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before. dtypedata-type, optionalType to use i...
- numpy.ma.masked_values
...ata=[1. , 1.1, 2. , 1.1, 3. ], mask=False, fill_value=2.1) Unlike masked_equal, masked_values can perform approximate equalities. >>> ma.masked_values(x, 2.1, atol=1e-1) masked_array(data=[1.0, 1.1, --, 1.1, 3.0],...
- numpy.ma.MaskedArray.compress
...then output is truncated to length of condition array. axis{None, int}, optionalAxis along which the operation must be performed. out{None, ndarray}, optionalAlternative output array in which to place the result. It must have the same sha...
- numpy.ma.MaskedArray.count
...ray along the given axis. Parameters: axisNone or int or tuple of ints, optionalAxis or axes along which the count is performed. The default, None, performs the count over all the dimensions of the input array. axis may be negative, in wh...
- numpy.ma.MaskedArray.take
...uld be of the appropriate shape and dtype. Note that out is always buffered if mode=’raise’; use other modes for better performance. mode{‘raise’, ‘wrap’, ‘clip’}, optionalSpecifies how out-of-bounds indices will behave. ‘raise’ – raise a...
- numpy.ma.MaskedArray.var
...is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before. dtypedata-type, optionalType to use i...
- numpy.ma.notmasked_contiguous
...in a masked array along the given axis. Parameters: aarray_likeThe input array. axisint, optionalAxis along which to perform the operation. If None (default), applies to a flattened version of the array, and this is the same as flatnotma...
- numpy.ma.notmasked_edges
...and last unmasked values respectively. Parameters: aarray_likeThe input array. axisint, optionalAxis along which to perform the operation. If None (default), applies to a flattened version of the array. Returns: edgesndarray or list...
- numpy.ma.set_fill_value
...tly, without doing anything. Parameters: aarray_likeInput array. fill_valuedtypeFilling value. A consistency test is performed to make sure the value is compatible with the dtype of a. Returns: NoneNothing returned by this function....
- numpy.ma.var
...is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before. dtypedata-type, optionalType to use i...
- numpy.matrix.any
...uates to True. Refer to numpy.any for full documentation. Parameters: axisint, optionalAxis along which logical OR is performed outndarray, optionalOutput to existing array instead of creating new one, must have same shape as expected ou...
- numpy.mean
...he means are computed. The default is to compute the mean of the flattened array. If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before. dtypedata-type, optionalType to use i...
- numpy.nditer.iternext
...numpy.nditer.iternext method nditer.iternext() Check whether iterations are left, and perform a single internal iteration without returning the result. Used in the C-style pattern do-while pattern. For an...
- numpy.partition
...ition. sortFull sorting Notes The various selection algorithms are characterized by their average speed, worst case performance, work space size, and whether they are stable. A stable sort keeps items with the same key in the same relat...
- numpy.polynomial.chebyshev.Chebyshev.integ
...tance that is the definite integral of the current series. Parameters: mnon-negative intThe number of integrations to perform. karray_likeIntegration constants. The first constant is applied to the first integration, the second to the se...
- numpy.polynomial.hermite.Hermite.integ
...tance that is the definite integral of the current series. Parameters: mnon-negative intThe number of integrations to perform. karray_likeIntegration constants. The first constant is applied to the first integration, the second to the se...
- numpy.polynomial.hermite_e.HermiteE.integ
...tance that is the definite integral of the current series. Parameters: mnon-negative intThe number of integrations to perform. karray_likeIntegration constants. The first constant is applied to the first integration, the second to the se...
- numpy.polynomial.laguerre.Laguerre.integ
...tance that is the definite integral of the current series. Parameters: mnon-negative intThe number of integrations to perform. karray_likeIntegration constants. The first constant is applied to the first integration, the second to the se...
- numpy.polynomial.legendre.Legendre.integ
...tance that is the definite integral of the current series. Parameters: mnon-negative intThe number of integrations to perform. karray_likeIntegration constants. The first constant is applied to the first integration, the second to the se...
- numpy.polynomial.polynomial.Polynomial.integ
...tance that is the definite integral of the current series. Parameters: mnon-negative intThe number of integrations to perform. karray_likeIntegration constants. The first constant is applied to the first integration, the second to the se...
- numpy.prod
.... Parameters: aarray_likeInput data. axisNone or int or tuple of ints, optionalAxis or axes along which a product is performed. The default, axis=None, will calculate the product of all the elements in the input array. If axis is negati...
- numpy.ptp
...is may be negative, in which case it counts from the last to the first axis. 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_likeAlternative output array i...
- numpy.random.BitGenerator.random_raw
...es are drawn. Default is None, in which case a single value is returned. outputbool, optionalOutput values. Used for performance testing since the generated values are not returned. Returns: outuint or ndarrayDrawn samples. Notes...
- numpy.random.Generator.choice
...he sample assumes a uniform distribution over all entries in a. axisint, optionalThe axis along which the selection is performed. The default, 0, selects by row. shufflebool, optionalWhether the sample is shuffled when sampling without re...
- numpy.random.Generator.logistic
...ons, in Epidemiology, and by the World Chess Federation (FIDE) where it is used in the Elo ranking system, assuming the performance of each player is a logistically distributed random variable. References [1] Reiss, R.-D. and Thomas M. (2...
- numpy.random.Generator.multivariate_hypergeometric
...rs contains relatively small integers), the “count” method can be significantly faster than the “marginals” method. If performance of the algorithm is important, test the two methods with typical inputs to decide which works best. Examples...
- numpy.random.Generator.standard_cauchy
...ilted at a random angle will cut the x axis. When studying hypothesis tests that assume normality, seeing how the tests perform on data from a Cauchy distribution is a good indicator of their sensitivity to a heavy-tailed distribution, sinc...
- numpy.random.logistic
...ons, in Epidemiology, and by the World Chess Federation (FIDE) where it is used in the Elo ranking system, assuming the performance of each player is a logistically distributed random variable. References [1] Reiss, R.-D. and Thomas M. (2...
- numpy.random.MT19937.jumped
...mputed using a modified version of Matsumoto’s implementation of Horner’s method. The step polynomial is precomputed to perform 2**128 steps. The jumped state has been verified to match the state produced using Matsumoto’s original code. Re...
- numpy.random.RandomState.logistic
...ons, in Epidemiology, and by the World Chess Federation (FIDE) where it is used in the Elo ranking system, assuming the performance of each player is a logistically distributed random variable. References [1] Reiss, R.-D. and Thomas M. (2...
- numpy.random.RandomState.standard_cauchy
...ilted at a random angle will cut the x axis. When studying hypothesis tests that assume normality, seeing how the tests perform on data from a Cauchy distribution is a good indicator of their sensitivity to a heavy-tailed distribution, sinc...
- numpy.random.standard_cauchy
...ilted at a random angle will cut the x axis. When studying hypothesis tests that assume normality, seeing how the tests perform on data from a Cauchy distribution is a good indicator of their sensitivity to a heavy-tailed distribution, sinc...
- numpy.sort
...y. partitionPartial sort. Notes The various sorting algorithms are characterized by their average speed, worst case performance, work space size, and whether they are stable. A stable sort keeps items with the same key in the same relat...
- numpy.std
...efault is to compute the standard deviation of the flattened array. If this is a tuple of ints, a standard deviation is performed over multiple axes, instead of a single axis or all the axes as before. dtypedtype, optionalType to use in co...
- numpy.sum
...Parameters: aarray_likeElements to sum. axisNone or int or tuple of ints, optionalAxis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from...
- numpy.take
...uld be of the appropriate shape and dtype. Note that out is always buffered if mode=’raise’; use other modes for better performance. mode{‘raise’, ‘wrap’, ‘clip’}, optionalSpecifies how out-of-bounds indices will behave. ‘raise’ – raise a...
- numpy.testing.assert_allclose
...nulp, assert_array_max_ulp Notes When one of actual and desired is a scalar and the other is array_like, the function performs the comparison as if the scalar were broadcasted to the shape of the array. This behaviour can be disabled with...
- numpy.testing.assert_array_equal
..., the behavior of assert_equal(actual, desired) is identical to the behavior of this function. Otherwise, this function performs np.asanyarray on the inputs before comparison, whereas assert_equal defines special comparison rules for common...
- numpy.testing.assert_array_less
...objects for equality up to precision Notes When one of x and y is a scalar and the other is array_like, the function performs the comparison as though the scalar were broadcasted to the shape of the array. This behaviour can be disabled...
- numpy.testing.print_assert_equal
...t_string, actual, desired)[source] Test if two objects are equal, and print an error message if test fails. The test is performed with actual == desired. Parameters: test_stringstrThe message supplied to AssertionError. actualobjectThe o...
- numpy.ufunc.at
...numpy.ufunc.at method ufunc.at(a, indices, b=None, /) Performs unbuffered in place operation on operand ‘a’ for elements specified by ‘indices’. For addition ufunc, this meth...
- numpy.ufunc.reduce
...arrayarray_likeThe array to act on. axisNone or int or tuple of ints, optionalAxis or axes along which a reduction is performed. The default (axis = 0) is perform a reduction over the first dimension of the input array. axis may be negati...
- numpy.ufunc.reduceat
...numpy.ufunc.reduceat method ufunc.reduceat(array, indices, axis=0, dtype=None, out=None) Performs a (local) reduce with specified slices over a single axis. For i in range(len(indices)), reduceat computes ufun...
- numpy.ufunc.signature
...tuple. Core dimensions assigned to the same label in the signature must have exactly matching sizes, no broadcasting is performed. The core dimensions are removed from all inputs and the remaining dimensions are broadcast together, defining...
- numpy.var
...is computed. The default is to compute the variance of the flattened array. If this is a tuple of ints, a variance is performed over multiple axes, instead of a single axis or all the axes as before. dtypedata-type, optionalType to use i...
- numpy.vdot
...x conjugate in the dot product calculation. vdot also handles multidimensional arrays differently than dot: it does not perform a matrix product, but flattens the arguments to 1-D arrays before taking a vector dot product. Consequently, whe...
- numpy.vectorize
...rary Python function and returns a ufunc Notes The vectorize function is provided primarily for convenience, not for performance. The implementation is essentially a for loop. If otypes is not specified, then a call to the function with...
- NumPy: the absolute basics for beginners
...be “heterogeneous”, meaning that they can contain elements of a variety of types, and they are quite fast when used to perform individual operations on a handful of elements. Depending on the characteristics of the data and the types of op...
- Philox counter-based RNG
...and David E. Shaw, “Parallel Random Numbers: As Easy as 1, 2, 3,” Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis (SC11), New York, NY: ACM, 2011. Examples >>> from numpy.rando...
- Putting the inner loop in Cython
...Putting the inner loop in Cython Those who want really good performance out of their low level operations should strongly consider directly using the iteration API provided in C, b...
- Python types and C-structures
...to change across versions of NumPy. To ensure compatibility: Never declare a non-pointer instance of the struct Never perform pointer arithmetic Never use sizeof(PyArray_Descr) It has the following structure: typedef struct { PyObjec...
- Random sampling (
numpy.random
)...RNG algorithms. default_rng currently uses PCG64 as the default BitGenerator. It has better statistical properties and performance than the MT19937 algorithm used in the legacy RandomState. See Bit generators for more details on the suppor...
- Release notes
...Release notes 2.2.0 Deprecations Expired deprecations Compatibility notes New Features Improvements Performance improvements and changes Changes 2.1.3 Improvements Changes Contributors Pull requests merged 2.1.2 Cont...
- Setting up and using your development environment
...tory of your numpy git repo without spin, that will result in strange test errors. Running linting Lint checks can be performed on newly added lines of Python code. Install all dependent packages using pip: $ python -m pip install -r requ...
- Signature file
...place); intent(in,inplace) is intent(inplace); intent(hide) disables optional and required. check([<C-booleanexpr>])Performs a consistency check on the arguments by evaluating <C-booleanexpr>; if <C-booleanexpr> returns 0, an exception...
- Standard array subclasses
...type. This matches Python’s rule for calling reflected methods, and this ensures that checking overloads has acceptable performance even when there are a large number of overloaded arguments. class.__array_finalize__(obj) This method is...
- String functionality
...also used in numpy.char, which provides the numpy.char.chararray array subclass, in order for those routines to get the performance benefits as well. Note Prior to NumPy 2.0, all string functionality was in numpy.char, which only operated...
- Structured arrays
...set, numpy will pad the structure in the same way many C compilers would pad a C-struct. Aligned structures can give a performance improvement in some cases, at the cost of increased datatype size. Padding bytes are inserted between fields...
- Testing guidelines
...f the module to test. Notes Unlike the previous nose-based implementation, this class is not publicly exposed as it performs some numpy-specific warning suppression. Attributes: module_namestrFull path to the package to test....
- Testing the numpy.i typemaps
...ng takes place with a Python script named: testVector.py that uses the standard Python library module unittest, which performs several tests of each function defined in Vector.h for each data type supported. Two-dimensional arrays are tes...
- The
numpy.ma
module...9999.) >>> print(mx.filled(mx.mean())) [0. 1. 2. 3. 4.] Numerical operations Numerical operations can be easily performed without worrying about missing values, dividing by zero, square roots of negative numbers, etc.: >>> import nu...
- The N-dimensional array (
ndarray
)...all elements and the base offset itself is a multiple of self.itemsize. Understanding memory-alignment leads to better performance on most hardware. Warning It does not generally hold that self.strides[-1] == self.itemsize for C-style con...
- Thread Safety
...library. Many NumPy operations release the GIL, so unlike many situations in Python, it is possible to improve parallel performance by exploiting multithreaded parallelism in Python. The easiest performance gains happen when each worker thr...
- Typing (
numpy.typing
)...cessary distinction between 0D and >0D arrays. While thus not strictly correct, all operations are that can potentially perform a 0D-array -> scalar cast are currently annotated as exclusively returning an ndarray. If it is known in advance...
- Universal functions (
ufunc
)...e calculation. The exact calculation DTypes chosen may depend on the ufunc and the inputs may be cast to this DType to perform the calculation. subok Defaults to true. If set to false, the output will always be a strict array, not a subtyp...
- Universal functions (
ufunc
) basics...at, out=y) array([ 0, 28, 80]) Ufuncs also have a fifth method, numpy.ufunc.at, that allows in place operations to be performed using advanced indexing. No buffering is used on the dimensions where advanced indexing is used, so the advanc...
- Upgrading
PCG64
withPCG64DXSM
...r implementation used by default_rng in future releases. PCG64DXSM solves the statistical weakness while preserving the performance and the features of PCG64. Does this affect me? If you only use a single Generator instance, only use Rand...
- Using F2PY
...may be required for non-gcc Fortran compilers: -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN To test the performance of F2PY generated interfaces, use -DF2PY_REPORT_ATEXIT. Then a report of various timings is printed out at t...
- Using Python as glue
...to write your own converter and use the "O&" format string which allows you to specify a function that will be used to perform the conversion from the Python object to whatever C-structures are needed. Once the conversions to the appropria...
- What is NumPy?
...e, is the ndarray object. This encapsulates n-dimensional arrays of homogeneous data types, with many operations being performed in compiled code for performance. There are several important differences between NumPy arrays and the standar...
- What’s new or different
...] Optional axis argument for methods like choice, permutation and shuffle that controls which axis an operation is performed over for multi-dimensional arrays. In [14]: rng = np.random.default_rng() In [15]: a = np.arange(12).reshape...
- Writing your own ufunc
...example, if a python interpreter is opened in the file containing the spam library or spam has been installed, one can perform the following commands: >>> import numpy as np >>> import spam >>> spam.logit(0) -inf >>> spam.logit(1) inf >>>...