OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
numpy
/
core
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📄
__init__.py
2.97 KB
09/29/2017 05:31:46 PM
rw-r--r--
📁
__pycache__
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📄
_dummy.cpython-36m-x86_64-linux-gnu.so
6.06 KB
12/05/2017 02:32:02 PM
rw-r--r--
📄
_internal.py
20.87 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
_methods.py
4.59 KB
09/17/2017 01:29:38 PM
rw-r--r--
📄
arrayprint.py
28.53 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
cversions.py
413 bytes
09/17/2017 01:29:38 PM
rw-r--r--
📄
defchararray.py
65.81 KB
09/17/2017 01:29:38 PM
rw-r--r--
📄
einsumfunc.py
34.7 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
fromnumeric.py
96.66 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
function_base.py
11.82 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
generate_numpy_api.py
7.16 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
getlimits.py
17.99 KB
09/17/2017 01:29:38 PM
rw-r--r--
📁
include
-
10/28/2024 08:45:51 AM
rwxr-xr-x
📄
info.py
4.58 KB
09/17/2017 01:29:38 PM
rw-r--r--
📁
lib
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📄
machar.py
10.54 KB
09/17/2017 01:29:38 PM
rw-r--r--
📄
memmap.py
11.16 KB
09/17/2017 01:29:38 PM
rw-r--r--
📄
multiarray.cpython-36m-x86_64-linux-gnu.so
1.51 MB
12/05/2017 02:32:02 PM
rw-r--r--
📄
multiarray_tests.cpython-36m-x86_64-linux-gnu.so
47.48 KB
12/05/2017 02:32:02 PM
rw-r--r--
📄
numeric.py
89.49 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
numerictypes.py
28.11 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
operand_flag_tests.cpython-36m-x86_64-linux-gnu.so
10.14 KB
12/05/2017 02:32:02 PM
rw-r--r--
📄
records.py
28.73 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
setup.py
39.75 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
setup_common.py
14.99 KB
12/05/2017 02:32:02 PM
rw-r--r--
📄
shape_base.py
18.63 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
struct_ufunc_test.cpython-36m-x86_64-linux-gnu.so
10.16 KB
12/05/2017 02:32:02 PM
rw-r--r--
📄
test_rational.cpython-36m-x86_64-linux-gnu.so
43.27 KB
12/05/2017 02:32:02 PM
rw-r--r--
📁
tests
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📄
umath.cpython-36m-x86_64-linux-gnu.so
1.35 MB
12/05/2017 02:32:02 PM
rw-r--r--
📄
umath_tests.cpython-36m-x86_64-linux-gnu.so
18.41 KB
12/05/2017 02:32:02 PM
rw-r--r--
Editing: _methods.py
Close
""" Array methods which are called by both the C-code for the method and the Python code for the NumPy-namespace function """ from __future__ import division, absolute_import, print_function import warnings from numpy.core import multiarray as mu from numpy.core import umath as um from numpy.core.numeric import asanyarray from numpy.core import numerictypes as nt # save those O(100) nanoseconds! umr_maximum = um.maximum.reduce umr_minimum = um.minimum.reduce umr_sum = um.add.reduce umr_prod = um.multiply.reduce umr_any = um.logical_or.reduce umr_all = um.logical_and.reduce # avoid keyword arguments to speed up parsing, saves about 15%-20% for very # small reductions def _amax(a, axis=None, out=None, keepdims=False): return umr_maximum(a, axis, None, out, keepdims) def _amin(a, axis=None, out=None, keepdims=False): return umr_minimum(a, axis, None, out, keepdims) def _sum(a, axis=None, dtype=None, out=None, keepdims=False): return umr_sum(a, axis, dtype, out, keepdims) def _prod(a, axis=None, dtype=None, out=None, keepdims=False): return umr_prod(a, axis, dtype, out, keepdims) def _any(a, axis=None, dtype=None, out=None, keepdims=False): return umr_any(a, axis, dtype, out, keepdims) def _all(a, axis=None, dtype=None, out=None, keepdims=False): return umr_all(a, axis, dtype, out, keepdims) def _count_reduce_items(arr, axis): if axis is None: axis = tuple(range(arr.ndim)) if not isinstance(axis, tuple): axis = (axis,) items = 1 for ax in axis: items *= arr.shape[ax] return items def _mean(a, axis=None, dtype=None, out=None, keepdims=False): arr = asanyarray(a) is_float16_result = False rcount = _count_reduce_items(arr, axis) # Make this warning show up first if rcount == 0: warnings.warn("Mean of empty slice.", RuntimeWarning, stacklevel=2) # Cast bool, unsigned int, and int to float64 by default if dtype is None: if issubclass(arr.dtype.type, (nt.integer, nt.bool_)): dtype = mu.dtype('f8') elif issubclass(arr.dtype.type, nt.float16): dtype = mu.dtype('f4') is_float16_result = True ret = umr_sum(arr, axis, dtype, out, keepdims) if isinstance(ret, mu.ndarray): ret = um.true_divide( ret, rcount, out=ret, casting='unsafe', subok=False) if is_float16_result and out is None: ret = arr.dtype.type(ret) elif hasattr(ret, 'dtype'): if is_float16_result: ret = arr.dtype.type(ret / rcount) else: ret = ret.dtype.type(ret / rcount) else: ret = ret / rcount return ret def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): arr = asanyarray(a) rcount = _count_reduce_items(arr, axis) # Make this warning show up on top. if ddof >= rcount: warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning, stacklevel=2) # Cast bool, unsigned int, and int to float64 by default if dtype is None and issubclass(arr.dtype.type, (nt.integer, nt.bool_)): dtype = mu.dtype('f8') # Compute the mean. # Note that if dtype is not of inexact type then arraymean will # not be either. arrmean = umr_sum(arr, axis, dtype, keepdims=True) if isinstance(arrmean, mu.ndarray): arrmean = um.true_divide( arrmean, rcount, out=arrmean, casting='unsafe', subok=False) else: arrmean = arrmean.dtype.type(arrmean / rcount) # Compute sum of squared deviations from mean # Note that x may not be inexact and that we need it to be an array, # not a scalar. x = asanyarray(arr - arrmean) if issubclass(arr.dtype.type, nt.complexfloating): x = um.multiply(x, um.conjugate(x), out=x).real else: x = um.multiply(x, x, out=x) ret = umr_sum(x, axis, dtype, out, keepdims) # Compute degrees of freedom and make sure it is not negative. rcount = max([rcount - ddof, 0]) # divide by degrees of freedom if isinstance(ret, mu.ndarray): ret = um.true_divide( ret, rcount, out=ret, casting='unsafe', subok=False) elif hasattr(ret, 'dtype'): ret = ret.dtype.type(ret / rcount) else: ret = ret / rcount return ret def _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof, keepdims=keepdims) if isinstance(ret, mu.ndarray): ret = um.sqrt(ret, out=ret) elif hasattr(ret, 'dtype'): ret = ret.dtype.type(um.sqrt(ret)) else: ret = um.sqrt(ret) return ret