OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
hps
/
faces
/
.venv
/
lib
/
python3.10
/
site-packages
/
numpy
/
core
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/26/2024 01:26:35 PM
rwxr-xr-x
📄
__init__.py
5.62 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
__init__.pyi
126 bytes
10/26/2024 01:26:25 PM
rw-r--r--
📁
__pycache__
-
10/26/2024 01:27:31 PM
rwxr-xr-x
📄
_add_newdocs.py
204.07 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_add_newdocs_scalars.py
11.8 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_asarray.py
3.91 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_asarray.pyi
1.03 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_dtype.py
10.25 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_dtype_ctypes.py
3.59 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_exceptions.py
8.41 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_internal.py
27.53 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_internal.pyi
1.01 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_machar.py
11.35 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_methods.py
10.81 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_multiarray_tests.cpython-310-darwin.so
145.47 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
_multiarray_umath.cpython-310-darwin.so
3.53 MB
10/26/2024 01:26:24 PM
rw-r--r--
📄
_operand_flag_tests.cpython-310-darwin.so
50.35 KB
10/26/2024 01:26:24 PM
rw-r--r--
📄
_rational_tests.cpython-310-darwin.so
78.49 KB
10/26/2024 01:26:24 PM
rw-r--r--
📄
_simd.cpython-310-darwin.so
362.62 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
_string_helpers.py
2.79 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
_struct_ufunc_tests.cpython-310-darwin.so
50.66 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
_type_aliases.py
7.36 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
_type_aliases.pyi
374 bytes
10/26/2024 01:26:25 PM
rw-r--r--
📄
_ufunc_config.py
13.62 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
_ufunc_config.pyi
1.04 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
_umath_tests.cpython-310-darwin.so
56.72 KB
10/26/2024 01:26:25 PM
rw-r--r--
📄
arrayprint.py
61.25 KB
10/26/2024 01:26:21 PM
rw-r--r--
📄
arrayprint.pyi
4.32 KB
10/26/2024 01:26:21 PM
rw-r--r--
📄
cversions.py
347 bytes
10/26/2024 01:26:21 PM
rw-r--r--
📄
defchararray.py
71.31 KB
10/26/2024 01:26:21 PM
rw-r--r--
📄
defchararray.pyi
9 KB
10/26/2024 01:26:21 PM
rw-r--r--
📄
einsumfunc.py
50.65 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
einsumfunc.pyi
3.69 KB
10/26/2024 01:26:21 PM
rw-r--r--
📄
fromnumeric.py
122.29 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
fromnumeric.pyi
22.92 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
function_base.py
18.83 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
function_base.pyi
4.61 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
generate_numpy_api.py
7.23 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
getlimits.py
24.31 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
getlimits.pyi
82 bytes
10/26/2024 01:26:22 PM
rw-r--r--
📁
include
-
10/26/2024 01:28:47 PM
rwxr-xr-x
📁
lib
-
10/26/2024 01:28:48 PM
rwxr-xr-x
📄
memmap.py
11.41 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
memmap.pyi
55 bytes
10/26/2024 01:26:22 PM
rw-r--r--
📄
multiarray.py
54.67 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
multiarray.pyi
24.18 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
numeric.py
75.82 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
numeric.pyi
13.9 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
numerictypes.py
16.83 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
numerictypes.pyi
3.31 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
overrides.py
8.11 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
records.py
36.67 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
records.pyi
5.56 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
setup.py
51.13 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
setup_common.py
19.06 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
shape_base.py
29.77 KB
10/26/2024 01:26:22 PM
rw-r--r--
📄
shape_base.pyi
2.71 KB
10/26/2024 01:26:23 PM
rw-r--r--
📁
tests
-
10/26/2024 01:29:54 PM
rwxr-xr-x
📄
umath.py
1.99 KB
10/26/2024 01:26:23 PM
rw-r--r--
📄
umath_tests.py
389 bytes
10/26/2024 01:26:23 PM
rw-r--r--
Editing: _exceptions.py
Close
""" Various richly-typed exceptions, that also help us deal with string formatting in python where it's easier. By putting the formatting in `__str__`, we also avoid paying the cost for users who silence the exceptions. """ from numpy.core.overrides import set_module def _unpack_tuple(tup): if len(tup) == 1: return tup[0] else: return tup def _display_as_base(cls): """ 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. """ assert issubclass(cls, Exception) cls.__name__ = cls.__base__.__name__ return cls class UFuncTypeError(TypeError): """ Base class for all ufunc exceptions """ def __init__(self, ufunc): self.ufunc = ufunc @_display_as_base class _UFuncBinaryResolutionError(UFuncTypeError): """ Thrown when a binary resolution fails """ def __init__(self, ufunc, dtypes): super().__init__(ufunc) self.dtypes = tuple(dtypes) assert len(self.dtypes) == 2 def __str__(self): return ( "ufunc {!r} cannot use operands with types {!r} and {!r}" ).format( self.ufunc.__name__, *self.dtypes ) @_display_as_base class _UFuncNoLoopError(UFuncTypeError): """ Thrown when a ufunc loop cannot be found """ def __init__(self, ufunc, dtypes): super().__init__(ufunc) self.dtypes = tuple(dtypes) def __str__(self): return ( "ufunc {!r} did not contain a loop with signature matching types " "{!r} -> {!r}" ).format( self.ufunc.__name__, _unpack_tuple(self.dtypes[:self.ufunc.nin]), _unpack_tuple(self.dtypes[self.ufunc.nin:]) ) @_display_as_base class _UFuncCastingError(UFuncTypeError): def __init__(self, ufunc, casting, from_, to): super().__init__(ufunc) self.casting = casting self.from_ = from_ self.to = to @_display_as_base class _UFuncInputCastingError(_UFuncCastingError): """ Thrown when a ufunc input cannot be casted """ def __init__(self, ufunc, casting, from_, to, i): super().__init__(ufunc, casting, from_, to) self.in_i = i def __str__(self): # only show the number if more than one input exists i_str = "{} ".format(self.in_i) if self.ufunc.nin != 1 else "" return ( "Cannot cast ufunc {!r} input {}from {!r} to {!r} with casting " "rule {!r}" ).format( self.ufunc.__name__, i_str, self.from_, self.to, self.casting ) @_display_as_base class _UFuncOutputCastingError(_UFuncCastingError): """ Thrown when a ufunc output cannot be casted """ def __init__(self, ufunc, casting, from_, to, i): super().__init__(ufunc, casting, from_, to) self.out_i = i def __str__(self): # only show the number if more than one output exists i_str = "{} ".format(self.out_i) if self.ufunc.nout != 1 else "" return ( "Cannot cast ufunc {!r} output {}from {!r} to {!r} with casting " "rule {!r}" ).format( self.ufunc.__name__, i_str, self.from_, self.to, self.casting ) # Exception used in shares_memory() @set_module('numpy') class TooHardError(RuntimeError): """max_work was exceeded. This is raised whenever the maximum number of candidate solutions to consider specified by the ``max_work`` parameter is exceeded. Assigning a finite number to max_work may have caused the operation to fail. """ pass @set_module('numpy') class AxisError(ValueError, IndexError): """Axis supplied was invalid. This is raised whenever an ``axis`` parameter is specified that is larger than the number of array dimensions. For compatibility with code written against older numpy versions, which raised a mixture of `ValueError` and `IndexError` for this situation, this exception subclasses both to ensure that ``except ValueError`` and ``except IndexError`` statements continue to catch `AxisError`. .. versionadded:: 1.13 Parameters ---------- axis : int or str The out of bounds axis or a custom exception message. If an axis is provided, then `ndim` should be specified as well. ndim : int, optional The number of array dimensions. msg_prefix : str, optional A prefix for the exception message. Attributes ---------- axis : int, optional The out of bounds axis or ``None`` if a custom exception message was provided. This should be the axis as passed by the user, before any normalization to resolve negative indices. .. versionadded:: 1.22 ndim : int, optional The number of array dimensions or ``None`` if a custom exception message was provided. .. versionadded:: 1.22 Examples -------- >>> array_1d = np.arange(10) >>> np.cumsum(array_1d, axis=1) Traceback (most recent call last): ... numpy.AxisError: axis 1 is out of bounds for array of dimension 1 Negative axes are preserved: >>> np.cumsum(array_1d, axis=-2) Traceback (most recent call last): ... numpy.AxisError: axis -2 is out of bounds for array of dimension 1 The class constructor generally takes the axis and arrays' dimensionality as arguments: >>> print(np.AxisError(2, 1, msg_prefix='error')) error: axis 2 is out of bounds for array of dimension 1 Alternatively, a custom exception message can be passed: >>> print(np.AxisError('Custom error message')) Custom error message """ __slots__ = ("axis", "ndim", "_msg") def __init__(self, axis, ndim=None, msg_prefix=None): if ndim is msg_prefix is None: # single-argument form: directly set the error message self._msg = axis self.axis = None self.ndim = None else: self._msg = msg_prefix self.axis = axis self.ndim = ndim def __str__(self): axis = self.axis ndim = self.ndim if axis is ndim is None: return self._msg else: msg = f"axis {axis} is out of bounds for array of dimension {ndim}" if self._msg is not None: msg = f"{self._msg}: {msg}" return msg @_display_as_base class _ArrayMemoryError(MemoryError): """ Thrown when an array cannot be allocated""" def __init__(self, shape, dtype): self.shape = shape self.dtype = dtype @property def _total_size(self): num_bytes = self.dtype.itemsize for dim in self.shape: num_bytes *= dim return num_bytes @staticmethod def _size_to_string(num_bytes): """ Convert a number of bytes into a binary size string """ # https://en.wikipedia.org/wiki/Binary_prefix LOG2_STEP = 10 STEP = 1024 units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'] unit_i = max(num_bytes.bit_length() - 1, 1) // LOG2_STEP unit_val = 1 << (unit_i * LOG2_STEP) n_units = num_bytes / unit_val del unit_val # ensure we pick a unit that is correct after rounding if round(n_units) == STEP: unit_i += 1 n_units /= STEP # deal with sizes so large that we don't have units for them if unit_i >= len(units): new_unit_i = len(units) - 1 n_units *= 1 << ((unit_i - new_unit_i) * LOG2_STEP) unit_i = new_unit_i unit_name = units[unit_i] # format with a sensible number of digits if unit_i == 0: # no decimal point on bytes return '{:.0f} {}'.format(n_units, unit_name) elif round(n_units) < 1000: # 3 significant figures, if none are dropped to the left of the . return '{:#.3g} {}'.format(n_units, unit_name) else: # just give all the digits otherwise return '{:#.0f} {}'.format(n_units, unit_name) def __str__(self): size_str = self._size_to_string(self._total_size) return ( "Unable to allocate {} for an array with shape {} and data type {}" .format(size_str, self.shape, self.dtype) )