id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
169,507 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | vdot(a, b, /) Return the dot product of two vectors. The vdot(`a`, `b`) function handles complex numbers differently than dot(`a`, `b`). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. Note that `vdot` handles multidimensional arrays different... |
169,508 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | bincount(x, /, weights=None, minlength=0) Count number of occurrences of each value in array of non-negative ints. The number of bins (of size 1) is one larger than the largest value in `x`. If `minlength` is specified, there will be at least this number of bins in the output array (though it will be longer if necessar... |
169,509 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | ravel_multi_index(multi_index, dims, mode='raise', order='C') Converts a tuple of index arrays into an array of flat indices, applying boundary modes to the multi-index. Parameters ---------- multi_index : tuple of array_like A tuple of integer arrays, one array for each dimension. dims : tuple of ints The shape of arr... |
169,510 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | unravel_index(indices, shape, order='C') Converts a flat index or array of flat indices into a tuple of coordinate arrays. Parameters ---------- indices : array_like An integer array whose elements are indices into the flattened version of an array of dimensions ``shape``. Before version 1.6.0, this function accepted j... |
169,511 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | putmask(a, mask, values) Changes elements of an array based on conditional and input values. Sets ``a.flat[n] = values[n]`` for each n where ``mask.flat[n]==True``. If `values` is not the same size as `a` and `mask` then it will repeat. This gives behavior different from ``a[mask] = values``. Parameters ---------- a : ... |
169,512 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | packbits(a, /, axis=None, bitorder='big') Packs the elements of a binary-valued array into bits in a uint8 array. The result is padded to full bytes by inserting zero bits at the end. Parameters ---------- a : array_like An array of integers or booleans whose elements should be packed to bits. axis : int, optional The ... |
169,513 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | unpackbits(a, /, axis=None, count=None, bitorder='big') Unpacks elements of a uint8 array into a binary-valued output array. Each element of `a` represents a bit-field that should be unpacked into a binary-valued output array. The shape of the output array is either 1-D (if `axis` is ``None``) or the same shape as the ... |
169,514 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | shares_memory(a, b, /, max_work=None) Determine if two arrays share memory. .. warning:: This function can be exponentially slow for some inputs, unless `max_work` is set to a finite number or ``MAY_SHARE_BOUNDS``. If in doubt, use `numpy.may_share_memory` instead. Parameters ---------- a, b : ndarray Input arrays max_... |
169,515 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | may_share_memory(a, b, /, max_work=None) Determine if two arrays might share memory A return of True does not necessarily mean that the two arrays share any element. It just means that they *might*. Only the memory bounds of a and b are checked by default. Parameters ---------- a, b : ndarray Input arrays max_work : in... |
169,516 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None) Calculates which of the given dates are valid days, and which are not. .. versionadded:: 1.7.0 Parameters ---------- dates : array_like of datetime64[D] The array of dates to process. weekmask : str or array_like of bool, optional A seven-ele... |
169,517 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None) First adjusts the date to fall on a valid day according to the ``roll`` rule, then applies offsets to the given dates counted in valid days. .. versionadded:: 1.7.0 Parameters ---------- dates : array_like of dateti... |
169,518 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None) Counts the number of valid days between `begindates` and `enddates`, not including the day of `enddates`. If ``enddates`` specifies a date value that is earlier than the corresponding ``begindates`` date value, the count will ... |
169,519 | import functools
from . import overrides
from . import _multiarray_umath
from ._multiarray_umath import *
from ._multiarray_umath import (
fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise... | datetime_as_string(arr, unit=None, timezone='naive', casting='same_kind') Convert an array of datetimes into an array of strings. Parameters ---------- arr : array_like of datetime64 The array of UTC timestamps to format. unit : str One of None, 'auto', or a :ref:`datetime unit <arrays.dtypes.dateunits>`. timezone : {'... |
169,520 | import functools
import warnings
import operator
import types
from . import numeric as _nx
from .numeric import result_type, NaN, asanyarray, ndim
from numpy.core.multiarray import add_docstring
from numpy.core import overrides
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
... | null |
169,521 | import functools
import warnings
import operator
import types
from . import numeric as _nx
from .numeric import result_type, NaN, asanyarray, ndim
from numpy.core.multiarray import add_docstring
from numpy.core import overrides
def _logspace_dispatcher(start, stop, num=None, endpoint=None, base=None,
... | null |
169,522 | import functools
import warnings
import operator
import types
from . import numeric as _nx
from .numeric import result_type, NaN, asanyarray, ndim
from numpy.core.multiarray import add_docstring
from numpy.core import overrides
def _geomspace_dispatcher(start, stop, num=None, endpoint=None, dtype=None,
... | null |
169,523 | import functools
import warnings
import operator
import types
from . import numeric as _nx
from .numeric import result_type, NaN, asanyarray, ndim
from numpy.core.multiarray import add_docstring
from numpy.core import overrides
def logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None,
axis=0)... | Return numbers spaced evenly on a log scale (a geometric progression). This is similar to `logspace`, but with endpoints specified directly. Each output sample is a constant multiple of the previous. .. versionchanged:: 1.16.0 Non-scalar `start` and `stop` are now supported. Parameters ---------- start : array_like The... |
169,524 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _atleast_1d_dispatcher(*arys):
return arys | null |
169,525 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _atleast_2d_dispatcher(*arys):
return arys | null |
169,526 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _atleast_3d_dispatcher(*arys):
return arys | null |
169,527 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
if not hasattr(arrays, '__getitem__') a... | null |
169,528 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def atleast_2d(*arys):
"""
View inputs as arrays with at least two dimensions.
Paramete... | Stack arrays in sequence vertically (row wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by `vsplit`. This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (fir... |
169,529 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def atleast_1d(*arys):
"""
Convert inputs to arrays with at least one dimension.
Scalar... | Stack arrays in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by `hsplit`. This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a he... |
169,530 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
if not hasattr(arrays, '__getitem__') a... | null |
169,531 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
if not hasattr(arrays, '__getitem__') a... | Join a sequence of arrays along a new axis. The ``axis`` parameter specifies the index of the new axis in the dimensions of the result. For example, if ``axis=0`` it will be the first dimension and if ``axis=-1`` it will be the last dimension. .. versionadded:: 1.10.0 Parameters ---------- arrays : sequence of array_li... |
169,532 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _block_dispatcher(arrays):
# Use type(...) is list to match the behavior of np.block(), wh... | null |
169,533 | import functools
import itertools
import operator
import warnings
from . import numeric as _nx
from . import overrides
from .multiarray import array, asanyarray, normalize_axis_index
from . import fromnumeric as _from_nx
def _block_setup(arrays):
"""
Returns
(`arrays`, list_ndim, result_ndim, final_size)
... | Assemble an nd-array from nested lists of blocks. Blocks in the innermost lists are concatenated (see `concatenate`) along the last dimension (-1), then these are concatenated along the second-last dimension (-2), and so on until the outermost list is reached. Blocks can be of any dimension, but will not be broadcasted... |
169,546 | import warnings
from ._machar import MachAr
from .overrides import set_module
from . import numeric
from . import numerictypes as ntypes
from .numeric import array, inf, NaN
from .umath import log10, exp2, nextafter, isnan
The provided code snippet includes necessary dependencies for implementing the `_fr1` function. ... | fix rank > 0 --> rank-0 |
169,547 | import warnings
from ._machar import MachAr
from .overrides import set_module
from . import numeric
from . import numerictypes as ntypes
from .numeric import array, inf, NaN
from .umath import log10, exp2, nextafter, isnan
class MachArLike:
def __init__(self, ftype, *, eps, epsneg, huge, tiny,
... | null |
169,548 | import warnings
from ._machar import MachAr
from .overrides import set_module
from . import numeric
from . import numerictypes as ntypes
from .numeric import array, inf, NaN
from .umath import log10, exp2, nextafter, isnan
_MACHAR_PARAMS = {
ntypes.double: dict(
itype = ntypes.int64,
fmt = '%24.16e'... | Get MachAr instance or MachAr-like instance Get parameters for floating point type, by first trying signatures of various known floating point types, then, if none match, attempting to identify parameters by analysis. Parameters ---------- ftype : class Numpy floating point type class (e.g. ``np.float64``) Returns ----... |
169,549 | import numpy as np
def _struct_str(dtype, include_align):
# The list str representation can't include the 'align=' flag,
# so if it is requested and the struct has the aligned flag set,
# we must use the dict str instead.
if not (include_align and dtype.isalignedstruct) and _is_packed(dtype):
su... | null |
169,550 | import numpy as np
def _construction_repr(dtype, include_align=False, short=False):
"""
Creates a string repr of the dtype, excluding the 'dtype()' part
surrounding the object. This object may be a string, a list, or
a dict depending on the nature of the dtype. This
is the object passed as the first... | null |
169,551 | import numpy as np
def _kind_name(dtype):
try:
return _kind_to_stem[dtype.kind]
except KeyError as e:
raise RuntimeError(
"internal dtype error, unknown kind {!r}"
.format(dtype.kind)
) from None
def _datetime_metadata_str(dtype):
# TODO: this duplicates the C... | null |
169,552 | import warnings
from collections import Counter
from contextlib import nullcontext
from . import numeric as sb
from . import numerictypes as nt
from numpy.compat import os_fspath
from numpy.core.overrides import set_module
from .arrayprint import _get_legacy_print_mode
class Counter(Dict[_T, int], Generic[_T]):
de... | Find duplication in a list, return a list of duplicated elements |
169,557 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
def _makenames_list(adict, align):
allfields = []
for fname, obj in adict.items():
n = len(obj)
if not isinstance(obj, tuple) or n not in (2, 3):
raise ValueError("entry not a... | null |
169,558 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
def _array_descr(descriptor):
fields = descriptor.fields
if fields is None:
subdtype = descriptor.subdtype
if subdtype is None:
if descriptor.metadata is None:
... | null |
169,559 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
def _reconstruct(subtype, shape, dtype):
return ndarray.__new__(subtype, shape, dtype) | null |
169,560 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
format_re = re.compile(r'(?P<order1>[<>|=]?)'
r'(?P<repeats> *[(]?[ ,0-9]*[)]? *)'
r'(?P<order2>[<>|=]?)'
r'(?P<dtype>[A-Za-z0-9.?]*(?:\[[a-zA... | null |
169,561 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
try:
import ctypes
except ImportError:
ctypes = None
class dummy_ctype:
def __init__(self, cls):
self._cls = cls
def __mul__(self, other):
return self
def __call__(self, *othe... | null |
169,562 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
The provided code snippet includes necessary dependencies for implementing the `_newnames` function. Write a Python function `def _newnames(datatype, order)` to solve the following problem:
Given a datatype and... | Given a datatype and an order object, return a new names tuple, with the order indicated |
169,563 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
array.__module__ = 'numpy'
The provided code snippet includes necessary dependencies for implementing the `_copy_fields` function. Write a Python function `def _copy_fields(ary)` to solve the following problem... | Return copy of structured array with padding between fields removed. Parameters ---------- ary : ndarray Structured array from which to remove padding bytes Returns ------- ary_copy : ndarray Copy of ary with padding bytes removed |
169,564 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
promote_types.__module__ = 'numpy'
The provided code snippet includes necessary dependencies for implementing the `_promote_fields` function. Write a Python function `def _promote_fields(dt1, dt2)` to solve th... | Perform type promotion for two structured dtypes. Parameters ---------- dt1 : structured dtype First dtype. dt2 : structured dtype Second dtype. Returns ------- out : dtype The promoted dtype Notes ----- If one of the inputs is aligned, the result will be. The titles of both descriptors must match (point to the same fi... |
169,565 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
The provided code snippet includes necessary dependencies for implementing the `_getfield_is_safe` function. Write a Python function `def _getfield_is_safe(oldtype, newtype, offset)` to solve the following prob... | Checks safety of getfield for object arrays. As in _view_is_safe, we need to check that memory containing objects is not reinterpreted as a non-object datatype and vice versa. Parameters ---------- oldtype : data-type Data type of the original ndarray. newtype : data-type Data type of the field being accessed by ndarra... |
169,566 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
The provided code snippet includes necessary dependencies for implementing the `_view_is_safe` function. Write a Python function `def _view_is_safe(oldtype, newtype)` to solve the following problem:
Checks safe... | Checks safety of a view involving object arrays, for example when doing:: np.zeros(10, dtype=oldtype).view(newtype) Parameters ---------- oldtype : data-type Data type of original ndarray newtype : data-type Data type of the view Raises ------ TypeError If the new type is incompatible with the old type. |
169,567 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
class _Stream:
def __init__(self, s):
self.s = s
self.byteorder = '@'
def advance(self, n):
res = self.s[:n]
self.s = self.s[n:]
return res
def consume(self, c... | null |
169,568 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
The provided code snippet includes necessary dependencies for implementing the `array_ufunc_errmsg_formatter` function. Write a Python function `def array_ufunc_errmsg_formatter(dummy, ufunc, method, *inputs, *... | Format the error message for when __array_ufunc__ gives up. |
169,569 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
The provided code snippet includes necessary dependencies for implementing the `array_function_errmsg_formatter` function. Write a Python function `def array_function_errmsg_formatter(public_api, types)` to sol... | Format the error message for when __array_ufunc__ gives up. |
169,570 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
The provided code snippet includes necessary dependencies for implementing the `_ufunc_doc_signature_formatter` function. Write a Python function `def _ufunc_doc_signature_formatter(ufunc)` to solve the followi... | Builds a signature string which resembles PEP 457 This is used to construct the first line of the docstring |
169,571 | import ast
import re
import sys
import warnings
from .multiarray import dtype, array, ndarray, promote_types
IS_PYPY = sys.implementation.name == 'pypy'
def npy_ctypes_check(cls):
# determine if a class comes from ctypes, in order to work around
# a bug in the buffer protocol for those objects, bpo-10746
t... | null |
169,572 | import collections
import functools
import os
from numpy.core._multiarray_umath import (
add_docstring, implement_array_function, _get_implementing_args)
from numpy.compat._inspect import getargspec
array_function_like_doc = (
"""like : array_like, optional
Reference object to allow the creation of arra... | null |
169,573 | import collections
import functools
import os
from numpy.core._multiarray_umath import (
add_docstring, implement_array_function, _get_implementing_args)
from numpy.compat._inspect import getargspec
The provided code snippet includes necessary dependencies for implementing the `set_module` function. Write a Python... | Decorator for overriding __module__ on a function or class. Example usage:: @set_module('numpy') def example(): pass assert example.__module__ == 'numpy' |
169,574 | import collections
import functools
import os
from numpy.core._multiarray_umath import (
add_docstring, implement_array_function, _get_implementing_args)
from numpy.compat._inspect import getargspec
def array_function_dispatch(dispatcher, module=None, verify=True,
docs_from_dispatcher=Fa... | Like array_function_dispatcher, but with function arguments flipped. |
169,575 | from numpy.core.overrides import set_module
def _unpack_tuple(tup):
if len(tup) == 1:
return tup[0]
else:
return tup | null |
169,576 | from numpy.core.overrides import set_module
The provided code snippet includes necessary dependencies for implementing the `_display_as_base` function. Write a Python function `def _display_as_base(cls)` to solve the following problem:
A decorator that makes an exception class look like its base. We use this to hide s... | A decorator that makes an exception class look like its base. We use this to hide subclasses that are implementation details - the user should catch the base type, which is what the traceback will show them. Classes decorated with this decorator are subject to removal without a deprecation warning. |
169,594 | import collections.abc
import contextlib
import contextvars
from .overrides import set_module
from .umath import (
UFUNC_BUFSIZE_DEFAULT,
ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)
from . import umath
_err... | Set how floating-point errors are handled. Note that operations on integer scalar types (such as `int16`) are handled like floating point, and are affected by these settings. Parameters ---------- all : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional Set treatment for all types of floating-point errors at... |
169,595 | import collections.abc
import contextlib
import contextvars
from .overrides import set_module
from .umath import (
UFUNC_BUFSIZE_DEFAULT,
ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)
from . import umath
def ... | Set the size of the buffer used in ufuncs. Parameters ---------- size : int Size of buffer. |
169,596 | import collections.abc
import contextlib
import contextvars
from .overrides import set_module
from .umath import (
UFUNC_BUFSIZE_DEFAULT,
ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)
from . import umath
def ... | Set the floating-point error callback function or log object. There are two ways to capture floating-point error messages. The first is to set the error-handler to 'call', using `seterr`. Then, set the function to call using this function. The second is to set the error-handler to 'log', using `seterr`. Floating-point ... |
169,597 | import collections.abc
import contextlib
import contextvars
from .overrides import set_module
from .umath import (
UFUNC_BUFSIZE_DEFAULT,
ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)
from . import umath
def... | null |
169,598 | from numpy.core.function_base import add_newdoc
from numpy.core.overrides import array_function_like_doc
def refer_to_array_attribute(attr, method=True):
docstring = """
Scalar {} identical to the corresponding array attribute.
Please see `ndarray.{}`.
"""
return attr, docstring.format("method" i... | null |
169,615 | from numpy.compat import unicode
from numpy.core._string_helpers import english_lower
from numpy.core.multiarray import typeinfo, dtype
from numpy.core._dtype import _kind_name
sctypeDict = {}
allTypes = {}
_abstract_types = {}
_concrete_typeinfo = {}
for name in _toadd:
if isinstance(name, tuple):
... | null |
169,616 | from numpy.compat import unicode
from numpy.core._string_helpers import english_lower
from numpy.core.multiarray import typeinfo, dtype
from numpy.core._dtype import _kind_name
sctypeDict = {}
allTypes = {}
_concrete_typeinfo = {}
def bitname(obj):
"""Return a bit-width name for a given type object"... | null |
169,617 | from numpy.compat import unicode
from numpy.core._string_helpers import english_lower
from numpy.core.multiarray import typeinfo, dtype
from numpy.core._dtype import _kind_name
sctypeDict = {}
allTypes = {}
_concrete_typeinfo = {}
_int_ctypes = ['long', 'longlong', 'int', 'short', 'byte']
_uint_ctypes =... | null |
169,618 | from numpy.compat import unicode
from numpy.core._string_helpers import english_lower
from numpy.core.multiarray import typeinfo, dtype
from numpy.core._dtype import _kind_name
sctypeDict = {}
allTypes = {}
def _set_up_aliases():
type_pairs = [('complex_', 'cdouble'),
('single', 'float'),
... | null |
169,619 | from numpy.compat import unicode
from numpy.core._string_helpers import english_lower
from numpy.core.multiarray import typeinfo, dtype
from numpy.core._dtype import _kind_name
sctypes = {'int': [],
'uint':[],
'float':[],
'complex':[],
'others':[bool, object, bytes, unicode, ... | null |
169,621 | import warnings
from ._machar import MachAr
from .overrides import set_module
from . import numeric
from . import numerictypes as ntypes
from .numeric import array, inf, NaN
from .umath import log10, exp2, nextafter, isnan
class MachArLike:
""" Object to simulate MachAr instance """
def __init__(self, ftype, *,... | null |
169,632 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
class MismatchCAPIError(ValueError):
pass
def get_api_versions(apiversion, codegen_dir):
"""
Return current C API checksum and the recorded checksum.
Return current C API checksum and the recorded checksu... | Emits a MismatchCAPIWarning if the C API version needs updating. |
169,633 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
FUNC_CALL_ARGS = {}
def set_sig(sig):
prefix, _, args = sig.partition("(")
args = args.rpartition(")")[0]
funcname = prefix.rpartition(" ")[-1]
args = [arg.strip() for arg in args.split(",")]
# We us... | null |
169,634 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
def fname2def(name):
return "HAVE_%s" % name.upper() | null |
169,635 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
def sym2def(symbol):
define = symbol.replace(' ', '')
return define.upper() | null |
169,636 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
def type2def(symbol):
define = symbol.replace(' ', '_')
return define.upper() | null |
169,637 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
LONG_DOUBLE_REPRESENTATION_SRC = r"""
/* "before" is 16 bytes to ensure there's no padding between it and "x".
* We're not expecting any "long double" bigger than 16 bytes or with
* alignment requirements stri... | null |
169,638 | import copy
import pathlib
import sys
import textwrap
from numpy.distutils.misc_util import mingw32
The provided code snippet includes necessary dependencies for implementing the `check_for_right_shift_internal_compiler_error` function. Write a Python function `def check_for_right_shift_internal_compiler_error(cmd)` t... | On our arm CI, this fails with an internal compilation error The failure looks like the following, and can be reproduced on ARM64 GCC 5.4: <source>: In function 'right_shift': <source>:4:20: internal compiler error: in expand_shift_1, at expmed.c:2349 ip1[i] = ip1[i] >> in2; ^ Please submit a full bug report, with prep... |
169,639 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,640 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,641 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,642 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,643 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,644 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,645 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,646 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,647 | import warnings
from contextlib import nullcontext
from numpy.core import multiarray as mu
from numpy.core import umath as um
from numpy.core.multiarray import asanyarray
from numpy.core import numerictypes as nt
from numpy.core import _exceptions
from numpy.core._ufunc_config import _no_nep50_warning
from numpy._globa... | null |
169,648 | import itertools
import operator
from numpy.core.multiarray import c_einsum
from numpy.core.numeric import asanyarray, tensordot
from numpy.core.overrides import array_function_dispatch
def _einsum_path_dispatcher(*operands, optimize=None, einsum_call=None):
# NOTE: technically, we should only dispatch on array-li... | null |
169,649 | import itertools
import operator
from numpy.core.multiarray import c_einsum
from numpy.core.numeric import asanyarray, tensordot
from numpy.core.overrides import array_function_dispatch
def _einsum_dispatcher(*operands, out=None, optimize=None, **kwargs):
# Arguably we dispatch on more arguments than we really sho... | null |
169,650 | import itertools
import operator
from numpy.core.multiarray import c_einsum
from numpy.core.numeric import asanyarray, tensordot
from numpy.core.overrides import array_function_dispatch
def einsum_path(*operands, optimize='greedy', einsum_call=False):
"""
einsum_path(subscripts, *operands, optimize='greedy')
... | einsum(subscripts, *operands, out=None, dtype=None, order='K', casting='safe', optimize=False) Evaluates the Einstein summation convention on the operands. Using the Einstein summation convention, many common multi-dimensional, linear algebraic array operations can be represented in a simple fashion. In *implicit* mode... |
169,651 | import sys
import os
from numpy.core import dtype
from numpy.core import numerictypes as _numerictypes
from numpy.core.function_base import add_newdoc
def numeric_type_aliases(aliases):
def type_aliases_gen():
for alias, doc in aliases:
try:
alias_type = getattr(_numerictypes, a... | null |
169,652 | import sys
import os
from numpy.core import dtype
from numpy.core import numerictypes as _numerictypes
from numpy.core.function_base import add_newdoc
import sys
if 'setuptools' in sys.modules:
have_setuptools = True
from setuptools import setup as old_setup
# easy_install imports math, it may be picked u... | null |
169,653 | import sys
import os
from numpy.core import dtype
from numpy.core import numerictypes as _numerictypes
from numpy.core.function_base import add_newdoc
possible_aliases = numeric_type_aliases([
('int8', '8-bit signed integer (``-128`` to ``127``)'),
('int16', '16-bit signed integer (``-32_768`` to ``32_767``)'),... | null |
169,694 |
class Configuration:
_list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
'libraries', 'headers', 'scripts', 'py_modules',
'installed_libraries', 'define_macros']
_dict_keys = ['package_dir', 'installed_pkg_config']
_extra_keys = ['name', 'version']
... | null |
169,695 | import sys
import warnings
import ast
import numpy.core.numeric as N
from numpy.core.numeric import concatenate, isscalar
from numpy.core.overrides import set_module
from numpy.linalg import matrix_power
def _convert_from_string(data):
for char in '[]':
data = data.replace(char, '')
rows = data.split(... | null |
169,696 | import sys
import warnings
import ast
import numpy.core.numeric as N
from numpy.core.numeric import concatenate, isscalar
from numpy.core.overrides import set_module
from numpy.linalg import matrix_power
class matrix(N.ndarray):
"""
matrix(data, dtype=None, copy=True)
.. note:: It is no longer recommended t... | Build a matrix object from a string, nested sequence, or array. Parameters ---------- obj : str or array_like Input data. If a string, variables in the current scope may be referenced by name. ldict : dict, optional A dictionary that replaces local operands in current frame. Ignored if `obj` is not a string or `gdict` ... |
169,699 |
class Configuration:
def __init__(self,
package_name=None,
parent_name=None,
top_path=None,
package_path=None,
caller_level=1,
setup_name='setup.py',
**attrs):
d... | null |
169,700 | from __future__ import annotations
import sys
import types
from collections.abc import Generator, Iterable, Iterator
from typing import (
Any,
ClassVar,
NoReturn,
TypeVar,
TYPE_CHECKING,
)
import numpy as np
The provided code snippet includes necessary dependencies for implementing the `_to_str` fu... | Helper function for `_GenericAlias.__repr__`. |
169,701 | from __future__ import annotations
import sys
import types
from collections.abc import Generator, Iterable, Iterator
from typing import (
Any,
ClassVar,
NoReturn,
TypeVar,
TYPE_CHECKING,
)
import numpy as np
Any = object()
class TypeVar:
__name__: str
__bound__: Optional[Type[Any]]
__c... | Search for all typevars and typevar-containing objects in `args`. Helper function for `_GenericAlias.__init__`. |
169,702 | from __future__ import annotations
import sys
import types
from collections.abc import Generator, Iterable, Iterator
from typing import (
Any,
ClassVar,
NoReturn,
TypeVar,
TYPE_CHECKING,
)
import numpy as np
_T = TypeVar("_T", bound="_GenericAlias")
class _GenericAlias:
"""A python-based backpor... | Recursively replace all typevars with those from `parameters`. Helper function for `_GenericAlias.__getitem__`. |
169,703 | import re
import textwrap
from ._generic_alias import NDArray
_docstrings_list = []
The provided code snippet includes necessary dependencies for implementing the `add_newdoc` function. Write a Python function `def add_newdoc(name: str, value: str, doc: str) -> None` to solve the following problem:
Append ``_docstring... | Append ``_docstrings_list`` with a docstring for `name`. Parameters ---------- name : str The name of the object. value : str A string-representation of the object. doc : str The docstring of the object. |
169,704 | import re
import textwrap
from ._generic_alias import NDArray
_docstrings_list = []
The provided code snippet includes necessary dependencies for implementing the `_parse_docstrings` function. Write a Python function `def _parse_docstrings() -> str` to solve the following problem:
Convert all docstrings in ``_docstrin... | Convert all docstrings in ``_docstrings_list`` into a single sphinx-legible text block. |
169,705 |
class Configuration:
_list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
'libraries', 'headers', 'scripts', 'py_modules',
'installed_libraries', 'define_macros']
_dict_keys = ['package_dir', 'installed_pkg_config']
_extra_keys = ['name', 'version']
... | null |
169,706 | import types
def getargs(co):
"""Get information about the arguments accepted by a code object.
Three things are returned: (args, varargs, varkw), where 'args' is
a list of argument names (possibly containing nested lists), and
'varargs' and 'varkw' are the names of the * and ** arguments or None.
"... | Get information about arguments passed into a particular frame. A tuple of four things is returned: (args, varargs, varkw, locals). 'args' is a list of the argument names (it may contain nested lists). 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dictionary of the given ... |
169,707 | import types
def joinseq(seq):
if len(seq) == 1:
return '(' + seq[0] + ',)'
else:
return '(' + ', '.join(seq) + ')'
def strseq(object, convert, join=joinseq):
"""Recursively walk a sequence, stringifying each element.
"""
if type(object) in [list, tuple]:
return join([strseq(... | Format an argument spec from the 4 values returned by getargspec. The first four arguments are (args, varargs, varkw, defaults). The other four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the se... |
169,708 | import types
def joinseq(seq):
if len(seq) == 1:
return '(' + seq[0] + ',)'
else:
return '(' + ', '.join(seq) + ')'
def strseq(object, convert, join=joinseq):
"""Recursively walk a sequence, stringifying each element.
"""
if type(object) in [list, tuple]:
return join([strseq(... | Format an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the seq... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.