id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
168,831
import functools import re import warnings import numpy.core.numeric as NX from numpy.core import (isscalar, abs, finfo, atleast_1d, hstack, dot, array, ones) from numpy.core import overrides from numpy.core.overrides import set_module from numpy.lib.twodim_base import diag, vander from numpy.li...
Find the product of two polynomials. .. note:: This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in `numpy.polynomial` is preferred. A summary of the differences can be found in the :doc:`transition guide </reference/routines.polynomials>`. Finds the polynomial resulting from ...
168,832
import functools import re import warnings import numpy.core.numeric as NX from numpy.core import (isscalar, abs, finfo, atleast_1d, hstack, dot, array, ones) from numpy.core import overrides from numpy.core.overrides import set_module from numpy.lib.twodim_base import diag, vander from numpy.li...
null
168,833
import functools import re import warnings import numpy.core.numeric as NX from numpy.core import (isscalar, abs, finfo, atleast_1d, hstack, dot, array, ones) from numpy.core import overrides from numpy.core.overrides import set_module from numpy.lib.twodim_base import diag, vander from numpy.li...
Returns the quotient and remainder of polynomial division. .. note:: This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in `numpy.polynomial` is preferred. A summary of the differences can be found in the :doc:`transition guide </reference/routines.polynomials>`. The input arra...
168,834
import functools import re import warnings import numpy.core.numeric as NX from numpy.core import (isscalar, abs, finfo, atleast_1d, hstack, dot, array, ones) from numpy.core import overrides from numpy.core.overrides import set_module from numpy.lib.twodim_base import diag, vander from numpy.li...
null
168,858
import functools import numpy.core.numeric as _nx from numpy.core.numeric import ( asarray, zeros, outer, concatenate, array, asanyarray ) from numpy.core.fromnumeric import reshape, transpose from numpy.core.multiarray import normalize_axis_index from numpy.core import overrides from numpy.core import vstack, ...
null
168,860
import functools import numpy.core.numeric as _nx from numpy.core.numeric import ( asarray, zeros, outer, concatenate, array, asanyarray ) from numpy.core.fromnumeric import reshape, transpose from numpy.core.multiarray import normalize_axis_index from numpy.core import overrides from numpy.core import vstack, ...
null
168,875
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _recursive_fill_fields_dispatcher(input,...
null
168,876
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like The provided code snippet includes necessary...
Returns the field names of the input datatype as a tuple. Input datatype must have fields otherwise error is raised. Parameters ---------- adtype : dtype Input datatype Examples -------- >>> from numpy.lib import recfunctions as rfn >>> rfn.get_names(np.empty((1,), dtype=[('A', int)]).dtype) ('A',) >>> rfn.get_names(np...
168,877
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like The provided code snippet includes necessary...
Returns the field names of the input datatype as a tuple. Input datatype must have fields otherwise error is raised. Nested structure are flattened beforehand. Parameters ---------- adtype : dtype Input datatype Examples -------- >>> from numpy.lib import recfunctions as rfn >>> rfn.get_names_flat(np.empty((1,), dtype=...
168,878
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _zip_dtype(seqarrays, flatten=False): ...
Combine the dtype description of a series of arrays. Parameters ---------- seqarrays : sequence of arrays Sequence of arrays flatten : {boolean}, optional Whether to collapse nested descriptions.
168,879
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _merge_arrays_dispatcher(seqarrays, fill...
null
168,880
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _drop_fields_dispatcher(base, drop_names...
null
168,881
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _rec_drop_fields_dispatcher(base, drop_n...
null
168,882
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def drop_fields(base, drop_names, usemask=Tru...
Returns a new numpy.recarray with fields in `drop_names` dropped.
168,883
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _rename_fields_dispatcher(base, namemapp...
null
168,884
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like The provided code snippet includes necessary...
Rename the fields from a flexible-datatype ndarray or recarray. Nested fields are supported. Parameters ---------- base : ndarray Input array whose fields must be modified. namemapper : dictionary Dictionary mapping old field names to their new version. Examples -------- >>> from numpy.lib import recfunctions as rfn >>...
168,885
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _append_fields_dispatcher(base, names, d...
null
168,886
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _rec_append_fields_dispatcher(base, name...
null
168,887
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def append_fields(base, names, data, dtypes=N...
Add new fields to an existing array. The names of the fields are given with the `names` arguments, the corresponding values with the `data` arguments. If a single field is appended, `names`, `data` and `dtypes` do not have to be lists but just values. Parameters ---------- base : array Input array to extend. names : st...
168,888
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _repack_fields_dispatcher(a, align=None,...
null
168,889
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like The provided code snippet includes necessary...
Re-pack the fields of a structured array or dtype in memory. The memory layout of structured datatypes allows fields at arbitrary byte offsets. This means the fields can be separated by padding bytes, their offsets can be non-monotonically increasing, and they can overlap. This method removes any overlaps and reorders ...
168,890
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _structured_to_unstructured_dispatcher(a...
null
168,891
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _unstructured_to_structured_dispatcher(a...
null
168,892
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _get_fields_and_offsets(dt, offset=0): ...
Converts an n-D unstructured array into an (n-1)-D structured array. The last dimension of the input array is converted into a structure, with number of field-elements equal to the size of the last dimension of the input array. By default all output fields have the input array's dtype, but an output structured dtype wi...
168,893
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _apply_along_fields_dispatcher(func, arr...
null
168,894
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def structured_to_unstructured(arr, dtype=Non...
Apply function 'func' as a reduction across fields of a structured array. This is similar to `apply_along_axis`, but treats the fields of a structured array as an extra axis. The fields are all first cast to a common type following the type-promotion rules from `numpy.result_type` applied to the field's dtypes. Paramet...
168,895
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _assign_fields_by_name_dispatcher(dst, s...
null
168,896
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _require_fields_dispatcher(array, requir...
null
168,897
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def assign_fields_by_name(dst, src, zero_unas...
Casts a structured array to a new dtype using assignment by field-name. This function assigns from the old to the new array by name, so the value of a field in the output array is the value of the field with the same name in the source array. This has the effect of creating a new ndarray containing only the fields "req...
168,898
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _stack_arrays_dispatcher(arrays, default...
null
168,899
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _get_fieldspec(dtype): """ Produc...
Superposes arrays fields by fields Parameters ---------- arrays : array or sequence Sequence of input arrays. defaults : dictionary, optional Dictionary mapping field names to the corresponding default values. usemask : {True, False}, optional Whether to return a MaskedArray (or MaskedRecords is `asrecarray==True`) or ...
168,900
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _find_duplicates_dispatcher( a, ...
null
168,901
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def get_fieldstructure(adtype, lastname=None,...
Find the duplicates in a structured array along a given key Parameters ---------- a : array-like Input array key : {string, None}, optional Name of the fields along which to check the duplicates. If None, the search is performed by records ignoremask : {True, False}, optional Whether masked data should be discarded or ...
168,902
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _join_by_dispatcher( key, r1, r2...
null
168,903
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def _rec_join_dispatcher( key, r1, r...
null
168,904
import itertools import numpy as np import numpy.ma as ma from numpy import ndarray, recarray from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.core.overrides import array_function_dispatch from numpy.lib._iotools import _is_string_like def join_by(key, r1, r2, jointype='inner', r1...
Join arrays `r1` and `r2` on keys. Alternative to join_by, that always returns a np.recarray. See Also -------- join_by : equivalent function
168,905
import numpy import warnings from numpy.lib.utils import safe_eval from numpy.compat import ( isfileobj, os_fspath, pickle ) def _write_array_header(fp, d, version=None): """ Write the header for an array and returns the version used Parameters ---------- fp : filelike object d : dict ...
Write the header for an array using the 1.0 format. Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header of the file.
168,906
import numpy import warnings from numpy.lib.utils import safe_eval from numpy.compat import ( isfileobj, os_fspath, pickle ) def _write_array_header(fp, d, version=None): """ Write the header for an array and returns the version used Parameters ---------- fp : filelike object d : dict ...
Write the header for an array using the 2.0 format. The 2.0 format allows storing very large structured arrays. .. versionadded:: 1.9.0 Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header of the file.
168,907
import numpy import warnings from numpy.lib.utils import safe_eval from numpy.compat import ( isfileobj, os_fspath, pickle ) _MAX_HEADER_SIZE = 10000 def _read_array_header(fp, version, max_header_size=_MAX_HEADER_SIZE): """ see read_array_header_1_0 """ # Read an unsigned, little-endian short i...
Read an array header from a filelike object using the 1.0 file format version. This will leave the file object located just after the header. Parameters ---------- fp : filelike object A file object or something with a `.read()` method like a file. Returns ------- shape : tuple of int The shape of the array. fortran_or...
168,908
import numpy import warnings from numpy.lib.utils import safe_eval from numpy.compat import ( isfileobj, os_fspath, pickle ) _MAX_HEADER_SIZE = 10000 def _read_array_header(fp, version, max_header_size=_MAX_HEADER_SIZE): """ see read_array_header_1_0 """ # Read an unsigned, little-endian short i...
Read an array header from a filelike object using the 2.0 file format version. This will leave the file object located just after the header. .. versionadded:: 1.9.0 Parameters ---------- fp : filelike object A file object or something with a `.read()` method like a file. max_header_size : int, optional Maximum allowed...
168,909
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _ptp(x): """Peak-to-peak value of x. This implementation avoids the problem of signed integer arrays having a peak-to-peak value that cannot be represented with the array's data type. ...
Square root histogram bin estimator. Bin width is inversely proportional to the data size. Used by many programs for its simplicity. Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to range. May not be empty. Returns ------- h : An estimate of the optimal bin width for the given data...
168,910
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _ptp(x): """Peak-to-peak value of x. This implementation avoids the problem of signed integer arrays having a peak-to-peak value that cannot be represented with the array's data type. ...
Rice histogram bin estimator. Another simple estimator with no normality assumption. It has better performance for large data than Sturges, but tends to overestimate the number of bins. The number of bins is proportional to the cube root of data size (asymptotically optimal). The estimate depends only on size of the da...
168,911
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides The provided code snippet includes necessary dependencies for implementing the `_hist_bin_scott` function. Write a Python function `def _hist_bin_scott(x, range)` to solve the following problem: Scott...
Scott histogram bin estimator. The binwidth is proportional to the standard deviation of the data and inversely proportional to the cube root of data size (asymptotically optimal). Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to range. May not be empty. Returns ------- h : An esti...
168,912
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides _range = range def _ptp(x): """Peak-to-peak value of x. This implementation avoids the problem of signed integer arrays having a peak-to-peak value that cannot be represented with the array...
Histogram bin estimator based on minimizing the estimated integrated squared error (ISE). The number of bins is chosen by minimizing the estimated ISE against the unknown true distribution. The ISE is estimated using cross-validation and can be regarded as a generalization of Scott's rule. https://en.wikipedia.org/wiki...
168,913
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _ptp(x): """Peak-to-peak value of x. This implementation avoids the problem of signed integer arrays having a peak-to-peak value that cannot be represented with the array's data type. ...
Doane's histogram bin estimator. Improved version of Sturges' formula which works better for non-normal data. See stats.stackexchange.com/questions/55134/doanes-formula-for-histogram-binning Parameters ---------- x : array_like Input data that is to be histogrammed, trimmed to range. May not be empty. Returns ------- h...
168,914
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _hist_bin_sturges(x, range): """ Sturges histogram bin estimator. A very simplistic estimator based on the assumption of normality of the data. This estimator has poor performance f...
Histogram bin estimator that uses the minimum width of the Freedman-Diaconis and Sturges estimators if the FD bin width is non-zero. If the bin width from the FD estimator is 0, the Sturges estimator is used. The FD estimator is usually the most robust method, but its width estimate tends to be too large for small `x` ...
168,915
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _histogram_bin_edges_dispatcher(a, bins=None, range=None, weights=None): return (a, bins, weights)
null
168,916
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _ravel_and_check_weights(a, weights): """ Check a and weights have matching shapes, and ravel both """ a = np.asarray(a) # Ensure that the array is a "subtractable" dtype if a.dtype...
r""" Function to calculate only the edges of the bins used by the `histogram` function. Parameters ---------- a : array_like Input data. The histogram is computed over the flattened array. bins : int or sequence of scalars or str, optional If `bins` is an int, it defines the number of equal-width bins in the given rang...
168,917
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _histogram_dispatcher( a, bins=None, range=None, density=None, weights=None): return (a, bins, weights)
null
168,918
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides def _histogramdd_dispatcher(sample, bins=None, range=None, density=None, weights=None): if hasattr(sample, 'shape'): # same condition as used in histogramdd yi...
null
168,919
import contextlib import functools import operator import warnings import numpy as np from numpy.core import overrides _range = range def _get_outer_edges(a, range): """ Determine the outer bin edges to use, from either the data or the range argument """ if range is not None: first_edge, las...
Compute the multidimensional histogram of some data. Parameters ---------- sample : (N, D) array, or (N, D) array_like The data to be histogrammed. Note the unusual interpretation of sample when an array_like: * When an array, each row is a coordinate in a D-dimensional space - such as ``histogramdd(np.array([p1, p2, p...
168,920
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides The provided code snippet includes necessary dependencies for implementing the `_nan_mask` function. Write a Python function `def _nan_mask(a, out=None)` to solve the following problem: Parameters -...
Parameters ---------- a : array-like Input array with at least 1 dimension. out : ndarray, optional Alternate output array in which to place the result. The default is ``None``; if provided, it must have the same shape as the expected output and will prevent the allocation of a new array. Returns ------- y : bool ndarr...
168,921
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanmin_dispatcher(a, axis=None, out=None, keepdims=None, initial=None, where=None): return (a, out)
null
168,922
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return minimum of an array or minimum along an axis, ignoring any NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is raised and Nan is returned for that slice. Parameters ---------- a : array_like Array containing numbers whose minimum is desired. If `a` is not an array, a conversion is attempted. axis :...
168,923
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanmax_dispatcher(a, axis=None, out=None, keepdims=None, initial=None, where=None): return (a, out)
null
168,924
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the maximum of an array or maximum along an axis, ignoring any NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is raised and NaN is returned for that slice. Parameters ---------- a : array_like Array containing numbers whose maximum is desired. If `a` is not an array, a conversion is attempted. ax...
168,925
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanargmin_dispatcher(a, axis=None, out=None, *, keepdims=None): return (a,)
null
168,926
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the indices of the minimum values in the specified axis ignoring NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results cannot be trusted if a slice contains only NaNs and Infs. Parameters ---------- a : array_like Input data. axis : int, optional Axis along which to operate. By default flattene...
168,927
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanargmax_dispatcher(a, axis=None, out=None, *, keepdims=None): return (a,)
null
168,928
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the indices of the maximum values in the specified axis ignoring NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results cannot be trusted if a slice contains only NaNs and -Infs. Parameters ---------- a : array_like Input data. axis : int, optional Axis along which to operate. By default flatten...
168,929
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nansum_dispatcher(a, axis=None, dtype=None, out=None, keepdims=None, initial=None, where=None): return (a, out)
null
168,930
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or empty. In later versions zero is returned. Parameters ---------- a : array_like Array containing numbers whose sum is desired. If `a` is not an array, a con...
168,931
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanprod_dispatcher(a, axis=None, dtype=None, out=None, keepdims=None, initial=None, where=None): return (a, out)
null
168,932
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones. One is returned for slices that are all-NaN or empty. .. versionadded:: 1.10.0 Parameters ---------- a : array_like Array containing numbers whose product is desired. If `a` is not an array, a conversion is attempted. axis : {...
168,933
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nancumsum_dispatcher(a, axis=None, dtype=None, out=None): return (a, out)
null
168,934
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros. Zeros are returned for slices that are all-NaN or empty. .. versionadded:: 1.12.0 Parameters ---------- a : array_like...
168,935
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nancumprod_dispatcher(a, axis=None, dtype=None, out=None): return (a, out)
null
168,936
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _replace_nan(a, val): """ If `a` is of inexact type, make a copy of `a`, replace NaNs with the `val` value, and return the copy together with a boolean mask marking the locations ...
Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one. The cumulative product does not change when NaNs are encountered and leading NaNs are replaced by ones. Ones are returned for slices that are all-NaN or empty. .. versionadded:: 1.12.0 Parameters ---------- a : array...
168,937
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanmean_dispatcher(a, axis=None, dtype=None, out=None, keepdims=None, *, where=None): return (a, out)
null
168,938
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanmedian_dispatcher( a, axis=None, out=None, overwrite_input=None, keepdims=None): return (a, out)
null
168,939
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def nanmean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, *, where=np._NoValue): """ Compute the arithmetic mean along the specified axis, ignoring NaNs. Returns t...
Compute the median along the specified axis, while ignoring NaNs. Returns the median of the array elements. .. versionadded:: 1.9.0 Parameters ---------- a : array_like Input array or object that can be converted to an array. axis : {int, sequence of int, None}, optional Axis or axes along which the medians are compute...
168,940
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanpercentile_dispatcher( a, q, axis=None, out=None, overwrite_input=None, method=None, keepdims=None, *, interpolation=None): return (a, q, out)
null
168,941
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanquantile_unchecked( a, q, axis=None, out=None, overwrite_input=False, method="linear", keepdims=np._NoValue, ): """Assumes that q i...
Compute the qth percentile of the data along the specified axis, while ignoring nan values. Returns the qth percentile(s) of the array elements. .. versionadded:: 1.9.0 Parameters ---------- a : array_like Input array or object that can be converted to an array, containing nan values to be ignored. q : array_like of fl...
168,942
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanquantile_dispatcher(a, q, axis=None, out=None, overwrite_input=None, method=None, keepdims=None, *, interpolation=None): return (a, q, out)
null
168,943
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanquantile_unchecked( a, q, axis=None, out=None, overwrite_input=False, method="linear", keepdims=np._NoValue, ): """Assumes that q i...
Compute the qth quantile of the data along the specified axis, while ignoring nan values. Returns the qth quantile(s) of the array elements. .. versionadded:: 1.15.0 Parameters ---------- a : array_like Input array or object that can be converted to an array, containing nan values to be ignored q : array_like of float ...
168,944
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanvar_dispatcher(a, axis=None, dtype=None, out=None, ddof=None, keepdims=None, *, where=None): return (a, out)
null
168,945
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def _nanstd_dispatcher(a, axis=None, dtype=None, out=None, ddof=None, keepdims=None, *, where=None): return (a, out)
null
168,946
import functools import warnings import numpy as np from numpy.lib import function_base from numpy.core import overrides def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue, *, where=np._NoValue): """ Compute the variance along the specified axis, while ignoring NaNs. Retu...
Compute the standard deviation along the specified axis, while ignoring NaNs. Returns the standard deviation, a measure of the spread of a distribution, of the non-NaN array elements. The standard deviation is computed for the flattened array by default, otherwise over the specified axis. For all-NaN slices or slices w...
168,952
import collections.abc import functools import re import sys import warnings import numpy as np import numpy.core.numeric as _nx from numpy.core import transpose from numpy.core.numeric import ( ones, zeros_like, arange, concatenate, array, asarray, asanyarray, empty, ndarray, take, dot, where, intp, integer, i...
null
169,026
import numpy as np from numpy.core.overrides import array_function_dispatch from numpy.lib.index_tricks import ndindex def _pad_dispatcher(array, pad_width, mode=None, **kwargs): return (array,)
null
169,027
import numpy as np from numpy.core.overrides import array_function_dispatch from numpy.lib.index_tricks import ndindex def _view_roi(array, original_area_slice, axis): """ Get a view of the current region of interest during iterative padding. When padding multiple dimensions iteratively corner values are ...
Pad an array. Parameters ---------- array : array_like of rank N The array to pad. pad_width : {sequence, array_like, int} Number of values padded to the edges of each axis. ``((before_1, after_1), ... (before_N, after_N))`` unique pad widths for each axis. ``(before, after)`` or ``((before, after),)`` yields same befo...
169,028
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _asfarray_dispatcher(a, dtype=None): return (a,)
null
169,029
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf The provided code snippet includes necessary dependencies for impleme...
Return an array converted to a float type. Parameters ---------- a : array_like The input array. dtype : str or dtype object, optional Float type code to coerce input array `a`. If `dtype` is one of the 'int' dtypes, it is replaced with float64. Returns ------- out : ndarray The input `a` as a float ndarray. Examples -...
169,030
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _real_dispatcher(val): return (val,)
null
169,031
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _imag_dispatcher(val): return (val,)
null
169,032
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _is_type_dispatcher(x): return (x,)
null
169,033
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def iscomplexobj(x): """ Check for a complex type or an array ...
Return True if x is a not complex type or an array of complex numbers. The type of the input is checked, not the value. So even if the input has an imaginary part equal to zero, `isrealobj` evaluates to False if the data type is complex. Parameters ---------- x : any The input can be of any type and shape. Returns ----...
169,034
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _nan_to_num_dispatcher(x, copy=None, nan=None, posinf=None, negin...
null
169,035
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def real(val): """ Return the real part of the complex argumen...
Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the `nan`, `posinf` and/or `neginf` keywords. If `x` is inexact, NaN is replaced by zero or by the user defined value in `nan` keyword, infinity is replaced by the largest finite floating point...
169,036
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _real_if_close_dispatcher(a, tol=None): return (a,)
null
169,037
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def real(val): """ Return the real part of the complex argumen...
If input is complex with all imaginary parts close to zero, return real parts. "Close to zero" is defined as `tol` * (machine epsilon of the type for `a`). Parameters ---------- a : array_like Input array. tol : float Tolerance in machine epsilons for the complex part of the elements in the array. Returns ------- out :...
169,038
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf _namefromtype = {'S1': 'character', '?': 'bool', ...
Return a description for the given data type code. Parameters ---------- char : str Data type code. Returns ------- out : str Description of the input data type code. See Also -------- dtype, typecodes Examples -------- >>> typechars = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q', ... 'S', 'U', 'V', 'b', 'd'...
169,039
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def _common_type_dispatcher(*arrays): return arrays
null
169,040
import functools import warnings import numpy.core.numeric as _nx from numpy.core.numeric import asarray, asanyarray, isnan, zeros from numpy.core.overrides import set_module from numpy.core import overrides from .ufunclike import isneginf, isposinf def iscomplexobj(x): """ Check for a complex type or an array ...
Return a scalar type which is common to the input arrays. The return type will always be an inexact (i.e. floating point) scalar type, even if all the arrays are integer arrays. If one of the inputs is an integer array, the minimum precision type that is returned is a 64-bit floating point dtype. All input arrays excep...
169,057
import numpy.core.numeric as nx from numpy.core.overrides import ( array_function_dispatch, ARRAY_FUNCTION_ENABLED, ) import warnings import functools def _deprecate_out_named_y(f): """ Allow the out argument to be passed as the name `y` (deprecated) In future, this decorator should be removed. """ ...
Use the appropriate decorator, depending upon if dispatching is being used.
169,058
import numpy.core.numeric as nx from numpy.core.overrides import ( array_function_dispatch, ARRAY_FUNCTION_ENABLED, ) import warnings import functools def _dispatcher(x, out=None): return (x, out)
null
169,059
import numpy.core.numeric as nx from numpy.core.overrides import ( array_function_dispatch, ARRAY_FUNCTION_ENABLED, ) import warnings import functools The provided code snippet includes necessary dependencies for implementing the `fix` function. Write a Python function `def fix(x, out=None)` to solve the following...
Round to nearest integer towards zero. Round an array of floats element-wise to nearest integer towards zero. The rounded values are returned as floats. Parameters ---------- x : array_like An array of floats to be rounded out : ndarray, optional A location into which the result is stored. If provided, it must have a s...
169,099
import numpy as np from numpy.core.numeric import normalize_axis_tuple from numpy.core.overrides import array_function_dispatch, set_module def _sliding_window_view_dispatcher(x, window_shape, axis=None, *, subok=None, writeable=None): return (x,)
null
169,100
import numpy as np from numpy.core.numeric import normalize_axis_tuple from numpy.core.overrides import array_function_dispatch, set_module def as_strided(x, shape=None, strides=None, subok=False, writeable=True): """ Create a view into the array with the given shape and strides. .. warning:: This function ...
Create a sliding window view into the array with the given window shape. Also known as rolling or moving window, the window slides across all dimensions of the array and extracts subsets of the array at all window positions. .. versionadded:: 1.20.0 Parameters ---------- x : array_like Array to create the sliding windo...
169,101
import numpy as np from numpy.core.numeric import normalize_axis_tuple from numpy.core.overrides import array_function_dispatch, set_module def _broadcast_to_dispatcher(array, shape, subok=None): return (array,)
null