Search
Searching..
- numpy.where
...NumPy reference Routines and objects by topic Indexing routines numpy.where...
- numpy.ma.where (Python function, in numpy.ma.where)
- numpy.where (Python function, in numpy.where)
numpy.distutils
user guide...files(*files) — prepend files to data_files list. If files item is a tuple then its first element defines the suffix of where data files are copied relative to package installation directory and the second element specifies the path to data...
numpy.polynomial
...s coefficients, ordered from lowest order term to highest. For example, array([1,2,3]) represents P_0 + 2*P_1 + 3*P_2, where P_n is the n-th order basis polynomial applicable to the specific module in question, e.g., polynomial (which “wra...
- Array creation
...define properties of special matrices represented as 2D arrays. np.eye(n, m) defines a 2D identity matrix. The elements where i=j (row index and column index are equal) are 1 and the rest are 0, as such: >>> import numpy as np >>> np.eye(3)...
- Array iterator API
...rite overlap exists, this flag ensures the result of the operation is the same as if all operands were copied. In cases where copies would need to be made, the result of the computation may be undefined without this flag! Flags that may be...
- Chebyshev Series (
numpy.polynomial.chebyshev
)...identities [1]: \[\begin{split}T_n(x) = \frac{z^n + z^{-n}}{2} \\ z\frac{dx}{dz} = \frac{z - z^{-1}}{2}.\end{split}\] where \[x = \frac{z + z^{-1}}{2}.\] These identities allow a Chebyshev series to be expressed as a finite, symmetric La...
- Constants of the
numpy.ma
module...e data, as a regular numpy.ndarray of any shape or datatype (the data). A boolean mask with the same shape as the data, where a True value indicates that the corresponding element of the data is invalid. The special value nomask is also acc...
- Contributing to NumPy
...y to add the deprecation. Cross referencing issues If the PR relates to any issues, you can add the text xref gh-xxxx where xxxx is the number of the issue to github comments. Likewise, if the PR solves an issue, replace the xref with clo...
- ctypes foreign function interface (
numpy.ctypeslib
)...libnamepath-likeName of the library, which can have ‘lib’ as a prefix, but without an extension. loader_pathpath-likeWhere the library can be found. Returns: ctypes.cdll[libpath]library objectA ctypes library object Raises: OSErr...
- Data type promotion in NumPy
...tween a Python integer and a NumPy integer should be a NumPy integer. However, Python integers have arbitrary precision whereas all NumPy dtypes have fixed precision, so the arbitrary precision of Python integers cannot be preserved. More g...
- Data types
...-bit CPU architectures). This should be taken into account when interfacing with low-level code (such as C or Fortran) where the raw memory is addressed. Data Types for Strings and Bytes In addition to numerical types, NumPy also support...
- Discrete Fourier Transform (
numpy.fft
)...ency component at linear frequency \(f\) is represented by a complex exponential \(a_m = \exp\{2\pi i\,f m\Delta t\}\), where \(\Delta t\) is the sampling interval. The values in the result follow so-called “standard” order: If A = fft(a, n...
- For downstream package authors
...be installed alongside other, newer packages. [*] The reason for setting N=3 is that NumPy will, on the rare occasion where it makes breaking changes, raise warnings for at least two releases. (NumPy releases about once every six months,...
- How to contribute to the NumPy documentation
...ocumentation is a NumPy Enhancement Proposal (NEP), NEP 44 — Restructuring the NumPy documentation. It identifies areas where our docs need help and lists several additions we’d like to see, including Jupyter notebooks. Documentation frame...
- How to extend NumPy
...ting an extension module that this tool depends on. When an extension module is written, compiled, and installed to somewhere in the Python path (sys.path), the code can then be imported into Python as if it were a standard python file. It...
- How to write a NumPy how-to
...out into an individual how-to and linking to it. Include subheadings. They help readers grasp what’s coming and return where they left off. Why write how-tos when there’s Stack Overflow, Reddit, Gitter…? We have authoritative answers....
- Internal organization of NumPy arrays
...he second index to indicate which column is selected. This is opposite the geometrically oriented-convention for images where people generally think the first index represents x position (i.e., column) and the second represents y position (...
- Interoperability with NumPy
...imitations. As datasets grow and NumPy becomes used in a variety of new environments and architectures, there are cases where the strided in-RAM storage strategy is inappropriate, which has caused different libraries to reimplement this API...
- Memory alignment
...imag; }. This has “true” alignment of 4 and “uint” alignment of 8 (equal to the true alignment of uint64). Some cases where uint and true alignment are different (default GCC Linux): arch type true-aln uint-aln x86_64 complex64 4 8 x...
- Memory management in NumPy
...p the struct aligned */ uint8_t version; /* currently 1 */ PyDataMemAllocator allocator; } PyDataMem_Handler; where the allocator structure is /* The declaration of free differs from PyMemAllocatorEx */ typedef struct { void *...
- NumPy 1.10.0 Release Notes
...kind'. For instance, if n is an array of integers, and f is an array of floats, then n += f will result in a TypeError, whereas in previous Numpy versions the floats would be silently cast to ints. In the unlikely case that the example code...
- NumPy 1.11.0 Release Notes
...be viewed using a dtype of different size causing the last dimension to change. That differs from the current behavior where arrays that are f_contiguous but not c_contiguous can be viewed as a dtype type of different size causing the firs...
- NumPy 1.12.0 Release Notes
...Any user-provided value of keepdims is passed through as a keyword argument to the method. This will raise in the case where the method does not support a keepdims kwarg and the user explicitly passes in keepdims. The following functions a...
- NumPy 1.13.0 Release Notes
...gate, which throws an error). Calling expand_dims when the axis keyword does not satisfy -a.ndim - 1 <= axis <= a.ndim, where a is the array being reshaped, is deprecated. Future Changes Assignment between structured arrays with differe...
- NumPy 1.13.1 Release Notes
...ont page and some doc build metadata. #9299 BUG: Fix Intel compilation on Unix. #9317 BUG: fix wrong ndim used in empty where check #9319 BUG: Make extensions compilable with MinGW on Py2.7 #9339 BUG: Prevent crash if ufunc doc string is nu...
- NumPy 1.14.0 Release Notes
...change affects only float32 and float16 arrays. count_nonzero(arr, axis=()) now counts over no axes, not all axes Elsewhere, axis==() is always understood as “no axes”, but count_nonzero had a special case to treat this as “all axes”. Thi...
- NumPy 1.15.0 Release Notes
...in a context manager When using an numpy.nditer with the "writeonly" or "readwrite" flags, there are some circumstances where nditer doesn’t actually give you a view of the writable array. Instead, it gives you a copy, and if you make chang...
- NumPy 1.16.0 Release Notes
...ld no longer interact with the host machine shell directly. exec_command has been replaced with subprocess.check_output where appropriate. np.polynomial.Polynomial classes render in LaTeX in Jupyter notebooks When used in a front-end that...
- NumPy 1.17.0 Release Notes
...unsafe casting is allowed Previously, can_cast returned True for almost all inputs for casting='unsafe', even for cases where casting was not possible, such as from a structured dtype to a regular one. This has been fixed, making it more c...
- NumPy 1.18.0 Release Notes
...ctions np.fromfile and np.fromstring will throw an error when parsing bad data. This will now give a DeprecationWarning where previously partial or even invalid data was silently returned. This deprecation also affects the C defined functio...
- NumPy 1.18.1 Release Notes
...#15222: MAINT: unskip test on win32 #15223: TST: add BLAS ILP64 run in Travis & Azure #15245: MAINT: only add –std=c99 where needed #15246: BUG: lib: Fix handling of integer arrays by gradient. #15247: MAINT: Do not use private Python func...
- NumPy 1.19.0 Release Notes
...ions numpy.insert and numpy.delete can no longer be passed an axis on 0d arrays This concludes a deprecation from 1.9, where when an axis argument was passed to a call to ~numpy.insert and ~numpy.delete on a 0d array, the axis and obj argu...
- NumPy 1.20.0 Release Notes
...ucture Array coercion has been restructured. In general, this should not affect users. In extremely rare corner cases where array-likes are nested: np.array([array_like1]) Things will now be more consistent with: np.array([np.array(arra...
- NumPy 1.20.2 Release Notes
...tions for dtype.__getitem__, __mul__ and… #18611: BUG: NameError in numpy.distutils.fcompiler.compaq #18612: BUG: Fixed where keyword for np.mean & np.var methods #18617: CI: Update apt package list before Python install #18636: MAINT: Ensu...
- NumPy 1.21.0 Release Notes
...by keyword), NumPy will now only dispatch on the input and output array. For example, NumPy will never dispatch on the where array in a reduction such as np.add.reduce. (gh-15271) Validate input values in Generator.uniform Checked that h...
- NumPy 1.22.0 Release Notes
..."formats": [int], "offsets": [2]}) is now dtype({'names': ['a'], 'formats': ['<i8'], 'offsets': [2], 'itemsize': 10}), whereas spaces where previously omitted after colons and between fields. The old behavior can be restored via np.set_pri...
- NumPy 1.22.2 Release Notes
...ample as per new release #20935: TYP, MAINT: Add annotations for flatiter.__setitem__ #20936: MAINT, TYP: Added missing where typehints in fromnumeric.pyi #20937: BUG: Fix build_ext interaction with non numpy extensions #20938: BUG: Fix mis...
- NumPy 1.23.0 Release Notes
...raised. (gh-20835) Multidimensional indexing with non-tuple values is not allowed. Previously, code such as arr[ind] where ind = [[0, 1], [0, 1]] produced a FutureWarning and was interpreted as a multidimensional index (i.e., arr[tuple(i...
- NumPy 1.24 Release Notes
...change means that a view rather than the input array is returned. The following is an example for this on 64bit Linux where long and longlong are the same precision but different dtypes: >>> arr = np.array([1, 2, 3], dtype="long") >>> new...
- NumPy 1.25.0 Release Notes
...=. This is no longer supported. (gh-23376) Compatibility notes The busday_count method now correctly handles cases where the begindates is later in time than the enddates. Previously, the enddates was included, even though the document...
- NumPy 1.26.3 Release Notes
...26.x for further development #25188: TYP: add None to __getitem__ in numpy.array_api #25189: BLD,BUG: quadmath required where available [f2py] #25190: BUG: alpha doesn’t use REAL(10) #25191: BUG: Fix FP overflow error in division when the d...
- NumPy 1.3.0 Release Notes
- NumPy 1.7.0 Release Notes
...orings. It supports Python 2.4 - 2.7 and 3.1 - 3.3 and is the last release that supports Python 2.4 - 2.5. Highlights where= parameter to ufuncs (allows the use of boolean arrays to choose where a computation should be done) vectorize imp...
- NumPy 1.8.0 Release Notes
...operations with non-arrays as second argument Binary operations of the form <array-or-subclass> * <non-array-subclass> where <non-array-subclass> declares an __array_priority__ higher than that of <array-or-subclass> will now unconditional...
- NumPy 1.9.0 Release Notes
...rray.tobytes have been added as aliases for tostring which exports arrays as bytes. This is more consistent in Python 3 where str and bytes are not the same. Build system Added experimental support for the ppc64le and OpenRISC architectur...
- NumPy 1.9.1 Release Notes
...ce index to tuple gh-5082: Segmentation fault with argmin() on unicode arrays gh-5095: don’t propagate subtypes from np.where gh-5104: np.inner segfaults with SciPy’s sparse matrices gh-5251: Issue with fromarrays not using correct format f...
- NumPy 2.0 migration guide
...e/descriptor itself is attached to an array (e.g. arr->descr->elsize) this is best replaced with PyArray_ITEMSIZE(arr). Where not possible, new accessor functions are required: PyDataType_ELSIZE and PyDataType_SET_ELSIZE (note that the res...
- NumPy 2.0.0 Release Notes
...ctype, np.sctype2char, np.sctypes, np.issubsctype were all removed from the main namespace without replacement, as they where niche members. Deprecated np.deprecate and np.deprecate_with_doc has been removed from the main namespace. Use Dep...
- NumPy 2.1.0 Release Notes
...nificantly reduces the wall time, but will return slightly different estimates of the correlation coefficients in cases where the observations between a pair of variables are not aligned. However, it will return the same estimates in all ot...
- NumPy 2.2.0 Release Notes
...fixed which allows F2PY users to expose variables to Python in modules with only assignments, and also fixes situations where multiple modules are present within a single source file. (gh-27695) Performance improvements and changes Impr...
- NumPy benchmarks
...cations: cd benchmarks/ export REGEXP="bench.*Ufunc" asv run --dry-run --show-stderr --python=same --quick -b $REGEXP Where the regular expression used to match benchmarks is stored in $REGEXP, and –quick is used to avoid repetitions. To...
- NumPy C code explanations
...ed so that pre-processing is performed on the inputs and post-processing is performed on the outputs in bufsize chunks (where bufsize is a user-settable parameter). The underlying 1-D computational loop is called on data that is copied over...
- NumPy core math library
...first step in this direction. This library contains most math-related C99 functionality, which can be used on platforms where C99 is not well supported. The core math functions have the same API as the C99 ones, except for the npy_* prefix....
- NumPy for MATLAB users
...lp func info(func) or help(func) or func? (in IPython) get help on the function func which func see note HELP find out where func is defined type func np.source(func) or func?? (in IPython) print source for func (if not a native function)...
- NumPy project governance and decision-making
...ectations – see below). Some members of the community additionally contribute by serving on the NumPy steering council, where they are responsible for facilitating the establishment of community consensus, for stewarding project resources,...
- NumPy quickstart
...m, mean, median, min, minimum, nonzero, outer, prod, re, round, sort, std, sum, trace, transpose, var, vdot, vectorize, where Indexing, slicing and iterating One-dimensional arrays can be indexed, sliced and iterated over, much like list...
- numpy.absolute
...numpy.absolute numpy.absolute(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'absolute'> Calculate the abso...
- numpy.acos
...numpy.acos numpy.acos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'arccos'> Trigonometric invers...
- numpy.acosh
...numpy.acosh numpy.acosh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'arccosh'> Inverse hyperbolic...
- numpy.add
...numpy.add numpy.add(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'add'> Add arguments element-w...
- numpy.all
...numpy.all numpy.all(a, axis=None, out=None, keepdims=<no value>, *, where=<no value>)[source] Test whether all array elements along a given axis evaluate to True. Parameters: aarray_like...
- numpy.amax
- numpy.amin
- numpy.any
...numpy.any numpy.any(a, axis=None, out=None, keepdims=<no value>, *, where=<no value>)[source] Test whether any array element along a given axis evaluates to True. Returns single boolean if...
- numpy.apply_along_axis
..., arr, *args, **kwargs)[source] Apply a function to 1-D slices along the given axis. Execute func1d(a, *args, **kwargs) where func1d operates on 1-D arrays and a is a 1-D slice of arr along axis. This is equivalent to (but faster than) the...
- numpy.apply_over_axes
- numpy.arange
- numpy.arccos
...numpy.arccos numpy.arccos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'arccos'> Trigonometric invers...
- numpy.arccosh
- numpy.arcsin
- numpy.arcsinh
- numpy.arctan
- numpy.arctan2
- numpy.arctanh
- numpy.argwhere
- numpy.asin
- numpy.asinh
- numpy.atan
- numpy.atan2
- numpy.atanh
- numpy.atleast_2d
- numpy.atleast_3d
- numpy.average
- numpy.bartlett
- numpy.bitwise_and
- numpy.bitwise_count
- numpy.bitwise_invert
- numpy.bitwise_left_shift
- numpy.bitwise_or
- numpy.bitwise_right_shift
- numpy.bitwise_xor
- numpy.blackman
- numpy.block
- numpy.cbrt
- numpy.ceil
- numpy.char.add
- numpy.char.chararray.all
- numpy.char.chararray.any
- numpy.char.chararray.ctypes
- numpy.char.chararray.endswith
- numpy.char.chararray.expandtabs
- numpy.char.chararray.fill
- numpy.char.chararray.find
- numpy.char.chararray.max
- numpy.char.chararray.mean
- numpy.char.chararray.min
- numpy.char.chararray.prod
- numpy.char.chararray.rfind
- numpy.char.chararray.searchsorted
- numpy.char.chararray.startswith
- numpy.char.chararray.std
- numpy.char.chararray.sum
- numpy.char.chararray.translate
- numpy.char.chararray.var
- numpy.char.endswith
- numpy.char.expandtabs
- numpy.char.find
- numpy.char.isalnum
- numpy.char.isalpha
- numpy.char.isdecimal
- numpy.char.isdigit
- numpy.char.islower
- numpy.char.isnumeric
- numpy.char.isspace
- numpy.char.istitle
- numpy.char.isupper
- numpy.char.rfind
- numpy.char.startswith
- numpy.char.str_len
- numpy.char.translate
- numpy.choose
- numpy.clip
- numpy.compress
- numpy.concat
- numpy.concatenate
- numpy.conj
- numpy.conjugate
- numpy.convolve
- numpy.copysign
- numpy.copyto
- numpy.correlate
- numpy.cos
- numpy.cosh
- numpy.cov
- numpy.cross
- numpy.deg2rad
- numpy.degrees
- numpy.diff
- numpy.distutils.ccompiler.CCompiler_find_executables
- numpy.distutils.ccompiler.simple_version_match
- numpy.divide
- numpy.divmod
- numpy.dot
- numpy.einsum
- numpy.equal
- numpy.exp
- numpy.exp2
- numpy.expand_dims
- numpy.expm1
- numpy.extract
- numpy.eye
- numpy.fabs
- numpy.fft.hfft
- numpy.fft.irfft
- numpy.fft.irfftn
- numpy.float_power
- numpy.floor
- numpy.floor_divide
- numpy.fmax
- numpy.fmin
- numpy.fmod
- numpy.frexp