diff options
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | numpy/__init__.pyi | 169 | ||||
-rw-r--r-- | numpy/core/src/common/npy_config.h | 2 | ||||
-rw-r--r-- | numpy/core/src/umath/simd.inc.src | 17 | ||||
-rw-r--r-- | numpy/core/tests/test_cpu_features.py | 54 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_umath_complex.py | 31 | ||||
-rw-r--r-- | numpy/tests/test_public_api.py | 6 | ||||
-rw-r--r-- | numpy/tests/typing/fail/fromnumeric.py | 35 | ||||
-rw-r--r-- | numpy/tests/typing/pass/fromnumeric.py | 69 | ||||
-rw-r--r-- | numpy/tests/typing/reveal/fromnumeric.py | 70 |
11 files changed, 439 insertions, 20 deletions
diff --git a/.travis.yml b/.travis.yml index 85f6127cd..b3d8adfa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ group: travis_latest os: linux dist: bionic -# Travis whitelists the installable packages, additions can be requested -# https://github.com/travis-ci/apt-package-whitelist +# Travis allows these packages, additions can be requested +# https://github.com/travis-ci/apt-package-safelist addons: apt: packages: &common_packages diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 8de9cce02..847b451f7 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -886,6 +886,9 @@ _ScalarGenericDT = TypeVar( "_ScalarGenericDT", bound=Union[dt.datetime, dt.timedelta, generic] ) +_Number = TypeVar('_Number', bound=number) +_NumberLike = Union[int, float, complex, number, bool_] + # An array-like object consisting of integers _Int = Union[int, integer] _Bool = Union[bool, bool_] @@ -901,6 +904,11 @@ _ArrayLikeIntOrBool = Union[ Sequence[_ArrayLikeIntNested], Sequence[_ArrayLikeBoolNested], ] +_ArrayLikeBool = Union[ + _Bool, + Sequence[_Bool], + ndarray +] # The signature of take() follows a common theme with its overloads: # 1. A generic comes in; the same generic comes out @@ -1062,3 +1070,164 @@ def compress( axis: Optional[int] = ..., out: Optional[ndarray] = ..., ) -> ndarray: ... +@overload +def clip( + a: _Number, + a_min: ArrayLike, + a_max: Optional[ArrayLike], + out: Optional[ndarray] = ..., + **kwargs: Any, +) -> _Number: ... +@overload +def clip( + a: _Number, + a_min: None, + a_max: ArrayLike, + out: Optional[ndarray] = ..., + **kwargs: Any, +) -> _Number: ... +@overload +def clip( + a: ArrayLike, + a_min: ArrayLike, + a_max: Optional[ArrayLike], + out: Optional[ndarray] = ..., + **kwargs: Any, +) -> Union[number, ndarray]: ... +@overload +def clip( + a: ArrayLike, + a_min: None, + a_max: ArrayLike, + out: Optional[ndarray] = ..., + **kwargs: Any, +) -> Union[number, ndarray]: ... +@overload +def sum( + a: _Number, + axis: Optional[_ShapeLike] = ..., + dtype: DtypeLike = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> _Number: ... +@overload +def sum( + a: ArrayLike, + axis: _ShapeLike = ..., + dtype: DtypeLike = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> Union[number, ndarray]: ... +@overload +def all( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., + keepdims: Literal[False] = ..., +) -> bool_: ... +@overload +def all( + a: ArrayLike, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., +) -> Union[bool_, ndarray]: ... +@overload +def any( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., + keepdims: Literal[False] = ..., +) -> bool_: ... +@overload +def any( + a: ArrayLike, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., +) -> Union[bool_, ndarray]: ... +def cumsum( + a: ArrayLike, + axis: Optional[int] = ..., + dtype: DtypeLike = ..., + out: Optional[ndarray] = ..., +) -> ndarray: ... +@overload +def ptp( + a: _Number, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., +) -> _Number: ... +@overload +def ptp( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., + keepdims: Literal[False] = ..., +) -> number: ... +@overload +def ptp( + a: ArrayLike, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., +) -> Union[number, ndarray]: ... +@overload +def amax( + a: _Number, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> _Number: ... +@overload +def amax( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., + keepdims: Literal[False] = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> number: ... +@overload +def amax( + a: ArrayLike, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> Union[number, ndarray]: ... +@overload +def amin( + a: _Number, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> _Number: ... +@overload +def amin( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., + keepdims: Literal[False] = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> number: ... +@overload +def amin( + a: ArrayLike, + axis: Optional[_ShapeLike] = ..., + out: Optional[ndarray] = ..., + keepdims: bool = ..., + initial: _NumberLike = ..., + where: _ArrayLikeBool = ..., +) -> Union[number, ndarray]: ... diff --git a/numpy/core/src/common/npy_config.h b/numpy/core/src/common/npy_config.h index 4493409bb..27328aa73 100644 --- a/numpy/core/src/common/npy_config.h +++ b/numpy/core/src/common/npy_config.h @@ -8,7 +8,7 @@ #include "numpy/npy_cpu.h" #include "numpy/npy_os.h" -/* blacklist */ +/* blocklist */ /* Disable broken Sun Workshop Pro math functions */ #ifdef __SUNPRO_C diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src index e6414e29e..8f01d33fa 100644 --- a/numpy/core/src/umath/simd.inc.src +++ b/numpy/core/src/umath/simd.inc.src @@ -132,8 +132,9 @@ nomemoverlap(char *ip, * 2) Input step should be smaller than MAX_STEP_SIZE for performance * 3) Input and output arrays should have no overlap in memory */ -#define IS_OUTPUT_BLOCKABLE_UNARY(esize, vsize) \ - (steps[1] == (esize) && abs(steps[0]) < MAX_STEP_SIZE && \ +#define IS_OUTPUT_BLOCKABLE_UNARY(esizein, esizeout, vsize) \ + ((steps[0] & (esizein-1)) == 0 && \ + steps[1] == (esizeout) && abs(steps[0]) < MAX_STEP_SIZE && \ (nomemoverlap(args[1], steps[1] * dimensions[0], args[0], steps[0] * dimensions[0]))) #define IS_BLOCKABLE_REDUCE(esize, vsize) \ @@ -251,7 +252,7 @@ static NPY_INLINE int run_unary_avx512f_@func@_@TYPE@(char **args, const npy_intp *dimensions, const npy_intp *steps) { #if defined HAVE_ATTRIBUTE_TARGET_AVX512F_WITH_INTRINSICS && defined NPY_HAVE_SSE2_INTRINSICS - if ((IS_OUTPUT_BLOCKABLE_UNARY((npy_uint)(@esize@/@outsize@), 64)) && (labs(steps[0]) < 2*@max_stride@*@esize@)) { + if ((IS_OUTPUT_BLOCKABLE_UNARY(@esize@, (npy_uint)(@esize@/@outsize@), 64)) && (labs(steps[0]) < 2*@max_stride@*@esize@)) { AVX512F_@func@_@TYPE@((@type@*)args[1], (@type@*)args[0], dimensions[0], steps[0]); return 1; } @@ -358,7 +359,7 @@ static NPY_INLINE int run_@func@_avx512_skx_@TYPE@(char **args, npy_intp const *dimensions, npy_intp const *steps) { #if defined HAVE_ATTRIBUTE_TARGET_AVX512_SKX_WITH_INTRINSICS && defined NPY_HAVE_SSE2_INTRINSICS && @EXISTS@ - if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_bool), 64)) { + if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(@type@), sizeof(npy_bool), 64)) { AVX512_SKX_@func@_@TYPE@((npy_bool*)args[1], (@type@*)args[0], dimensions[0], steps[0]); return 1; } @@ -400,7 +401,7 @@ static NPY_INLINE int run_unary_@isa@_@func@_@TYPE@(char **args, npy_intp const *dimensions, npy_intp const *steps) { #if defined @CHK@ && defined NPY_HAVE_SSE2_INTRINSICS - if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(@type@), @REGISTER_SIZE@)) { + if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(@type@), sizeof(@type@), @REGISTER_SIZE@)) { @ISA@_@func@_@TYPE@((@type@*)args[1], (@type@*)args[0], dimensions[0], steps[0]); return 1; } @@ -426,7 +427,7 @@ static NPY_INLINE int run_unary_@isa@_@func@_FLOAT(char **args, npy_intp const *dimensions, npy_intp const *steps) { #if defined @CHK@ && defined NPY_HAVE_SSE2_INTRINSICS - if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_float), @REGISTER_SIZE@)) { + if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_float), sizeof(npy_float), @REGISTER_SIZE@)) { @ISA@_@func@_FLOAT((npy_float*)args[1], (npy_float*)args[0], dimensions[0], steps[0]); return 1; } @@ -447,7 +448,7 @@ static NPY_INLINE int run_unary_@isa@_sincos_FLOAT(char **args, npy_intp const *dimensions, npy_intp const *steps, NPY_TRIG_OP my_trig_op) { #if defined @CHK@ && defined NPY_HAVE_SSE2_INTRINSICS - if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_float), @REGISTER_SIZE@)) { + if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_float), sizeof(npy_float), @REGISTER_SIZE@)) { @ISA@_sincos_FLOAT((npy_float*)args[1], (npy_float*)args[0], dimensions[0], steps[0], my_trig_op); return 1; } @@ -468,7 +469,7 @@ run_unary_avx512f_exp_DOUBLE(char **args, npy_intp const *dimensions, npy_intp c { #if defined HAVE_ATTRIBUTE_TARGET_AVX512F_WITH_INTRINSICS && defined NPY_HAVE_SSE2_INTRINSICS #if !(defined(__clang__) && (__clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 1))) - if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_double), 64)) { + if (IS_OUTPUT_BLOCKABLE_UNARY(sizeof(npy_double), sizeof(npy_double), 64)) { AVX512F_exp_DOUBLE((npy_double*)args[1], (npy_double*)args[0], dimensions[0], steps[0]); return 1; } diff --git a/numpy/core/tests/test_cpu_features.py b/numpy/core/tests/test_cpu_features.py index 337b7330c..bafa5a05f 100644 --- a/numpy/core/tests/test_cpu_features.py +++ b/numpy/core/tests/test_cpu_features.py @@ -1,8 +1,53 @@ import sys, platform, re, pytest - -from numpy.testing import assert_equal from numpy.core._multiarray_umath import __cpu_features__ +def assert_features_equal(actual, desired, fname): + __tracebackhide__ = True # Hide traceback for py.test + actual, desired = str(actual), str(desired) + if actual == desired: + return + detected = str(__cpu_features__).replace("'", "") + try: + with open("/proc/cpuinfo", "r") as fd: + cpuinfo = fd.read(2048) + except Exception as err: + cpuinfo = str(err) + + try: + import subprocess + auxv = subprocess.check_output(['/bin/true'], env=dict(LD_SHOW_AUXV="1")) + auxv = auxv.decode() + except Exception as err: + auxv = str(err) + + import textwrap + error_report = textwrap.indent( +""" +########################################### +### Extra debugging information +########################################### +------------------------------------------- +--- NumPy Detections +------------------------------------------- +%s +------------------------------------------- +--- SYS / CPUINFO +------------------------------------------- +%s.... +------------------------------------------- +--- SYS / AUXV +------------------------------------------- +%s +""" % (detected, cpuinfo, auxv), prefix='\r') + + raise AssertionError(( + "Failure Detection\n" + " NAME: '%s'\n" + " ACTUAL: %s\n" + " DESIRED: %s\n" + "%s" + ) % (fname, actual, desired, error_report)) + class AbstractTest(object): features = [] features_groups = {} @@ -12,17 +57,16 @@ class AbstractTest(object): def load_flags(self): # a hook pass - def test_features(self): self.load_flags() for gname, features in self.features_groups.items(): test_features = [self.cpu_have(f) for f in features] - assert_equal(__cpu_features__.get(gname), all(test_features)) + assert_features_equal(__cpu_features__.get(gname), all(test_features), gname) for feature_name in self.features: cpu_have = self.cpu_have(feature_name) npy_have = __cpu_features__.get(feature_name) - assert_equal(npy_have, cpu_have) + assert_features_equal(npy_have, cpu_have, feature_name) def cpu_have(self, feature_name): map_names = self.features_map.get(feature_name, feature_name) diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index f836af168..941d99521 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -23,7 +23,7 @@ def on_powerpc(): def bad_arcsinh(): - """The blacklisted trig functions are not accurate on aarch64 for + """The blocklisted trig functions are not accurate on aarch64 for complex256. Rather than dig through the actual problem skip the test. This should be fixed when we can move past glibc2.17 which is the version in manylinux2014 diff --git a/numpy/core/tests/test_umath_complex.py b/numpy/core/tests/test_umath_complex.py index a626219c5..90a349da1 100644 --- a/numpy/core/tests/test_umath_complex.py +++ b/numpy/core/tests/test_umath_complex.py @@ -577,3 +577,34 @@ class TestComplexAbsoluteAVX(object): arr = np.ones(arraysize, dtype=astype) abs_true = np.ones(arraysize, dtype=arr.real.dtype) assert_equal(np.abs(arr[::stride]), abs_true[::stride]) + +# Testcase taken as is from https://github.com/numpy/numpy/issues/16660 +class TestComplexAbsoluteMixedDTypes(object): + @pytest.mark.parametrize("stride", [-4,-3,-2,-1,1,2,3,4]) + @pytest.mark.parametrize("astype", [np.complex64, np.complex128]) + @pytest.mark.parametrize("func", ['abs', 'square', 'conjugate']) + + def test_array(self, stride, astype, func): + dtype = [('template_id', '<i8'), ('bank_chisq','<f4'), + ('bank_chisq_dof','<i8'), ('chisq', '<f4'), ('chisq_dof','<i8'), + ('cont_chisq', '<f4'), ('psd_var_val', '<f4'), ('sg_chisq','<f4'), + ('mycomplex', astype), ('time_index', '<i8')] + vec = np.array([ + (0, 0., 0, -31.666483, 200, 0., 0., 1. , 3.0+4.0j , 613090), + (1, 0., 0, 260.91525 , 42, 0., 0., 1. , 5.0+12.0j , 787315), + (1, 0., 0, 52.15155 , 42, 0., 0., 1. , 8.0+15.0j , 806641), + (1, 0., 0, 52.430195, 42, 0., 0., 1. , 7.0+24.0j , 1363540), + (2, 0., 0, 304.43646 , 58, 0., 0., 1. , 20.0+21.0j , 787323), + (3, 0., 0, 299.42108 , 52, 0., 0., 1. , 12.0+35.0j , 787332), + (4, 0., 0, 39.4836 , 28, 0., 0., 9.182192, 9.0+40.0j , 787304), + (4, 0., 0, 76.83787 , 28, 0., 0., 1. , 28.0+45.0j, 1321869), + (5, 0., 0, 143.26366 , 24, 0., 0., 10.996129, 11.0+60.0j , 787299)], dtype=dtype) + myfunc = getattr(np, func) + a = vec['mycomplex'] + g = myfunc(a[::stride]) + + b = vec['mycomplex'].copy() + h = myfunc(b[::stride]) + + assert_array_max_ulp(h.real, g.real, 1) + assert_array_max_ulp(h.imag, g.imag, 1) diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index cc4c5d8c5..a9d6da01c 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -66,14 +66,14 @@ def test_numpy_namespace(): 'str': 'builtins.str', 'unicode': 'builtins.str', } - whitelist = dict(undocumented, **builtins) + allowlist = dict(undocumented, **builtins) else: # after 3.7, we override dir to not show these members - whitelist = undocumented + allowlist = undocumented bad_results = check_dir(np) # pytest gives better error messages with the builtin assert than with # assert_equal - assert bad_results == whitelist + assert bad_results == allowlist @pytest.mark.parametrize('name', ['testing', 'Tester']) diff --git a/numpy/tests/typing/fail/fromnumeric.py b/numpy/tests/typing/fail/fromnumeric.py index 7455ce722..66f8a89d0 100644 --- a/numpy/tests/typing/fail/fromnumeric.py +++ b/numpy/tests/typing/fail/fromnumeric.py @@ -89,3 +89,38 @@ np.ravel(a, order="bob") # E: Argument "order" to "ravel" has incompatible type np.compress( [True], A, axis=1.0 # E: Argument "axis" to "compress" has incompatible type ) + +np.clip(a, 1, 2, out=1) # E: No overload variant of "clip" matches argument type +np.clip(1, None, None) # E: No overload variant of "clip" matches argument type + +np.sum(a, axis=1.0) # E: No overload variant of "sum" matches argument type +np.sum(a, keepdims=1.0) # E: No overload variant of "sum" matches argument type +np.sum(a, initial=[1]) # E: No overload variant of "sum" matches argument type + +np.all(a, axis=1.0) # E: No overload variant of "all" matches argument type +np.all(a, keepdims=1.0) # E: No overload variant of "all" matches argument type +np.all(a, out=1.0) # E: No overload variant of "all" matches argument type + +np.any(a, axis=1.0) # E: No overload variant of "any" matches argument type +np.any(a, keepdims=1.0) # E: No overload variant of "any" matches argument type +np.any(a, out=1.0) # E: No overload variant of "any" matches argument type + +np.cumsum(a, axis=1.0) # E: Argument "axis" to "cumsum" has incompatible type +np.cumsum(a, dtype=1.0) # E: Argument "dtype" to "cumsum" has incompatible type +np.cumsum(a, out=1.0) # E: Argument "out" to "cumsum" has incompatible type + +np.ptp(a, axis=1.0) # E: No overload variant of "ptp" matches argument type +np.ptp(a, keepdims=1.0) # E: No overload variant of "ptp" matches argument type +np.ptp(a, out=1.0) # E: No overload variant of "ptp" matches argument type + +np.amax(a, axis=1.0) # E: No overload variant of "amax" matches argument type +np.amax(a, keepdims=1.0) # E: No overload variant of "amax" matches argument type +np.amax(a, out=1.0) # E: No overload variant of "amax" matches argument type +np.amax(a, initial=[1.0]) # E: No overload variant of "amax" matches argument type +np.amax(a, where=[1.0]) # E: List item 0 has incompatible type + +np.amin(a, axis=1.0) # E: No overload variant of "amin" matches argument type +np.amin(a, keepdims=1.0) # E: No overload variant of "amin" matches argument type +np.amin(a, out=1.0) # E: No overload variant of "amin" matches argument type +np.amin(a, initial=[1.0]) # E: No overload variant of "amin" matches argument type +np.amin(a, where=[1.0]) # E: List item 0 has incompatible type diff --git a/numpy/tests/typing/pass/fromnumeric.py b/numpy/tests/typing/pass/fromnumeric.py index 0ce8ef970..d9dd45c54 100644 --- a/numpy/tests/typing/pass/fromnumeric.py +++ b/numpy/tests/typing/pass/fromnumeric.py @@ -114,3 +114,72 @@ np.compress([True], b) np.compress([True], c) np.compress([True], A) np.compress([True], B) + +np.clip(a, 0, 1.0) +np.clip(b, -1, 1) +np.clip(a, 0, None) +np.clip(b, None, 1) +np.clip(c, 0, 1) +np.clip(A, 0, 1) +np.clip(B, 0, 1) +np.clip(B, [0, 1], [1, 2]) + +np.sum(a) +np.sum(b) +np.sum(c) +np.sum(A) +np.sum(B) +np.sum(A, axis=0) +np.sum(B, axis=0) + +np.all(a) +np.all(b) +np.all(c) +np.all(A) +np.all(B) +np.all(A, axis=0) +np.all(B, axis=0) +np.all(A, keepdims=True) +np.all(B, keepdims=True) + +np.any(a) +np.any(b) +np.any(c) +np.any(A) +np.any(B) +np.any(A, axis=0) +np.any(B, axis=0) +np.any(A, keepdims=True) +np.any(B, keepdims=True) + +np.cumsum(a) +np.cumsum(b) +np.cumsum(c) +np.cumsum(A) +np.cumsum(B) + +np.ptp(b) +np.ptp(c) +np.ptp(B) +np.ptp(B, axis=0) +np.ptp(B, keepdims=True) + +np.amax(a) +np.amax(b) +np.amax(c) +np.amax(A) +np.amax(B) +np.amax(A, axis=0) +np.amax(B, axis=0) +np.amax(A, keepdims=True) +np.amax(B, keepdims=True) + +np.amin(a) +np.amin(b) +np.amin(c) +np.amin(A) +np.amin(B) +np.amin(A, axis=0) +np.amin(B, axis=0) +np.amin(A, keepdims=True) +np.amin(B, keepdims=True) diff --git a/numpy/tests/typing/reveal/fromnumeric.py b/numpy/tests/typing/reveal/fromnumeric.py index 7d79d5fa9..f5feb3f5f 100644 --- a/numpy/tests/typing/reveal/fromnumeric.py +++ b/numpy/tests/typing/reveal/fromnumeric.py @@ -133,3 +133,73 @@ reveal_type(np.compress([True], b)) # E: numpy.ndarray reveal_type(np.compress([True], c)) # E: numpy.ndarray reveal_type(np.compress([True], A)) # E: numpy.ndarray reveal_type(np.compress([True], B)) # E: numpy.ndarray + +reveal_type(np.clip(a, 0, 1.0)) # E: numpy.number +reveal_type(np.clip(b, -1, 1)) # E: numpy.float32 +reveal_type(np.clip(c, 0, 1)) # E: numpy.number +reveal_type(np.clip(A, 0, 1)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.clip(B, 0, 1)) # E: Union[numpy.number, numpy.ndarray] + +reveal_type(np.sum(a)) # E: numpy.number +reveal_type(np.sum(b)) # E: numpy.float32 +reveal_type(np.sum(c)) # E: numpy.number +reveal_type(np.sum(A)) # E: numpy.number +reveal_type(np.sum(B)) # E: numpy.number +reveal_type(np.sum(A, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.sum(B, axis=0)) # E: Union[numpy.number, numpy.ndarray] + +reveal_type(np.all(a)) # E: numpy.bool_ +reveal_type(np.all(b)) # E: numpy.bool_ +reveal_type(np.all(c)) # E: numpy.bool_ +reveal_type(np.all(A)) # E: numpy.bool_ +reveal_type(np.all(B)) # E: numpy.bool_ +reveal_type(np.all(A, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.all(B, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.all(A, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.all(B, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] + +reveal_type(np.any(a)) # E: numpy.bool_ +reveal_type(np.any(b)) # E: numpy.bool_ +reveal_type(np.any(c)) # E: numpy.bool_ +reveal_type(np.any(A)) # E: numpy.bool_ +reveal_type(np.any(B)) # E: numpy.bool_ +reveal_type(np.any(A, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.any(B, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.any(A, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.any(B, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] + +reveal_type(np.cumsum(a)) # E: numpy.ndarray +reveal_type(np.cumsum(b)) # E: numpy.ndarray +reveal_type(np.cumsum(c)) # E: numpy.ndarray +reveal_type(np.cumsum(A)) # E: numpy.ndarray +reveal_type(np.cumsum(B)) # E: numpy.ndarray + +reveal_type(np.ptp(a)) # E: numpy.number +reveal_type(np.ptp(b)) # E: numpy.float32 +reveal_type(np.ptp(c)) # E: numpy.number +reveal_type(np.ptp(A)) # E: numpy.number +reveal_type(np.ptp(B)) # E: numpy.number +reveal_type(np.ptp(A, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.ptp(B, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.ptp(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.ptp(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray] + +reveal_type(np.amax(a)) # E: numpy.number +reveal_type(np.amax(b)) # E: numpy.float32 +reveal_type(np.amax(c)) # E: numpy.number +reveal_type(np.amax(A)) # E: numpy.number +reveal_type(np.amax(B)) # E: numpy.number +reveal_type(np.amax(A, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.amax(B, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.amax(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.amax(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray] + +reveal_type(np.amin(a)) # E: numpy.number +reveal_type(np.amin(b)) # E: numpy.float32 +reveal_type(np.amin(c)) # E: numpy.number +reveal_type(np.amin(A)) # E: numpy.number +reveal_type(np.amin(B)) # E: numpy.number +reveal_type(np.amin(A, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.amin(B, axis=0)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.amin(A, keepdims=True)) # E: Union[numpy.number, numpy.ndarray] +reveal_type(np.amin(B, keepdims=True)) # E: Union[numpy.number, numpy.ndarray] |