summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--benchmarks/benchmarks/bench_ufunc_strides.py (renamed from benchmarks/benchmarks/bench_avx.py)16
-rw-r--r--numpy/core/code_generators/generate_umath.py4
-rw-r--r--numpy/core/include/numpy/npy_math.h9
-rw-r--r--numpy/core/setup.py1
-rw-r--r--numpy/core/src/common/simd/vsx/vsx.h10
-rw-r--r--numpy/core/src/umath/loops.c.src26
-rw-r--r--numpy/core/src/umath/loops.h.src13
-rw-r--r--numpy/core/src/umath/loops_trigonometric.dispatch.c.src230
-rw-r--r--numpy/core/src/umath/loops_utils.h.src11
-rw-r--r--numpy/core/src/umath/npy_simd_data.h16
-rw-r--r--numpy/core/src/umath/simd.inc.src238
-rw-r--r--numpy/typing/tests/data/reveal/arithmetic.py386
-rw-r--r--numpy/typing/tests/data/reveal/bitwise_ops.py136
-rw-r--r--numpy/typing/tests/data/reveal/dtype.py22
-rw-r--r--numpy/typing/tests/data/reveal/fromnumeric.py42
-rw-r--r--numpy/typing/tests/data/reveal/mod.py176
-rw-r--r--numpy/typing/tests/data/reveal/nbit_base_example.py8
-rw-r--r--numpy/typing/tests/data/reveal/ndarray_misc.py20
-rw-r--r--numpy/typing/tests/data/reveal/scalars.py76
-rw-r--r--numpy/typing/tests/test_typing.py82
21 files changed, 789 insertions, 734 deletions
diff --git a/.gitignore b/.gitignore
index b0fa037a6..5a5e464cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -218,3 +218,4 @@ numpy/core/src/_simd/_simd_inc.h
# umath module
numpy/core/src/umath/loops_unary_fp.dispatch.c
numpy/core/src/umath/loops_arithm_fp.dispatch.c
+numpy/core/src/umath/loops_trigonometric.dispatch.c
diff --git a/benchmarks/benchmarks/bench_avx.py b/benchmarks/benchmarks/bench_ufunc_strides.py
index 82866c170..58f325e76 100644
--- a/benchmarks/benchmarks/bench_avx.py
+++ b/benchmarks/benchmarks/bench_ufunc_strides.py
@@ -2,7 +2,7 @@ from .common import Benchmark
import numpy as np
-avx_ufuncs = ['sin',
+unary_ufuncs = ['sin',
'cos',
'exp',
'log',
@@ -20,14 +20,15 @@ avx_ufuncs = ['sin',
'isinf',
'signbit']
stride = [1, 2, 4]
+stride_out = [1, 2, 4]
dtype = ['f', 'd']
-class AVX_UFunc(Benchmark):
- params = [avx_ufuncs, stride, dtype]
- param_names = ['avx_based_ufunc', 'stride', 'dtype']
+class Unary(Benchmark):
+ params = [unary_ufuncs, stride, stride_out, dtype]
+ param_names = ['ufunc', 'stride_in', 'stride_out', 'dtype']
timeout = 10
- def setup(self, ufuncname, stride, dtype):
+ def setup(self, ufuncname, stride, stride_out, dtype):
np.seterr(all='ignore')
try:
self.f = getattr(np, ufuncname)
@@ -35,9 +36,10 @@ class AVX_UFunc(Benchmark):
raise NotImplementedError()
N = 10000
self.arr = np.ones(stride*N, dtype)
+ self.arr_out = np.empty(stride_out*N, dtype)
- def time_ufunc(self, ufuncname, stride, dtype):
- self.f(self.arr[::stride])
+ def time_ufunc(self, ufuncname, stride, stride_out, dtype):
+ self.f(self.arr[::stride], self.arr_out[::stride_out])
class AVX_UFunc_log(Benchmark):
params = [stride, dtype]
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
index 4e9a2cfec..6ee8031cb 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -676,7 +676,7 @@ defdict = {
docstrings.get('numpy.core.umath.cos'),
None,
TD('e', f='cos', astype={'e':'f'}),
- TD('f', simd=[('fma', 'f'), ('avx512f', 'f')]),
+ TD('f', dispatch=[('loops_trigonometric', 'f')]),
TD('fdg' + cmplx, f='cos'),
TD(P, f='cos'),
),
@@ -685,7 +685,7 @@ defdict = {
docstrings.get('numpy.core.umath.sin'),
None,
TD('e', f='sin', astype={'e':'f'}),
- TD('f', simd=[('fma', 'f'), ('avx512f', 'f')]),
+ TD('f', dispatch=[('loops_trigonometric', 'f')]),
TD('fdg' + cmplx, f='sin'),
TD(P, f='sin'),
),
diff --git a/numpy/core/include/numpy/npy_math.h b/numpy/core/include/numpy/npy_math.h
index 7d71c36cc..f32e298f0 100644
--- a/numpy/core/include/numpy/npy_math.h
+++ b/numpy/core/include/numpy/npy_math.h
@@ -151,15 +151,6 @@ NPY_INPLACE npy_longlong npy_rshiftll(npy_longlong a, npy_longlong b);
NPY_INPLACE npy_longlong npy_lshiftll(npy_longlong a, npy_longlong b);
/*
- * avx function has a common API for both sin & cos. This enum is used to
- * distinguish between the two
- */
-typedef enum {
- npy_compute_sin,
- npy_compute_cos
-} NPY_TRIG_OP;
-
-/*
* C99 double math funcs
*/
NPY_INPLACE double npy_sin(double x);
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 2e020a595..1042a1c45 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -929,6 +929,7 @@ def configuration(parent_package='',top_path=None):
join('src', 'umath', 'scalarmath.c.src'),
join('src', 'umath', 'ufunc_type_resolution.c'),
join('src', 'umath', 'override.c'),
+ join('src', 'umath', 'loops_trigonometric.dispatch.c.src'),
]
umath_deps = [
diff --git a/numpy/core/src/common/simd/vsx/vsx.h b/numpy/core/src/common/simd/vsx/vsx.h
index 769f5a08f..66b76208f 100644
--- a/numpy/core/src/common/simd/vsx/vsx.h
+++ b/numpy/core/src/common/simd/vsx/vsx.h
@@ -2,6 +2,16 @@
#error "Not a standalone header"
#endif
+#if defined(__GNUC__) && __GNUC__ <= 7
+ /**
+ * GCC <= 7 produces ambiguous warning caused by -Werror=maybe-uninitialized,
+ * when certain intrinsics involved. `vec_ld` is one of them but it seemed to work fine,
+ * and suppressing the warning wouldn't affect its functionality.
+ */
+ #pragma GCC diagnostic ignored "-Wuninitialized"
+ #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
#define NPY_SIMD 128
#define NPY_SIMD_WIDTH 16
#define NPY_SIMD_F64 1
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 839d2b3ae..ba538d2ab 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1658,8 +1658,8 @@ NPY_NO_EXPORT NPY_GCC_OPT_3 void
/**end repeat**/
/**begin repeat
- * #func = sin, cos, exp, log#
- * #scalarf = npy_sinf, npy_cosf, npy_expf, npy_logf#
+ * #func = exp, log#
+ * #scalarf = npy_expf, npy_logf#
*/
NPY_NO_EXPORT NPY_GCC_OPT_3 void
@@ -1749,28 +1749,6 @@ FLOAT_@func@_@isa@(char **args, npy_intp const *dimensions, npy_intp const *step
/**end repeat1**/
-/**begin repeat1
- * #func = cos, sin#
- * #enum = npy_compute_cos, npy_compute_sin#
- * #scalarf = npy_cosf, npy_sinf#
- */
-
-NPY_NO_EXPORT NPY_GCC_OPT_3 void
-FLOAT_@func@_@isa@(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))
-{
- if (!run_unary_@isa@_sincos_FLOAT(args, dimensions, steps, @enum@)) {
- UNARY_LOOP {
-#if defined @CHK@ && defined NPY_HAVE_SSE2_INTRINSICS
- @ISA@_sincos_FLOAT((npy_float *)op1, (npy_float *)ip1, 1, steps[0], @enum@);
-#else
- const npy_float in1 = *(npy_float *)ip1;
- *(npy_float *)op1 = @scalarf@(in1);
-#endif
- }
- }
-}
-
-/**end repeat1**/
/**end repeat**/
NPY_NO_EXPORT NPY_GCC_OPT_3 void
diff --git a/numpy/core/src/umath/loops.h.src b/numpy/core/src/umath/loops.h.src
index c15ff8e3b..d73c9fa7f 100644
--- a/numpy/core/src/umath/loops.h.src
+++ b/numpy/core/src/umath/loops.h.src
@@ -225,8 +225,19 @@ DOUBLE_log(char **args, npy_intp const *dimensions, npy_intp const *steps, void
NPY_NO_EXPORT void
DOUBLE_log_avx512f(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func));
+#ifndef NPY_DISABLE_OPTIMIZATION
+ #include "loops_trigonometric.dispatch.h"
+#endif
+/**begin repeat
+ * #func = sin, cos#
+ */
+NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_@func@, (
+ char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)
+))
+/**end repeat**/
+
/**begin repeat
- * #func = sin, cos, exp, log#
+ * #func = exp, log#
*/
NPY_NO_EXPORT void
FLOAT_@func@(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func));
diff --git a/numpy/core/src/umath/loops_trigonometric.dispatch.c.src b/numpy/core/src/umath/loops_trigonometric.dispatch.c.src
new file mode 100644
index 000000000..8c2c83e7c
--- /dev/null
+++ b/numpy/core/src/umath/loops_trigonometric.dispatch.c.src
@@ -0,0 +1,230 @@
+/*@targets
+ ** $maxopt baseline
+ ** (avx2 fma3) avx512f
+ ** vsx2
+ ** neon_vfpv4
+ **/
+#include "numpy/npy_math.h"
+#include "simd/simd.h"
+#include "loops_utils.h"
+#include "loops.h"
+/*
+ * TODO:
+ * - use vectorized version of Payne-Hanek style reduction for large elements or
+ * when there's no native FUSED support instead of fallback to libc
+ */
+#if NPY_SIMD_FMA3 // native support
+/*
+ * Vectorized Cody-Waite range reduction technique
+ * Performs the reduction step x* = x - y*C in three steps:
+ * 1) x* = x - y*c1
+ * 2) x* = x - y*c2
+ * 3) x* = x - y*c3
+ * c1, c2 are exact floating points, c3 = C - c1 - c2 simulates higher precision
+ */
+NPY_FINLINE npyv_f32
+simd_range_reduction_f32(npyv_f32 x, npyv_f32 y, npyv_f32 c1, npyv_f32 c2, npyv_f32 c3)
+{
+ npyv_f32 reduced_x = npyv_muladd_f32(y, c1, x);
+ reduced_x = npyv_muladd_f32(y, c2, reduced_x);
+ reduced_x = npyv_muladd_f32(y, c3, reduced_x);
+ return reduced_x;
+}
+/*
+ * Approximate cosine algorithm for x \in [-PI/4, PI/4]
+ * Maximum ULP across all 32-bit floats = 0.875
+ */
+NPY_FINLINE npyv_f32
+simd_cosine_poly_f32(npyv_f32 x2)
+{
+ const npyv_f32 invf8 = npyv_setall_f32(0x1.98e616p-16f);
+ const npyv_f32 invf6 = npyv_setall_f32(-0x1.6c06dcp-10f);
+ const npyv_f32 invf4 = npyv_setall_f32(0x1.55553cp-05f);
+ const npyv_f32 invf2 = npyv_setall_f32(-0x1.000000p-01f);
+ const npyv_f32 invf0 = npyv_setall_f32(0x1.000000p+00f);
+
+ npyv_f32 r = npyv_muladd_f32(invf8, x2, invf6);
+ r = npyv_muladd_f32(r, x2, invf4);
+ r = npyv_muladd_f32(r, x2, invf2);
+ r = npyv_muladd_f32(r, x2, invf0);
+ return r;
+}
+/*
+ * Approximate sine algorithm for x \in [-PI/4, PI/4]
+ * Maximum ULP across all 32-bit floats = 0.647
+ * Polynomial approximation based on unpublished work by T. Myklebust
+ */
+NPY_FINLINE npyv_f32
+simd_sine_poly_f32(npyv_f32 x, npyv_f32 x2)
+{
+ const npyv_f32 invf9 = npyv_setall_f32(0x1.7d3bbcp-19f);
+ const npyv_f32 invf7 = npyv_setall_f32(-0x1.a06bbap-13f);
+ const npyv_f32 invf5 = npyv_setall_f32(0x1.11119ap-07f);
+ const npyv_f32 invf3 = npyv_setall_f32(-0x1.555556p-03f);
+
+ npyv_f32 r = npyv_muladd_f32(invf9, x2, invf7);
+ r = npyv_muladd_f32(r, x2, invf5);
+ r = npyv_muladd_f32(r, x2, invf3);
+ r = npyv_muladd_f32(r, x2, npyv_zero_f32());
+ r = npyv_muladd_f32(r, x, x);
+ return r;
+}
+/*
+ * Vectorized approximate sine/cosine algorithms: The following code is a
+ * vectorized version of the algorithm presented here:
+ * https://stackoverflow.com/questions/30463616/payne-hanek-algorithm-implementation-in-c/30465751#30465751
+ * (1) Load data in registers and generate mask for elements that are
+ * within range [-71476.0625f, 71476.0625f] for cosine and [-117435.992f,
+ * 117435.992f] for sine.
+ * (2) For elements within range, perform range reduction using Cody-Waite's
+ * method: x* = x - y*PI/2, where y = rint(x*2/PI). x* \in [-PI/4, PI/4].
+ * (3) Map cos(x) to (+/-)sine or (+/-)cosine of x* based on the quadrant k =
+ * int(y).
+ * (4) For elements outside that range, Cody-Waite reduction performs poorly
+ * leading to catastrophic cancellation. We compute cosine by calling glibc in
+ * a scalar fashion.
+ * (5) Vectorized implementation has a max ULP of 1.49 and performs at least
+ * 5-7x(x86) - 2.5-3x(Power) - 1-2x(Arm) faster than scalar implementations
+ * when magnitude of all elements in the array < 71476.0625f (117435.992f for sine).
+ * Worst case performance is when all the elements are large leading to about 1-2% reduction in
+ * performance.
+ */
+typedef enum
+{
+ SIMD_COMPUTE_SIN,
+ SIMD_COMPUTE_COS
+} SIMD_TRIG_OP;
+
+static void SIMD_MSVC_NOINLINE
+simd_sincos_f32(const float *src, npy_intp ssrc, float *dst, npy_intp sdst,
+ npy_intp len, SIMD_TRIG_OP trig_op)
+{
+ // Load up frequently used constants
+ const npyv_f32 zerosf = npyv_zero_f32();
+ const npyv_s32 ones = npyv_setall_s32(1);
+ const npyv_s32 twos = npyv_setall_s32(2);
+ const npyv_f32 two_over_pi = npyv_setall_f32(0x1.45f306p-1f);
+ const npyv_f32 codyw_pio2_highf = npyv_setall_f32(-0x1.921fb0p+00f);
+ const npyv_f32 codyw_pio2_medf = npyv_setall_f32(-0x1.5110b4p-22f);
+ const npyv_f32 codyw_pio2_lowf = npyv_setall_f32(-0x1.846988p-48f);
+ const npyv_f32 rint_cvt_magic = npyv_setall_f32(0x1.800000p+23f);
+ // Cody-Waite's range
+ float max_codi = 117435.992f;
+ if (trig_op == SIMD_COMPUTE_COS) {
+ max_codi = 71476.0625f;
+ }
+ const npyv_f32 max_cody = npyv_setall_f32(max_codi);
+ const int vstep = npyv_nlanes_f32;
+
+ for (; len > 0; len -= vstep, src += ssrc*vstep, dst += sdst*vstep) {
+ npyv_f32 x_in;
+ if (ssrc == 1) {
+ x_in = npyv_load_tillz_f32(src, len);
+ } else {
+ x_in = npyv_loadn_tillz_f32(src, ssrc, len);
+ }
+ npyv_b32 simd_mask = npyv_cmple_f32(npyv_abs_f32(x_in), max_cody);
+ npy_uint64 simd_maski = npyv_tobits_b32(simd_mask);
+ /*
+ * For elements outside of this range, Cody-Waite's range reduction
+ * becomes inaccurate and we will call libc to compute cosine for
+ * these numbers
+ */
+ if (simd_maski != 0) {
+ npyv_b32 nnan_mask = npyv_notnan_f32(x_in);
+ npyv_f32 x = npyv_select_f32(npyv_and_b32(nnan_mask, simd_mask), x_in, zerosf);
+
+ npyv_f32 quadrant = npyv_mul_f32(x, two_over_pi);
+ // round to nearest, -0.0f -> +0.0f, and |a| must be <= 0x1.0p+22
+ quadrant = npyv_add_f32(quadrant, rint_cvt_magic);
+ quadrant = npyv_sub_f32(quadrant, rint_cvt_magic);
+
+ // Cody-Waite's range reduction algorithm
+ npyv_f32 reduced_x = simd_range_reduction_f32(
+ x, quadrant, codyw_pio2_highf, codyw_pio2_medf, codyw_pio2_lowf
+ );
+ npyv_f32 reduced_x2 = npyv_square_f32(reduced_x);
+
+ // compute cosine and sine
+ npyv_f32 cos = simd_cosine_poly_f32(reduced_x2);
+ npyv_f32 sin = simd_sine_poly_f32(reduced_x, reduced_x2);
+
+ npyv_s32 iquadrant = npyv_round_s32_f32(quadrant);
+ if (trig_op == SIMD_COMPUTE_COS) {
+ iquadrant = npyv_add_s32(iquadrant, ones);
+ }
+ // blend sin and cos based on the quadrant
+ npyv_b32 sine_mask = npyv_cmpeq_s32(npyv_and_s32(iquadrant, ones), npyv_zero_s32());
+ cos = npyv_select_f32(sine_mask, sin, cos);
+
+ // multiply by -1 for appropriate elements
+ npyv_b32 negate_mask = npyv_cmpeq_s32(npyv_and_s32(iquadrant, twos), twos);
+ cos = npyv_ifsub_f32(negate_mask, zerosf, cos, cos);
+ cos = npyv_select_f32(nnan_mask, cos, npyv_setall_f32(NPY_NANF));
+
+ if (sdst == 1) {
+ npyv_store_till_f32(dst, len, cos);
+ } else {
+ npyv_storen_till_f32(dst, sdst, len, cos);
+ }
+ }
+ if (simd_maski != ((1 << vstep) - 1)) {
+ float NPY_DECL_ALIGNED(NPY_SIMD_WIDTH) ip_fback[npyv_nlanes_f32];
+ npyv_storea_f32(ip_fback, x_in);
+
+ // process elements using libc for large elements
+ if (trig_op == SIMD_COMPUTE_COS) {
+ for (unsigned i = 0; i < npyv_nlanes_f32; ++i) {
+ if ((simd_maski >> i) & 1) {
+ continue;
+ }
+ dst[sdst*i] = npy_cosf(ip_fback[i]);
+ }
+ }
+ else {
+ for (unsigned i = 0; i < npyv_nlanes_f32; ++i) {
+ if ((simd_maski >> i) & 1) {
+ continue;
+ }
+ dst[sdst*i] = npy_sinf(ip_fback[i]);
+ }
+ }
+ }
+ }
+ npyv_cleanup();
+}
+#endif // NPY_SIMD_FMA3
+
+/**begin repeat
+ * #func = cos, sin#
+ * #enum = SIMD_COMPUTE_COS, SIMD_COMPUTE_SIN#
+ */
+NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(FLOAT_@func@)
+(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))
+{
+ const float *src = (float*)args[0];
+ float *dst = (float*)args[1];
+
+ const int lsize = sizeof(src[0]);
+ const npy_intp ssrc = steps[0] / lsize;
+ const npy_intp sdst = steps[1] / lsize;
+ npy_intp len = dimensions[0];
+ assert(steps[0] % lsize == 0 && steps[1] % lsize == 0);
+#if NPY_SIMD_FMA3
+ if (is_mem_overlap(src, steps[0], dst, steps[1], len) ||
+ !npyv_loadable_stride_f32(ssrc) || !npyv_storable_stride_f32(sdst)
+ ) {
+ for (; len > 0; --len, src += ssrc, dst += sdst) {
+ simd_sincos_f32(src, 1, dst, 1, 1, @enum@);
+ }
+ } else {
+ simd_sincos_f32(src, ssrc, dst, sdst, len, @enum@);
+ }
+#else
+ for (; len > 0; --len, src += ssrc, dst += sdst) {
+ const float src0 = *src;
+ *dst = npy_@func@f(src0);
+ }
+#endif
+}
+/**end repeat**/
diff --git a/numpy/core/src/umath/loops_utils.h.src b/numpy/core/src/umath/loops_utils.h.src
index dfa790ed9..1a2a5a32b 100644
--- a/numpy/core/src/umath/loops_utils.h.src
+++ b/numpy/core/src/umath/loops_utils.h.src
@@ -3,6 +3,17 @@
#include "numpy/npy_common.h" // NPY_FINLINE
#include "numpy/halffloat.h" // npy_half_to_float
+
+/**
+ * Old versions of MSVC causes ambiguous link errors when we deal with large SIMD kernels
+ * which lead to break the build, probably releated to the following bug:
+ * https://developercommunity.visualstudio.com/content/problem/415095/internal-compiler-error-with-perfectly-forwarded-r.html
+ */
+#if defined(_MSC_VER) && _MSC_VER < 1916
+ #define SIMD_MSVC_NOINLINE __declspec(noinline)
+#else
+ #define SIMD_MSVC_NOINLINE
+#endif
/*
* nomemoverlap - returns false if two strided arrays have an overlapping
* region in memory. ip_size/op_size = size of the arrays which can be negative
diff --git a/numpy/core/src/umath/npy_simd_data.h b/numpy/core/src/umath/npy_simd_data.h
index 45487d0a8..be9288aff 100644
--- a/numpy/core/src/umath/npy_simd_data.h
+++ b/numpy/core/src/umath/npy_simd_data.h
@@ -119,22 +119,6 @@ static npy_uint64 EXP_Table_tail[32] = {
#define NPY_COEFF_Q3_LOGf 9.864942958519418960339e-01f
#define NPY_COEFF_Q4_LOGf 1.546476374983906719538e-01f
#define NPY_COEFF_Q5_LOGf 5.875095403124574342950e-03f
-/*
- * Constants used in vector implementation of sinf/cosf(x)
- */
-#define NPY_TWO_O_PIf 0x1.45f306p-1f
-#define NPY_CODY_WAITE_PI_O_2_HIGHf -0x1.921fb0p+00f
-#define NPY_CODY_WAITE_PI_O_2_MEDf -0x1.5110b4p-22f
-#define NPY_CODY_WAITE_PI_O_2_LOWf -0x1.846988p-48f
-#define NPY_COEFF_INVF0_COSINEf 0x1.000000p+00f
-#define NPY_COEFF_INVF2_COSINEf -0x1.000000p-01f
-#define NPY_COEFF_INVF4_COSINEf 0x1.55553cp-05f
-#define NPY_COEFF_INVF6_COSINEf -0x1.6c06dcp-10f
-#define NPY_COEFF_INVF8_COSINEf 0x1.98e616p-16f
-#define NPY_COEFF_INVF3_SINEf -0x1.555556p-03f
-#define NPY_COEFF_INVF5_SINEf 0x1.11119ap-07f
-#define NPY_COEFF_INVF7_SINEf -0x1.a06bbap-13f
-#define NPY_COEFF_INVF9_SINEf 0x1.7d3bbcp-19f
/*
* Lookup table of log(c_k)
diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src
index 3d4e6de87..e66763986 100644
--- a/numpy/core/src/umath/simd.inc.src
+++ b/numpy/core/src/umath/simd.inc.src
@@ -271,25 +271,6 @@ run_unary_@isa@_@func@_FLOAT(char **args, npy_intp const *dimensions, npy_intp c
/**end repeat1**/
-#if defined @CHK@ && defined NPY_HAVE_SSE2_INTRINSICS
-static NPY_INLINE void
-@ISA@_sincos_FLOAT(npy_float *, npy_float *, const npy_intp n, const npy_intp steps, NPY_TRIG_OP);
-#endif
-
-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), 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;
- }
- else
- return 0;
-#endif
- return 0;
-}
-
/**end repeat**/
#if defined HAVE_ATTRIBUTE_TARGET_AVX512F_WITH_INTRINSICS && defined NPY_HAVE_SSE2_INTRINSICS
@@ -976,19 +957,6 @@ fma_invert_mask_pd(__m256i ymask)
}
static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_FMA __m256
-fma_should_calculate_sine(__m256i k, __m256i andop, __m256i cmp)
-{
- return _mm256_cvtepi32_ps(
- _mm256_cmpeq_epi32(_mm256_and_si256(k, andop), cmp));
-}
-
-static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_FMA __m256
-fma_should_negate(__m256i k, __m256i andop, __m256i cmp)
-{
- return fma_should_calculate_sine(k, andop, cmp);
-}
-
-static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_FMA __m256
fma_get_exponent(__m256 x)
{
/*
@@ -1215,18 +1183,6 @@ avx512_invert_mask_pd(__mmask8 ymask)
return _mm512_knot(ymask);
}
-static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_AVX512F __mmask16
-avx512_should_calculate_sine(__m512i k, __m512i andop, __m512i cmp)
-{
- return _mm512_cmpeq_epi32_mask(_mm512_and_epi32(k, andop), cmp);
-}
-
-static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_AVX512F __mmask16
-avx512_should_negate(__m512i k, __m512i andop, __m512i cmp)
-{
- return avx512_should_calculate_sine(k, andop, cmp);
-}
-
static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_AVX512F __m512
avx512_get_exponent(__m512 x)
{
@@ -1458,40 +1414,6 @@ static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ @mask@
return _mm@vsize@_@or@(m1,m2);
}
-/*
- * Approximate cosine algorithm for x \in [-PI/4, PI/4]
- * Maximum ULP across all 32-bit floats = 0.875
- */
-
-static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ @vtype@
-@isa@_cosine(@vtype@ x2, @vtype@ invf8, @vtype@ invf6, @vtype@ invf4,
- @vtype@ invf2, @vtype@ invf0)
-{
- @vtype@ cos = @fmadd@(invf8, x2, invf6);
- cos = @fmadd@(cos, x2, invf4);
- cos = @fmadd@(cos, x2, invf2);
- cos = @fmadd@(cos, x2, invf0);
- return cos;
-}
-
-/*
- * Approximate sine algorithm for x \in [-PI/4, PI/4]
- * Maximum ULP across all 32-bit floats = 0.647
- */
-
-static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ @vtype@
-@isa@_sine(@vtype@ x, @vtype@ x2, @vtype@ invf9, @vtype@ invf7,
- @vtype@ invf5, @vtype@ invf3,
- @vtype@ zero)
-{
- @vtype@ sin = @fmadd@(invf9, x2, invf7);
- sin = @fmadd@(sin, x2, invf5);
- sin = @fmadd@(sin, x2, invf3);
- sin = @fmadd@(sin, x2, zero);
- sin = @fmadd@(sin, x, x);
- return sin;
-}
-
static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ @vtype@
@isa@_sqrt_ps(@vtype@ x)
{
@@ -2004,167 +1926,7 @@ static NPY_INLINE NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ void
* #cvtps_epi32 = _mm256_cvtps_epi32, #
* #CHK = HAVE_ATTRIBUTE_TARGET_AVX2_WITH_INTRINSICS, HAVE_ATTRIBUTE_TARGET_AVX512F_WITH_INTRINSICS#
*/
-
-/*
- * Vectorized approximate sine/cosine algorithms: The following code is a
- * vectorized version of the algorithm presented here:
- * https://stackoverflow.com/questions/30463616/payne-hanek-algorithm-implementation-in-c/30465751#30465751
- * (1) Load data in ZMM/YMM registers and generate mask for elements that are
- * within range [-71476.0625f, 71476.0625f] for cosine and [-117435.992f,
- * 117435.992f] for sine.
- * (2) For elements within range, perform range reduction using Cody-Waite's
- * method: x* = x - y*PI/2, where y = rint(x*2/PI). x* \in [-PI/4, PI/4].
- * (3) Map cos(x) to (+/-)sine or (+/-)cosine of x* based on the quadrant k =
- * int(y).
- * (4) For elements outside that range, Cody-Waite reduction performs poorly
- * leading to catastrophic cancellation. We compute cosine by calling glibc in
- * a scalar fashion.
- * (5) Vectorized implementation has a max ULP of 1.49 and performs at least
- * 5-7x faster than scalar implementations when magnitude of all elements in
- * the array < 71476.0625f (117435.992f for sine). Worst case performance is
- * when all the elements are large leading to about 1-2% reduction in
- * performance.
- */
-
#if defined @CHK@
-static NPY_GCC_OPT_3 NPY_GCC_TARGET_@ISA@ void
-@ISA@_sincos_FLOAT(npy_float * op,
- npy_float * ip,
- const npy_intp array_size,
- const npy_intp steps,
- NPY_TRIG_OP my_trig_op)
-{
- const npy_intp stride = steps/(npy_intp)sizeof(npy_float);
- const npy_int num_lanes = @NUM_LANES@;
- npy_float large_number = 71476.0625f;
- if (my_trig_op == npy_compute_sin) {
- large_number = 117435.992f;
- }
-
- /* Load up frequently used constants */
- @vtype@i zeros = _mm@vsize@_set1_epi32(0);
- @vtype@i ones = _mm@vsize@_set1_epi32(1);
- @vtype@i twos = _mm@vsize@_set1_epi32(2);
- @vtype@ two_over_pi = _mm@vsize@_set1_ps(NPY_TWO_O_PIf);
- @vtype@ codyw_c1 = _mm@vsize@_set1_ps(NPY_CODY_WAITE_PI_O_2_HIGHf);
- @vtype@ codyw_c2 = _mm@vsize@_set1_ps(NPY_CODY_WAITE_PI_O_2_MEDf);
- @vtype@ codyw_c3 = _mm@vsize@_set1_ps(NPY_CODY_WAITE_PI_O_2_LOWf);
- @vtype@ cos_invf0 = _mm@vsize@_set1_ps(NPY_COEFF_INVF0_COSINEf);
- @vtype@ cos_invf2 = _mm@vsize@_set1_ps(NPY_COEFF_INVF2_COSINEf);
- @vtype@ cos_invf4 = _mm@vsize@_set1_ps(NPY_COEFF_INVF4_COSINEf);
- @vtype@ cos_invf6 = _mm@vsize@_set1_ps(NPY_COEFF_INVF6_COSINEf);
- @vtype@ cos_invf8 = _mm@vsize@_set1_ps(NPY_COEFF_INVF8_COSINEf);
- @vtype@ sin_invf3 = _mm@vsize@_set1_ps(NPY_COEFF_INVF3_SINEf);
- @vtype@ sin_invf5 = _mm@vsize@_set1_ps(NPY_COEFF_INVF5_SINEf);
- @vtype@ sin_invf7 = _mm@vsize@_set1_ps(NPY_COEFF_INVF7_SINEf);
- @vtype@ sin_invf9 = _mm@vsize@_set1_ps(NPY_COEFF_INVF9_SINEf);
- @vtype@ cvt_magic = _mm@vsize@_set1_ps(NPY_RINT_CVT_MAGICf);
- @vtype@ zero_f = _mm@vsize@_set1_ps(0.0f);
- @vtype@ quadrant, reduced_x, reduced_x2, cos, sin;
- @vtype@i iquadrant;
- @mask@ nan_mask, glibc_mask, sine_mask, negate_mask;
- @mask@ load_mask = @isa@_get_full_load_mask_ps();
- npy_intp num_remaining_elements = array_size;
-
- /*
- * Note: while generally indices are npy_intp, we ensure that our maximum index
- * will fit in an int32 as a precondition for this function via
- * IS_OUTPUT_BLOCKABLE_UNARY
- */
- npy_int32 indexarr[16];
- for (npy_int32 ii = 0; ii < 16; ii++) {
- indexarr[ii] = ii*stride;
- }
- @vtype@i vindex = _mm@vsize@_loadu_si@vsize@((@vtype@i*)&indexarr[0]);
-
- while (num_remaining_elements > 0) {
-
- if (num_remaining_elements < num_lanes) {
- load_mask = @isa@_get_partial_load_mask_ps(num_remaining_elements,
- num_lanes);
- }
-
- @vtype@ x_in;
- if (stride == 1) {
- x_in = @isa@_masked_load_ps(load_mask, ip);
- }
- else {
- x_in = @isa@_masked_gather_ps(zero_f, ip, vindex, load_mask);
- }
-
- /*
- * For elements outside of this range, Cody-Waite's range reduction
- * becomes inaccurate and we will call glibc to compute cosine for
- * these numbers
- */
-
- glibc_mask = @isa@_in_range_mask(x_in, large_number,-large_number);
- glibc_mask = @and_masks@(load_mask, glibc_mask);
- nan_mask = _mm@vsize@_cmp_ps@vsub@(x_in, x_in, _CMP_NEQ_UQ);
- @vtype@ x = @isa@_set_masked_lanes_ps(x_in, zero_f, @or_masks@(nan_mask, glibc_mask));
- npy_int iglibc_mask = @mask_to_int@(glibc_mask);
-
- if (iglibc_mask != @full_mask@) {
- quadrant = _mm@vsize@_mul_ps(x, two_over_pi);
-
- /* round to nearest */
- quadrant = _mm@vsize@_add_ps(quadrant, cvt_magic);
- quadrant = _mm@vsize@_sub_ps(quadrant, cvt_magic);
-
- /* Cody-Waite's range reduction algorithm */
- reduced_x = @isa@_range_reduction(x, quadrant,
- codyw_c1, codyw_c2, codyw_c3);
- reduced_x2 = _mm@vsize@_mul_ps(reduced_x, reduced_x);
-
- /* compute cosine and sine */
- cos = @isa@_cosine(reduced_x2, cos_invf8, cos_invf6, cos_invf4,
- cos_invf2, cos_invf0);
- sin = @isa@_sine(reduced_x, reduced_x2, sin_invf9, sin_invf7,
- sin_invf5, sin_invf3, zero_f);
-
- iquadrant = _mm@vsize@_cvtps_epi32(quadrant);
- if (my_trig_op == npy_compute_cos) {
- iquadrant = _mm@vsize@_add_epi32(iquadrant, ones);
- }
-
- /* blend sin and cos based on the quadrant */
- sine_mask = @isa@_should_calculate_sine(iquadrant, ones, zeros);
- cos = @isa@_blend(cos, sin, sine_mask);
-
- /* multiply by -1 for appropriate elements */
- negate_mask = @isa@_should_negate(iquadrant, twos, twos);
- cos = @isa@_blend(cos, _mm@vsize@_sub_ps(zero_f, cos), negate_mask);
- cos = @isa@_set_masked_lanes_ps(cos, _mm@vsize@_set1_ps(NPY_NANF), nan_mask);
-
- @masked_store@(op, @cvtps_epi32@(load_mask), cos);
- }
-
- /* process elements using glibc for large elements */
- if (iglibc_mask != 0) {
- float NPY_DECL_ALIGNED(@BYTES@) ip_fback[@NUM_LANES@];
- _mm@vsize@_store_ps(ip_fback, x_in);
-
- if (my_trig_op == npy_compute_cos) {
- for (int ii = 0; ii < num_lanes; ++ii, iglibc_mask >>= 1) {
- if (iglibc_mask & 0x01) {
- op[ii] = npy_cosf(ip_fback[ii]);
- }
- }
- }
- else {
- for (int ii = 0; ii < num_lanes; ++ii, iglibc_mask >>= 1) {
- if (iglibc_mask & 0x01) {
- op[ii] = npy_sinf(ip_fback[ii]);
- }
- }
- }
- }
- ip += num_lanes*stride;
- op += num_lanes;
- num_remaining_elements -= num_lanes;
- }
-}
-
/*
* Vectorized implementation of exp using AVX2 and AVX512:
* 1) if x >= xmax; return INF (overflow)
diff --git a/numpy/typing/tests/data/reveal/arithmetic.py b/numpy/typing/tests/data/reveal/arithmetic.py
index 4d07e8dac..8574df936 100644
--- a/numpy/typing/tests/data/reveal/arithmetic.py
+++ b/numpy/typing/tests/data/reveal/arithmetic.py
@@ -25,36 +25,36 @@ AR.setflags(write=False)
# unary ops
-reveal_type(-c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(-c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(-f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(-f4) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(-i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(-i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(-u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(-u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(-c16) # E: {complex128}
+reveal_type(-c8) # E: {complex64}
+reveal_type(-f8) # E: {float64}
+reveal_type(-f4) # E: {float32}
+reveal_type(-i8) # E: {int64}
+reveal_type(-i4) # E: {int32}
+reveal_type(-u8) # E: {uint64}
+reveal_type(-u4) # E: {uint32}
reveal_type(-td) # E: numpy.timedelta64
reveal_type(-AR) # E: Any
-reveal_type(+c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(+c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(+f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(+f4) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(+i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(+i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(+u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(+u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(+c16) # E: {complex128}
+reveal_type(+c8) # E: {complex64}
+reveal_type(+f8) # E: {float64}
+reveal_type(+f4) # E: {float32}
+reveal_type(+i8) # E: {int64}
+reveal_type(+i4) # E: {int32}
+reveal_type(+u8) # E: {uint64}
+reveal_type(+u4) # E: {uint32}
reveal_type(+td) # E: numpy.timedelta64
reveal_type(+AR) # E: Any
-reveal_type(abs(c16)) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(abs(c8)) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(abs(f8)) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(abs(f4)) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(abs(i8)) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(abs(i4)) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(abs(u8)) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(abs(u4)) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(abs(c16)) # E: {float64}
+reveal_type(abs(c8)) # E: {float32}
+reveal_type(abs(f8)) # E: {float64}
+reveal_type(abs(f4)) # E: {float32}
+reveal_type(abs(i8)) # E: {int64}
+reveal_type(abs(i4)) # E: {int32}
+reveal_type(abs(u8)) # E: {uint64}
+reveal_type(abs(u4)) # E: {uint32}
reveal_type(abs(td)) # E: numpy.timedelta64
reveal_type(abs(b_)) # E: numpy.bool_
reveal_type(abs(AR)) # E: Any
@@ -81,214 +81,212 @@ reveal_type(td - i8) # E: numpy.timedelta64
reveal_type(td / f) # E: numpy.timedelta64
reveal_type(td / f4) # E: numpy.timedelta64
reveal_type(td / f8) # E: numpy.timedelta64
-reveal_type(td / td) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(td // td) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(td / td) # E: {float64}
+reveal_type(td // td) # E: {int64}
# boolean
-reveal_type(b_ / b) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / i) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / i8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / i4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / u8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / u4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / f4) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(b_ / c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(b_ / c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(b_ / c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-
-reveal_type(b / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i4 / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(u8 / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(u4 / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 / b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 / b_) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(c / b_) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 / b_) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 / b_) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(b_ / b) # E: {float64}
+reveal_type(b_ / b_) # E: {float64}
+reveal_type(b_ / i) # E: {float64}
+reveal_type(b_ / i8) # E: {float64}
+reveal_type(b_ / i4) # E: {float64}
+reveal_type(b_ / u8) # E: {float64}
+reveal_type(b_ / u4) # E: {float64}
+reveal_type(b_ / f) # E: {float64}
+reveal_type(b_ / f8) # E: {float64}
+reveal_type(b_ / f4) # E: {float32}
+reveal_type(b_ / c) # E: {complex128}
+reveal_type(b_ / c16) # E: {complex128}
+reveal_type(b_ / c8) # E: {complex64}
+
+reveal_type(b / b_) # E: {float64}
+reveal_type(b_ / b_) # E: {float64}
+reveal_type(i / b_) # E: {float64}
+reveal_type(i8 / b_) # E: {float64}
+reveal_type(i4 / b_) # E: {float64}
+reveal_type(u8 / b_) # E: {float64}
+reveal_type(u4 / b_) # E: {float64}
+reveal_type(f / b_) # E: {float64}
+reveal_type(f8 / b_) # E: {float64}
+reveal_type(f4 / b_) # E: {float32}
+reveal_type(c / b_) # E: {complex128}
+reveal_type(c16 / b_) # E: {complex128}
+reveal_type(c8 / b_) # E: {complex64}
# Complex
-reveal_type(c16 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + f4) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + i4) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + b_) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + b) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c16 + f) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-
-# note this comment is deliberate truncated as the result varies by platform,
-# and the numpy `reveal` tests use substring matching
-reveal_type(c16 + i) # E: numpy.complexfloating[numpy.typing._
+reveal_type(c16 + c16) # E: {complex128}
+reveal_type(c16 + f8) # E: {complex128}
+reveal_type(c16 + i8) # E: {complex128}
+reveal_type(c16 + c8) # E: {complex128}
+reveal_type(c16 + f4) # E: {complex128}
+reveal_type(c16 + i4) # E: {complex128}
+reveal_type(c16 + b_) # E: {complex128}
+reveal_type(c16 + b) # E: {complex128}
+reveal_type(c16 + c) # E: {complex128}
+reveal_type(c16 + f) # E: {complex128}
+
+reveal_type(c16 + i) # E: {complex128}
reveal_type(c16 + AR) # E: Any
-reveal_type(c16 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(i8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f4 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(i4 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(b_ + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(b + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(i + c16) # E: numpy.complexfloating[numpy.typing._
+reveal_type(c16 + c16) # E: {complex128}
+reveal_type(f8 + c16) # E: {complex128}
+reveal_type(i8 + c16) # E: {complex128}
+reveal_type(c8 + c16) # E: {complex128}
+reveal_type(f4 + c16) # E: {complex128}
+reveal_type(i4 + c16) # E: {complex128}
+reveal_type(b_ + c16) # E: {complex128}
+reveal_type(b + c16) # E: {complex128}
+reveal_type(c + c16) # E: {complex128}
+reveal_type(f + c16) # E: {complex128}
+reveal_type(i + c16) # E: {complex128}
reveal_type(AR + c16) # E: Any
-reveal_type(c8 + c16) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(c8 + f4) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(c8 + i4) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(c8 + b_) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(c8 + b) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(c8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + f) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + i) # E: numpy.complexfloating[numpy.typing._
+reveal_type(c8 + c16) # E: {complex128}
+reveal_type(c8 + f8) # E: {complex128}
+reveal_type(c8 + i8) # E: {complex128}
+reveal_type(c8 + c8) # E: {complex64}
+reveal_type(c8 + f4) # E: {complex64}
+reveal_type(c8 + i4) # E: {complex64}
+reveal_type(c8 + b_) # E: {complex64}
+reveal_type(c8 + b) # E: {complex64}
+reveal_type(c8 + c) # E: {complex128}
+reveal_type(c8 + f) # E: {complex128}
+reveal_type(c8 + i) # E: numpy.complexfloating[{_NBitInt}, {_NBitInt}]
reveal_type(c8 + AR) # E: Any
-reveal_type(c16 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f8 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(i8 + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(c8 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(f4 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(i4 + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(b_ + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(b + c8) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(c + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f + c8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(i + c8) # E: numpy.complexfloating[numpy.typing._
+reveal_type(c16 + c8) # E: {complex128}
+reveal_type(f8 + c8) # E: {complex128}
+reveal_type(i8 + c8) # E: {complex128}
+reveal_type(c8 + c8) # E: {complex64}
+reveal_type(f4 + c8) # E: {complex64}
+reveal_type(i4 + c8) # E: {complex64}
+reveal_type(b_ + c8) # E: {complex64}
+reveal_type(b + c8) # E: {complex64}
+reveal_type(c + c8) # E: {complex128}
+reveal_type(f + c8) # E: {complex128}
+reveal_type(i + c8) # E: numpy.complexfloating[{_NBitInt}, {_NBitInt}]
reveal_type(AR + c8) # E: Any
# Float
-reveal_type(f8 + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + i8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + f4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + i4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + b) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f8 + f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 + i) # E: numpy.floating[numpy.typing._
+reveal_type(f8 + f8) # E: {float64}
+reveal_type(f8 + i8) # E: {float64}
+reveal_type(f8 + f4) # E: {float64}
+reveal_type(f8 + i4) # E: {float64}
+reveal_type(f8 + b_) # E: {float64}
+reveal_type(f8 + b) # E: {float64}
+reveal_type(f8 + c) # E: {complex128}
+reveal_type(f8 + f) # E: {float64}
+reveal_type(f8 + i) # E: {float64}
reveal_type(f8 + AR) # E: Any
-reveal_type(f8 + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i4 + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(c + f8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i + f8) # E: numpy.floating[numpy.typing._
+reveal_type(f8 + f8) # E: {float64}
+reveal_type(i8 + f8) # E: {float64}
+reveal_type(f4 + f8) # E: {float64}
+reveal_type(i4 + f8) # E: {float64}
+reveal_type(b_ + f8) # E: {float64}
+reveal_type(b + f8) # E: {float64}
+reveal_type(c + f8) # E: {complex128}
+reveal_type(f + f8) # E: {float64}
+reveal_type(i + f8) # E: {float64}
reveal_type(AR + f8) # E: Any
-reveal_type(f4 + f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 + i8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 + f4) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(f4 + i4) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(f4 + b_) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(f4 + b) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(f4 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f4 + f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 + i) # E: numpy.floating[numpy.typing._
+reveal_type(f4 + f8) # E: {float64}
+reveal_type(f4 + i8) # E: {float64}
+reveal_type(f4 + f4) # E: {float32}
+reveal_type(f4 + i4) # E: {float32}
+reveal_type(f4 + b_) # E: {float32}
+reveal_type(f4 + b) # E: {float32}
+reveal_type(f4 + c) # E: {complex128}
+reveal_type(f4 + f) # E: {float64}
+reveal_type(f4 + i) # E: numpy.floating[{_NBitInt}]
reveal_type(f4 + AR) # E: Any
-reveal_type(f8 + f4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 + f4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 + f4) # E: umpy.floating[numpy.typing._32Bit]
-reveal_type(i4 + f4) # E: umpy.floating[numpy.typing._32Bit]
-reveal_type(b_ + f4) # E: umpy.floating[numpy.typing._32Bit]
-reveal_type(b + f4) # E: umpy.floating[numpy.typing._32Bit]
-reveal_type(c + f4) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f + f4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i + f4) # E: numpy.floating[numpy.typing._
+reveal_type(f8 + f4) # E: {float64}
+reveal_type(i8 + f4) # E: {float64}
+reveal_type(f4 + f4) # E: {float32}
+reveal_type(i4 + f4) # E: {float32}
+reveal_type(b_ + f4) # E: {float32}
+reveal_type(b + f4) # E: {float32}
+reveal_type(c + f4) # E: {complex128}
+reveal_type(f + f4) # E: {float64}
+reveal_type(i + f4) # E: numpy.floating[{_NBitInt}]
reveal_type(AR + f4) # E: Any
# Int
-reveal_type(i8 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(i8 + i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(i8 + b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 + b) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(i8 + f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 + i) # E: numpy.signedinteger[numpy.typing._
+reveal_type(i8 + i8) # E: {int64}
+reveal_type(i8 + u8) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(i8 + i4) # E: {int64}
+reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(i8 + b_) # E: {int64}
+reveal_type(i8 + b) # E: {int64}
+reveal_type(i8 + c) # E: {complex128}
+reveal_type(i8 + f) # E: {float64}
+reveal_type(i8 + i) # E: {int64}
reveal_type(i8 + AR) # E: Any
-reveal_type(u8 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 + i4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(u8 + u4) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 + b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 + b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(u8 + f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(u8 + i) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u8 + u8) # E: {uint64}
+reveal_type(u8 + i4) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(u8 + u4) # E: {uint64}
+reveal_type(u8 + b_) # E: {uint64}
+reveal_type(u8 + b) # E: {uint64}
+reveal_type(u8 + c) # E: {complex128}
+reveal_type(u8 + f) # E: {float64}
+reveal_type(u8 + i) # E: Union[numpy.signedinteger[Any], {float64}]
reveal_type(u8 + AR) # E: Any
-reveal_type(i8 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(u8 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(i4 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(b_ + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(b + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(c + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f + i8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i + i8) # E: numpy.signedinteger[numpy.typing._
+reveal_type(i8 + i8) # E: {int64}
+reveal_type(u8 + i8) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(i4 + i8) # E: {int64}
+reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(b_ + i8) # E: {int64}
+reveal_type(b + i8) # E: {int64}
+reveal_type(c + i8) # E: {complex128}
+reveal_type(f + i8) # E: {float64}
+reveal_type(i + i8) # E: {int64}
reveal_type(AR + i8) # E: Any
-reveal_type(u8 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(i4 + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(u4 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(b_ + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(b + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(c + u8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]
-reveal_type(f + u8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(u8 + u8) # E: {uint64}
+reveal_type(i4 + u8) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(u4 + u8) # E: {uint64}
+reveal_type(b_ + u8) # E: {uint64}
+reveal_type(b + u8) # E: {uint64}
+reveal_type(c + u8) # E: {complex128}
+reveal_type(f + u8) # E: {float64}
+reveal_type(i + u8) # E: Union[numpy.signedinteger[Any], {float64}]
reveal_type(AR + u8) # E: Any
-reveal_type(i4 + i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i4 + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 + i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(i4 + b_) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 + b) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i4 + i8) # E: {int64}
+reveal_type(i4 + i4) # E: {int32}
+reveal_type(i4 + i) # E: {int_}
+reveal_type(i4 + b_) # E: {int32}
+reveal_type(i4 + b) # E: {int32}
reveal_type(i4 + AR) # E: Any
-reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(u4 + i4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(u4 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u4 + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(u4 + i) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(u4 + b_) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(u4 + b) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(u4 + i4) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(u4 + u8) # E: {uint64}
+reveal_type(u4 + u4) # E: {uint32}
+reveal_type(u4 + i) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(u4 + b_) # E: {uint32}
+reveal_type(u4 + b) # E: {uint32}
reveal_type(u4 + AR) # E: Any
-reveal_type(i8 + i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i4 + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i + i4) # E: numpy.signedinteger[numpy.typing._
-reveal_type(b_ + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(b + i4) # E: numpy.signedinteger[numpy.typing._32Bit]
+reveal_type(i8 + i4) # E: {int64}
+reveal_type(i4 + i4) # E: {int32}
+reveal_type(i + i4) # E: {int_}
+reveal_type(b_ + i4) # E: {int32}
+reveal_type(b + i4) # E: {int32}
reveal_type(AR + i4) # E: Any
-reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(i4 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
-reveal_type(u8 + u4) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u4 + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(b_ + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(b + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(i + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]]
+reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(i4 + u4) # E: Union[numpy.signedinteger[Any], {float64}]
+reveal_type(u8 + u4) # E: {uint64}
+reveal_type(u4 + u4) # E: {uint32}
+reveal_type(b_ + u4) # E: {uint32}
+reveal_type(b + u4) # E: {uint32}
+reveal_type(i + u4) # E: Union[numpy.signedinteger[Any], {float64}]
reveal_type(AR + u4) # E: Any
diff --git a/numpy/typing/tests/data/reveal/bitwise_ops.py b/numpy/typing/tests/data/reveal/bitwise_ops.py
index af4924483..6b9969568 100644
--- a/numpy/typing/tests/data/reveal/bitwise_ops.py
+++ b/numpy/typing/tests/data/reveal/bitwise_ops.py
@@ -15,11 +15,11 @@ AR = np.array([0, 1, 2], dtype=np.int32)
AR.setflags(write=False)
-reveal_type(i8 << i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 >> i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 | i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 ^ i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 & i8) # E: numpy.signedinteger[numpy.typing._64Bit]
+reveal_type(i8 << i8) # E: {int64}
+reveal_type(i8 >> i8) # E: {int64}
+reveal_type(i8 | i8) # E: {int64}
+reveal_type(i8 ^ i8) # E: {int64}
+reveal_type(i8 & i8) # E: {int64}
reveal_type(i8 << AR) # E: Any
reveal_type(i8 >> AR) # E: Any
@@ -27,41 +27,41 @@ reveal_type(i8 | AR) # E: Any
reveal_type(i8 ^ AR) # E: Any
reveal_type(i8 & AR) # E: Any
-reveal_type(i4 << i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 >> i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 | i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 ^ i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 & i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-
-reveal_type(i8 << i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 >> i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 | i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 ^ i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 & i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-
-reveal_type(i8 << i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(i8 >> i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(i8 | i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(i8 ^ i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(i8 & i) # E: numpy.signedinteger[numpy.typing._
-
-reveal_type(i8 << b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 >> b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 | b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 ^ b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 & b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-
-reveal_type(i8 << b) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 >> b) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 | b) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 ^ b) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 & b) # E: numpy.signedinteger[numpy.typing._64Bit]
-
-reveal_type(u8 << u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 >> u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 | u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 ^ u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 & u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(i4 << i4) # E: {int32}
+reveal_type(i4 >> i4) # E: {int32}
+reveal_type(i4 | i4) # E: {int32}
+reveal_type(i4 ^ i4) # E: {int32}
+reveal_type(i4 & i4) # E: {int32}
+
+reveal_type(i8 << i4) # E: {int64}
+reveal_type(i8 >> i4) # E: {int64}
+reveal_type(i8 | i4) # E: {int64}
+reveal_type(i8 ^ i4) # E: {int64}
+reveal_type(i8 & i4) # E: {int64}
+
+reveal_type(i8 << i) # E: {int64}
+reveal_type(i8 >> i) # E: {int64}
+reveal_type(i8 | i) # E: {int64}
+reveal_type(i8 ^ i) # E: {int64}
+reveal_type(i8 & i) # E: {int64}
+
+reveal_type(i8 << b_) # E: {int64}
+reveal_type(i8 >> b_) # E: {int64}
+reveal_type(i8 | b_) # E: {int64}
+reveal_type(i8 ^ b_) # E: {int64}
+reveal_type(i8 & b_) # E: {int64}
+
+reveal_type(i8 << b) # E: {int64}
+reveal_type(i8 >> b) # E: {int64}
+reveal_type(i8 | b) # E: {int64}
+reveal_type(i8 ^ b) # E: {int64}
+reveal_type(i8 & b) # E: {int64}
+
+reveal_type(u8 << u8) # E: {uint64}
+reveal_type(u8 >> u8) # E: {uint64}
+reveal_type(u8 | u8) # E: {uint64}
+reveal_type(u8 ^ u8) # E: {uint64}
+reveal_type(u8 & u8) # E: {uint64}
reveal_type(u8 << AR) # E: Any
reveal_type(u8 >> AR) # E: Any
@@ -69,11 +69,11 @@ reveal_type(u8 | AR) # E: Any
reveal_type(u8 ^ AR) # E: Any
reveal_type(u8 & AR) # E: Any
-reveal_type(u4 << u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(u4 >> u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(u4 | u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(u4 ^ u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
-reveal_type(u4 & u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(u4 << u4) # E: {uint32}
+reveal_type(u4 >> u4) # E: {uint32}
+reveal_type(u4 | u4) # E: {uint32}
+reveal_type(u4 ^ u4) # E: {uint32}
+reveal_type(u4 & u4) # E: {uint32}
reveal_type(u4 << i4) # E: numpy.signedinteger[Any]
reveal_type(u4 >> i4) # E: numpy.signedinteger[Any]
@@ -87,20 +87,20 @@ reveal_type(u4 | i) # E: numpy.signedinteger[Any]
reveal_type(u4 ^ i) # E: numpy.signedinteger[Any]
reveal_type(u4 & i) # E: numpy.signedinteger[Any]
-reveal_type(u8 << b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 >> b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 | b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 ^ b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 & b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 << b_) # E: {uint64}
+reveal_type(u8 >> b_) # E: {uint64}
+reveal_type(u8 | b_) # E: {uint64}
+reveal_type(u8 ^ b_) # E: {uint64}
+reveal_type(u8 & b_) # E: {uint64}
-reveal_type(u8 << b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 >> b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 | b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 ^ b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(u8 & b) # E: numpy.unsignedinteger[numpy.typing._64Bit]
+reveal_type(u8 << b) # E: {uint64}
+reveal_type(u8 >> b) # E: {uint64}
+reveal_type(u8 | b) # E: {uint64}
+reveal_type(u8 ^ b) # E: {uint64}
+reveal_type(u8 & b) # E: {uint64}
-reveal_type(b_ << b_) # E: numpy.signedinteger[numpy.typing._8Bit]
-reveal_type(b_ >> b_) # E: numpy.signedinteger[numpy.typing._8Bit]
+reveal_type(b_ << b_) # E: {int8}
+reveal_type(b_ >> b_) # E: {int8}
reveal_type(b_ | b_) # E: numpy.bool_
reveal_type(b_ ^ b_) # E: numpy.bool_
reveal_type(b_ & b_) # E: numpy.bool_
@@ -111,21 +111,21 @@ reveal_type(b_ | AR) # E: Any
reveal_type(b_ ^ AR) # E: Any
reveal_type(b_ & AR) # E: Any
-reveal_type(b_ << b) # E: numpy.signedinteger[numpy.typing._8Bit]
-reveal_type(b_ >> b) # E: numpy.signedinteger[numpy.typing._8Bit]
+reveal_type(b_ << b) # E: {int8}
+reveal_type(b_ >> b) # E: {int8}
reveal_type(b_ | b) # E: numpy.bool_
reveal_type(b_ ^ b) # E: numpy.bool_
reveal_type(b_ & b) # E: numpy.bool_
-reveal_type(b_ << i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(b_ >> i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(b_ | i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(b_ ^ i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(b_ & i) # E: numpy.signedinteger[numpy.typing._
+reveal_type(b_ << i) # E: {int_}
+reveal_type(b_ >> i) # E: {int_}
+reveal_type(b_ | i) # E: {int_}
+reveal_type(b_ ^ i) # E: {int_}
+reveal_type(b_ & i) # E: {int_}
-reveal_type(~i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(~i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(~u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(~u4) # E: numpy.unsignedinteger[numpy.typing._32Bit]
+reveal_type(~i8) # E: {int64}
+reveal_type(~i4) # E: {int32}
+reveal_type(~u8) # E: {uint64}
+reveal_type(~u4) # E: {uint32}
reveal_type(~b_) # E: numpy.bool_
reveal_type(~AR) # E: Any
diff --git a/numpy/typing/tests/data/reveal/dtype.py b/numpy/typing/tests/data/reveal/dtype.py
index f786637dc..b30a0ad6e 100644
--- a/numpy/typing/tests/data/reveal/dtype.py
+++ b/numpy/typing/tests/data/reveal/dtype.py
@@ -2,31 +2,31 @@ import numpy as np
dtype_obj: np.dtype[np.str_]
-reveal_type(np.dtype(np.float64)) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
-reveal_type(np.dtype(np.int64)) # E: numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]
+reveal_type(np.dtype(np.float64)) # E: numpy.dtype[{float64}]
+reveal_type(np.dtype(np.int64)) # E: numpy.dtype[{int64}]
# String aliases
-reveal_type(np.dtype("float64")) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
-reveal_type(np.dtype("float32")) # E: numpy.dtype[numpy.floating[numpy.typing._32Bit]]
-reveal_type(np.dtype("int64")) # E: numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(np.dtype("int32")) # E: numpy.dtype[numpy.signedinteger[numpy.typing._32Bit]]
+reveal_type(np.dtype("float64")) # E: numpy.dtype[{float64}]
+reveal_type(np.dtype("float32")) # E: numpy.dtype[{float32}]
+reveal_type(np.dtype("int64")) # E: numpy.dtype[{int64}]
+reveal_type(np.dtype("int32")) # E: numpy.dtype[{int32}]
reveal_type(np.dtype("bool")) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype("bytes")) # E: numpy.dtype[numpy.bytes_]
reveal_type(np.dtype("str")) # E: numpy.dtype[numpy.str_]
# Python types
-reveal_type(np.dtype(complex)) # E: numpy.dtype[numpy.complexfloating[numpy.typing._
-reveal_type(np.dtype(float)) # E: numpy.dtype[numpy.floating[numpy.typing._
-reveal_type(np.dtype(int)) # E: numpy.dtype[numpy.signedinteger[numpy.typing._
+reveal_type(np.dtype(complex)) # E: numpy.dtype[{cdouble}]
+reveal_type(np.dtype(float)) # E: numpy.dtype[{double}]
+reveal_type(np.dtype(int)) # E: numpy.dtype[{int_}]
reveal_type(np.dtype(bool)) # E: numpy.dtype[numpy.bool_]
reveal_type(np.dtype(str)) # E: numpy.dtype[numpy.str_]
reveal_type(np.dtype(bytes)) # E: numpy.dtype[numpy.bytes_]
# Special case for None
-reveal_type(np.dtype(None)) # E: numpy.dtype[numpy.floating[numpy.typing._
+reveal_type(np.dtype(None)) # E: numpy.dtype[{double}]
# Dtypes of dtypes
-reveal_type(np.dtype(np.dtype(np.float64))) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
+reveal_type(np.dtype(np.dtype(np.float64))) # E: numpy.dtype[{float64}]
# Parameterized dtypes
reveal_type(np.dtype("S8")) # E: numpy.dtype
diff --git a/numpy/typing/tests/data/reveal/fromnumeric.py b/numpy/typing/tests/data/reveal/fromnumeric.py
index 2d823b2e2..2b58f019f 100644
--- a/numpy/typing/tests/data/reveal/fromnumeric.py
+++ b/numpy/typing/tests/data/reveal/fromnumeric.py
@@ -13,7 +13,7 @@ c = 1.0
d = np.array(1.0, dtype=np.float32) # writeable
reveal_type(np.take(a, 0)) # E: numpy.bool_
-reveal_type(np.take(b, 0)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.take(b, 0)) # E: {float32}
reveal_type(
np.take(c, 0) # E: Union[numpy.generic, datetime.datetime, datetime.timedelta]
)
@@ -66,8 +66,8 @@ reveal_type(np.partition(c, 0, axis=None)) # E: numpy.ndarray[Any, Any]
reveal_type(np.partition(A, 0)) # E: numpy.ndarray[Any, Any]
reveal_type(np.partition(B, 0)) # E: numpy.ndarray[Any, Any]
-reveal_type(np.argpartition(a, 0)) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.argpartition(b, 0)) # E: numpy.signedinteger[numpy.typing._
+reveal_type(np.argpartition(a, 0)) # E: {intp}
+reveal_type(np.argpartition(b, 0)) # E: {intp}
reveal_type(np.argpartition(c, 0)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argpartition(A, 0)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argpartition(B, 0)) # E: numpy.ndarray[Any, Any]
@@ -78,18 +78,18 @@ reveal_type(np.sort(B, 0)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argsort(A, 0)) # E: numpy.ndarray[Any, Any]
reveal_type(np.argsort(B, 0)) # E: numpy.ndarray[Any, Any]
-reveal_type(np.argmax(A)) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.argmax(B)) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.argmax(A, axis=0)) # E: Union[numpy.ndarray[Any, Any], numpy.signedinteger[numpy.typing._
-reveal_type(np.argmax(B, axis=0)) # E: Union[numpy.ndarray[Any, Any], numpy.signedinteger[numpy.typing._
+reveal_type(np.argmax(A)) # E: {intp}
+reveal_type(np.argmax(B)) # E: {intp}
+reveal_type(np.argmax(A, axis=0)) # E: Union[numpy.ndarray[Any, Any], {intp}]
+reveal_type(np.argmax(B, axis=0)) # E: Union[numpy.ndarray[Any, Any], {intp}]
-reveal_type(np.argmin(A)) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.argmin(B)) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.argmin(A, axis=0)) # E: Union[numpy.ndarray[Any, Any], numpy.signedinteger[numpy.typing._
-reveal_type(np.argmin(B, axis=0)) # E: Union[numpy.ndarray[Any, Any], numpy.signedinteger[numpy.typing._
+reveal_type(np.argmin(A)) # E: {intp}
+reveal_type(np.argmin(B)) # E: {intp}
+reveal_type(np.argmin(A, axis=0)) # E: Union[numpy.ndarray[Any, Any], {intp}]
+reveal_type(np.argmin(B, axis=0)) # E: Union[numpy.ndarray[Any, Any], {intp}]
-reveal_type(np.searchsorted(A[0], 0)) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.searchsorted(B[0], 0)) # E: numpy.signedinteger[numpy.typing._
+reveal_type(np.searchsorted(A[0], 0)) # E: {intp}
+reveal_type(np.searchsorted(B[0], 0)) # E: {intp}
reveal_type(np.searchsorted(A[0], [0])) # E: numpy.ndarray[Any, Any]
reveal_type(np.searchsorted(B[0], [0])) # E: numpy.ndarray[Any, Any]
@@ -100,7 +100,7 @@ reveal_type(np.resize(A, (5, 5))) # E: numpy.ndarray[Any, Any]
reveal_type(np.resize(B, (5, 5))) # E: numpy.ndarray[Any, Any]
reveal_type(np.squeeze(a)) # E: numpy.bool_
-reveal_type(np.squeeze(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.squeeze(b)) # E: {float32}
reveal_type(np.squeeze(c)) # E: numpy.ndarray[Any, Any]
reveal_type(np.squeeze(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.squeeze(B)) # E: numpy.ndarray[Any, Any]
@@ -136,13 +136,13 @@ reveal_type(np.compress([True], A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.compress([True], B)) # E: numpy.ndarray[Any, Any]
reveal_type(np.clip(a, 0, 1.0)) # E: numpy.number[Any]
-reveal_type(np.clip(b, -1, 1)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.clip(b, -1, 1)) # E: {float32}
reveal_type(np.clip(c, 0, 1)) # E: numpy.number[Any]
reveal_type(np.clip(A, 0, 1)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(np.clip(B, 0, 1)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(np.sum(a)) # E: numpy.number[Any]
-reveal_type(np.sum(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.sum(b)) # E: {float32}
reveal_type(np.sum(c)) # E: numpy.number[Any]
reveal_type(np.sum(A)) # E: numpy.number[Any]
reveal_type(np.sum(B)) # E: numpy.number[Any]
@@ -176,7 +176,7 @@ reveal_type(np.cumsum(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.cumsum(B)) # E: numpy.ndarray[Any, Any]
reveal_type(np.ptp(a)) # E: numpy.number[Any]
-reveal_type(np.ptp(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.ptp(b)) # E: {float32}
reveal_type(np.ptp(c)) # E: numpy.number[Any]
reveal_type(np.ptp(A)) # E: numpy.number[Any]
reveal_type(np.ptp(B)) # E: numpy.number[Any]
@@ -186,7 +186,7 @@ reveal_type(np.ptp(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarr
reveal_type(np.ptp(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(np.amax(a)) # E: numpy.number[Any]
-reveal_type(np.amax(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.amax(b)) # E: {float32}
reveal_type(np.amax(c)) # E: numpy.number[Any]
reveal_type(np.amax(A)) # E: numpy.number[Any]
reveal_type(np.amax(B)) # E: numpy.number[Any]
@@ -196,7 +196,7 @@ reveal_type(np.amax(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndar
reveal_type(np.amax(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(np.amin(a)) # E: numpy.number[Any]
-reveal_type(np.amin(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.amin(b)) # E: {float32}
reveal_type(np.amin(c)) # E: numpy.number[Any]
reveal_type(np.amin(A)) # E: numpy.number[Any]
reveal_type(np.amin(B)) # E: numpy.number[Any]
@@ -206,7 +206,7 @@ reveal_type(np.amin(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndar
reveal_type(np.amin(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(np.prod(a)) # E: numpy.number[Any]
-reveal_type(np.prod(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.prod(b)) # E: {float32}
reveal_type(np.prod(c)) # E: numpy.number[Any]
reveal_type(np.prod(A)) # E: numpy.number[Any]
reveal_type(np.prod(B)) # E: numpy.number[Any]
@@ -236,7 +236,7 @@ reveal_type(np.size(A)) # E: int
reveal_type(np.size(B)) # E: int
reveal_type(np.around(a)) # E: numpy.number[Any]
-reveal_type(np.around(b)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(np.around(b)) # E: {float32}
reveal_type(np.around(c)) # E: numpy.number[Any]
reveal_type(np.around(A)) # E: numpy.ndarray[Any, Any]
reveal_type(np.around(B)) # E: numpy.ndarray[Any, Any]
diff --git a/numpy/typing/tests/data/reveal/mod.py b/numpy/typing/tests/data/reveal/mod.py
index 3330cf175..989ef99fd 100644
--- a/numpy/typing/tests/data/reveal/mod.py
+++ b/numpy/typing/tests/data/reveal/mod.py
@@ -27,123 +27,123 @@ reveal_type(td % td) # E: numpy.timedelta64
reveal_type(AR2 % td) # E: Any
reveal_type(td % AR2) # E: Any
-reveal_type(divmod(td, td)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.timedelta64]
+reveal_type(divmod(td, td)) # E: Tuple[{int64}, numpy.timedelta64]
reveal_type(divmod(AR2, td)) # E: Tuple[Any, Any]
reveal_type(divmod(td, AR2)) # E: Tuple[Any, Any]
# Bool
-reveal_type(b_ % b) # E: numpy.signedinteger[numpy.typing._8Bit]
-reveal_type(b_ % i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(b_ % f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ % b_) # E: numpy.signedinteger[numpy.typing._8Bit]
-reveal_type(b_ % i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(b_ % u8) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(b_ % f8) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b_ % b) # E: {int8}
+reveal_type(b_ % i) # E: {int_}
+reveal_type(b_ % f) # E: {float64}
+reveal_type(b_ % b_) # E: {int8}
+reveal_type(b_ % i8) # E: {int64}
+reveal_type(b_ % u8) # E: {uint64}
+reveal_type(b_ % f8) # E: {float64}
reveal_type(b_ % AR) # E: Any
-reveal_type(divmod(b_, b)) # E: Tuple[numpy.signedinteger[numpy.typing._8Bit], numpy.signedinteger[numpy.typing._8Bit]]
-reveal_type(divmod(b_, i)) # E: Tuple[numpy.signedinteger[numpy.typing._
-reveal_type(divmod(b_, f)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(b_, b_)) # E: Tuple[numpy.signedinteger[numpy.typing._8Bit], numpy.signedinteger[numpy.typing._8Bit]]
-reveal_type(divmod(b_, i8)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(b_, u8)) # E: Tuple[numpy.unsignedinteger[numpy.typing._64Bit], numpy.unsignedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(b_, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
+reveal_type(divmod(b_, b)) # E: Tuple[{int8}, {int8}]
+reveal_type(divmod(b_, i)) # E: Tuple[{int_}, {int_}]
+reveal_type(divmod(b_, f)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(b_, b_)) # E: Tuple[{int8}, {int8}]
+reveal_type(divmod(b_, i8)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(b_, u8)) # E: Tuple[{uint64}, {uint64}]
+reveal_type(divmod(b_, f8)) # E: Tuple[{float64}, {float64}]
reveal_type(divmod(b_, AR)) # E: Tuple[Any, Any]
-reveal_type(b % b_) # E: numpy.signedinteger[numpy.typing._8Bit]
-reveal_type(i % b_) # E: numpy.signedinteger[numpy.typing._
-reveal_type(f % b_) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(b_ % b_) # E: numpy.signedinteger[numpy.typing._8Bit]
-reveal_type(i8 % b_) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(u8 % b_) # E: numpy.unsignedinteger[numpy.typing._64Bit]
-reveal_type(f8 % b_) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(b % b_) # E: {int8}
+reveal_type(i % b_) # E: {int_}
+reveal_type(f % b_) # E: {float64}
+reveal_type(b_ % b_) # E: {int8}
+reveal_type(i8 % b_) # E: {int64}
+reveal_type(u8 % b_) # E: {uint64}
+reveal_type(f8 % b_) # E: {float64}
reveal_type(AR % b_) # E: Any
-reveal_type(divmod(b, b_)) # E: Tuple[numpy.signedinteger[numpy.typing._8Bit], numpy.signedinteger[numpy.typing._8Bit]]
-reveal_type(divmod(i, b_)) # E: Tuple[numpy.signedinteger[numpy.typing._
-reveal_type(divmod(f, b_)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(b_, b_)) # E: Tuple[numpy.signedinteger[numpy.typing._8Bit], numpy.signedinteger[numpy.typing._8Bit]]
-reveal_type(divmod(i8, b_)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(u8, b_)) # E: Tuple[numpy.unsignedinteger[numpy.typing._64Bit], numpy.unsignedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(f8, b_)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
+reveal_type(divmod(b, b_)) # E: Tuple[{int8}, {int8}]
+reveal_type(divmod(i, b_)) # E: Tuple[{int_}, {int_}]
+reveal_type(divmod(f, b_)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(b_, b_)) # E: Tuple[{int8}, {int8}]
+reveal_type(divmod(i8, b_)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(u8, b_)) # E: Tuple[{uint64}, {uint64}]
+reveal_type(divmod(f8, b_)) # E: Tuple[{float64}, {float64}]
reveal_type(divmod(AR, b_)) # E: Tuple[Any, Any]
# int
-reveal_type(i8 % b) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 % i) # E: numpy.signedinteger[numpy.typing._
-reveal_type(i8 % f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 % i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i8 % f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i4 % i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i4 % f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i4 % i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(i4 % f4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(i8 % b) # E: {int64}
+reveal_type(i8 % i) # E: {int64}
+reveal_type(i8 % f) # E: {float64}
+reveal_type(i8 % i8) # E: {int64}
+reveal_type(i8 % f8) # E: {float64}
+reveal_type(i4 % i8) # E: {int64}
+reveal_type(i4 % f8) # E: {float64}
+reveal_type(i4 % i4) # E: {int32}
+reveal_type(i4 % f4) # E: {float32}
reveal_type(i8 % AR) # E: Any
-reveal_type(divmod(i8, b)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(i8, i)) # E: Tuple[numpy.signedinteger[numpy.typing._
-reveal_type(divmod(i8, f)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i8, i8)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(i8, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i8, i4)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(i8, f4)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i4, i4)) # E: Tuple[numpy.signedinteger[numpy.typing._32Bit], numpy.signedinteger[numpy.typing._32Bit]]
-reveal_type(divmod(i4, f4)) # E: Tuple[numpy.floating[numpy.typing._32Bit], numpy.floating[numpy.typing._32Bit]]
+reveal_type(divmod(i8, b)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(i8, i)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(i8, f)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i8, i8)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(i8, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i8, i4)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(i8, f4)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i4, i4)) # E: Tuple[{int32}, {int32}]
+reveal_type(divmod(i4, f4)) # E: Tuple[{float32}, {float32}]
reveal_type(divmod(i8, AR)) # E: Tuple[Any, Any]
-reveal_type(b % i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(i % i8) # E: numpy.signedinteger[numpy.typing._
-reveal_type(f % i8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 % i8) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(f8 % i8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 % i4) # E: numpy.signedinteger[numpy.typing._64Bit]
-reveal_type(f8 % i4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i4 % i4) # E: numpy.signedinteger[numpy.typing._32Bit]
-reveal_type(f4 % i4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(b % i8) # E: {int64}
+reveal_type(i % i8) # E: {int64}
+reveal_type(f % i8) # E: {float64}
+reveal_type(i8 % i8) # E: {int64}
+reveal_type(f8 % i8) # E: {float64}
+reveal_type(i8 % i4) # E: {int64}
+reveal_type(f8 % i4) # E: {float64}
+reveal_type(i4 % i4) # E: {int32}
+reveal_type(f4 % i4) # E: {float32}
reveal_type(AR % i8) # E: Any
-reveal_type(divmod(b, i8)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(i, i8)) # E: Tuple[numpy.signedinteger[numpy.typing._
-reveal_type(divmod(f, i8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i8, i8)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(f8, i8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i4, i8)) # E: Tuple[numpy.signedinteger[numpy.typing._64Bit], numpy.signedinteger[numpy.typing._64Bit]]
-reveal_type(divmod(f4, i8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i4, i4)) # E: Tuple[numpy.signedinteger[numpy.typing._32Bit], numpy.signedinteger[numpy.typing._32Bit]]
-reveal_type(divmod(f4, i4)) # E: Tuple[numpy.floating[numpy.typing._32Bit], numpy.floating[numpy.typing._32Bit]]
+reveal_type(divmod(b, i8)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(i, i8)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(f, i8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i8, i8)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(f8, i8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i4, i8)) # E: Tuple[{int64}, {int64}]
+reveal_type(divmod(f4, i8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i4, i4)) # E: Tuple[{int32}, {int32}]
+reveal_type(divmod(f4, i4)) # E: Tuple[{float32}, {float32}]
reveal_type(divmod(AR, i8)) # E: Tuple[Any, Any]
# float
-reveal_type(f8 % b) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 % i) # E: numpy.floating[numpy.typing._
-reveal_type(f8 % f) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i8 % f4) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 % f4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(f8 % b) # E: {float64}
+reveal_type(f8 % i) # E: {float64}
+reveal_type(f8 % f) # E: {float64}
+reveal_type(i8 % f4) # E: {float64}
+reveal_type(f4 % f4) # E: {float32}
reveal_type(f8 % AR) # E: Any
-reveal_type(divmod(f8, b)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f8, i)) # E: Tuple[numpy.floating[numpy.typing._
-reveal_type(divmod(f8, f)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f8, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f8, f4)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f4, f4)) # E: Tuple[numpy.floating[numpy.typing._32Bit], numpy.floating[numpy.typing._32Bit]]
+reveal_type(divmod(f8, b)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f8, i)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f8, f)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f8, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f8, f4)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f4, f4)) # E: Tuple[{float32}, {float32}]
reveal_type(divmod(f8, AR)) # E: Tuple[Any, Any]
-reveal_type(b % f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(i % f8) # E: numpy.floating[numpy.typing._
-reveal_type(f % f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 % f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f8 % f8) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(f4 % f4) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(b % f8) # E: {float64}
+reveal_type(i % f8) # E: {float64}
+reveal_type(f % f8) # E: {float64}
+reveal_type(f8 % f8) # E: {float64}
+reveal_type(f8 % f8) # E: {float64}
+reveal_type(f4 % f4) # E: {float32}
reveal_type(AR % f8) # E: Any
-reveal_type(divmod(b, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(i, f8)) # E: Tuple[numpy.floating[numpy.typing._
-reveal_type(divmod(f, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f8, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f4, f8)) # E: Tuple[numpy.floating[numpy.typing._64Bit], numpy.floating[numpy.typing._64Bit]]
-reveal_type(divmod(f4, f4)) # E: Tuple[numpy.floating[numpy.typing._32Bit], numpy.floating[numpy.typing._32Bit]]
+reveal_type(divmod(b, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(i, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f8, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f4, f8)) # E: Tuple[{float64}, {float64}]
+reveal_type(divmod(f4, f4)) # E: Tuple[{float32}, {float32}]
reveal_type(divmod(AR, f8)) # E: Tuple[Any, Any]
diff --git a/numpy/typing/tests/data/reveal/nbit_base_example.py b/numpy/typing/tests/data/reveal/nbit_base_example.py
index 0c4c53f9b..99fb71560 100644
--- a/numpy/typing/tests/data/reveal/nbit_base_example.py
+++ b/numpy/typing/tests/data/reveal/nbit_base_example.py
@@ -12,7 +12,7 @@ i4: np.int32
f8: np.float64
f4: np.float32
-reveal_type(add(f8, i8)) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(add(f4, i8)) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(add(f8, i4)) # E: numpy.floating[numpy.typing._64Bit]
-reveal_type(add(f4, i4)) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(add(f8, i8)) # E: {float64}
+reveal_type(add(f4, i8)) # E: {float64}
+reveal_type(add(f8, i4)) # E: {float64}
+reveal_type(add(f4, i4)) # E: {float32}
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.py b/numpy/typing/tests/data/reveal/ndarray_misc.py
index df6cd4586..0f7345358 100644
--- a/numpy/typing/tests/data/reveal/ndarray_misc.py
+++ b/numpy/typing/tests/data/reveal/ndarray_misc.py
@@ -26,14 +26,14 @@ reveal_type(A.any(axis=0)) # E: Union[numpy.bool_, numpy.ndarray[Any, Any]]
reveal_type(A.any(keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray[Any, Any]]
reveal_type(A.any(out=B)) # E: SubClass
-reveal_type(f8.argmax()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(A.argmax()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(A.argmax(axis=0)) # E: Union[numpy.ndarray[Any, Any], numpy.signedinteger[numpy.typing._
+reveal_type(f8.argmax()) # E: {intp}
+reveal_type(A.argmax()) # E: {intp}
+reveal_type(A.argmax(axis=0)) # E: Union[numpy.ndarray[Any, Any], {intp}]
reveal_type(A.argmax(out=B)) # E: SubClass
-reveal_type(f8.argmin()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(A.argmin()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(A.argmin(axis=0)) # E: Union[numpy.ndarray[Any, Any], numpy.signedinteger[numpy.typing._
+reveal_type(f8.argmin()) # E: {intp}
+reveal_type(A.argmin()) # E: {intp}
+reveal_type(A.argmin(axis=0)) # E: Union[numpy.ndarray[Any, Any], {intp}]
reveal_type(A.argmin(out=B)) # E: SubClass
reveal_type(f8.argsort()) # E: numpy.ndarray[Any, Any]
@@ -53,11 +53,11 @@ reveal_type(f8.compress([0])) # E: numpy.ndarray[Any, Any]
reveal_type(A.compress([0])) # E: numpy.ndarray[Any, Any]
reveal_type(A.compress([0], out=B)) # E: SubClass
-reveal_type(f8.conj()) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8.conj()) # E: {float64}
reveal_type(A.conj()) # E: numpy.ndarray[Any, Any]
reveal_type(B.conj()) # E: SubClass
-reveal_type(f8.conjugate()) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8.conjugate()) # E: {float64}
reveal_type(A.conjugate()) # E: numpy.ndarray[Any, Any]
reveal_type(B.conjugate()) # E: SubClass
@@ -87,7 +87,7 @@ reveal_type(A.min(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any
reveal_type(A.min(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(A.min(out=B)) # E: SubClass
-reveal_type(f8.newbyteorder()) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8.newbyteorder()) # E: {float64}
reveal_type(A.newbyteorder()) # E: numpy.ndarray[Any, Any]
reveal_type(B.newbyteorder('|')) # E: SubClass
@@ -103,7 +103,7 @@ reveal_type(A.ptp(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any
reveal_type(A.ptp(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray[Any, Any]]
reveal_type(A.ptp(out=B)) # E: SubClass
-reveal_type(f8.round()) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(f8.round()) # E: {float64}
reveal_type(A.round()) # E: numpy.ndarray[Any, Any]
reveal_type(A.round(out=B)) # E: SubClass
diff --git a/numpy/typing/tests/data/reveal/scalars.py b/numpy/typing/tests/data/reveal/scalars.py
index 841b1473d..faa7ac3d2 100644
--- a/numpy/typing/tests/data/reveal/scalars.py
+++ b/numpy/typing/tests/data/reveal/scalars.py
@@ -2,11 +2,11 @@ import numpy as np
x = np.complex64(3 + 2j)
-reveal_type(x.real) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(x.imag) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(x.real) # E: {float32}
+reveal_type(x.imag) # E: {float32}
-reveal_type(x.real.real) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(x.real.imag) # E: numpy.floating[numpy.typing._32Bit]
+reveal_type(x.real.real) # E: {float32}
+reveal_type(x.real.imag) # E: {float32}
reveal_type(x.itemsize) # E: int
reveal_type(x.shape) # E: Tuple[]
@@ -15,14 +15,14 @@ reveal_type(x.strides) # E: Tuple[]
reveal_type(x.ndim) # E: Literal[0]
reveal_type(x.size) # E: Literal[1]
-reveal_type(x.squeeze()) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(x.byteswap()) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
-reveal_type(x.transpose()) # E: numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]
+reveal_type(x.squeeze()) # E: {complex64}
+reveal_type(x.byteswap()) # E: {complex64}
+reveal_type(x.transpose()) # E: {complex64}
-reveal_type(x.dtype) # E: numpy.dtype[numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]]
+reveal_type(x.dtype) # E: numpy.dtype[{complex64}]
-reveal_type(np.complex64().real) # E: numpy.floating[numpy.typing._32Bit]
-reveal_type(np.complex128().imag) # E: numpy.floating[numpy.typing._64Bit]
+reveal_type(np.complex64().real) # E: {float32}
+reveal_type(np.complex128().imag) # E: {float64}
reveal_type(np.unicode_('foo')) # E: numpy.str_
reveal_type(np.str0('foo')) # E: numpy.str_
@@ -31,34 +31,34 @@ reveal_type(np.str0('foo')) # E: numpy.str_
reveal_type(np.unicode_()) # E: numpy.str_
reveal_type(np.str0()) # E: numpy.str_
-reveal_type(np.byte()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.short()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.intc()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.intp()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.int0()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.int_()) # E: numpy.signedinteger[numpy.typing._
-reveal_type(np.longlong()) # E: numpy.signedinteger[numpy.typing._
+reveal_type(np.byte()) # E: {byte}
+reveal_type(np.short()) # E: {short}
+reveal_type(np.intc()) # E: {intc}
+reveal_type(np.intp()) # E: {intp}
+reveal_type(np.int0()) # E: {intp}
+reveal_type(np.int_()) # E: {int_}
+reveal_type(np.longlong()) # E: {longlong}
-reveal_type(np.ubyte()) # E: numpy.unsignedinteger[numpy.typing._
-reveal_type(np.ushort()) # E: numpy.unsignedinteger[numpy.typing._
-reveal_type(np.uintc()) # E: numpy.unsignedinteger[numpy.typing._
-reveal_type(np.uintp()) # E: numpy.unsignedinteger[numpy.typing._
-reveal_type(np.uint0()) # E: numpy.unsignedinteger[numpy.typing._
-reveal_type(np.uint()) # E: numpy.unsignedinteger[numpy.typing._
-reveal_type(np.ulonglong()) # E: numpy.unsignedinteger[numpy.typing._
+reveal_type(np.ubyte()) # E: {ubyte}
+reveal_type(np.ushort()) # E: {ushort}
+reveal_type(np.uintc()) # E: {uintc}
+reveal_type(np.uintp()) # E: {uintp}
+reveal_type(np.uint0()) # E: {uintp}
+reveal_type(np.uint()) # E: {uint}
+reveal_type(np.ulonglong()) # E: {ulonglong}
-reveal_type(np.half()) # E: numpy.floating[numpy.typing._
-reveal_type(np.single()) # E: numpy.floating[numpy.typing._
-reveal_type(np.double()) # E: numpy.floating[numpy.typing._
-reveal_type(np.float_()) # E: numpy.floating[numpy.typing._
-reveal_type(np.longdouble()) # E: numpy.floating[numpy.typing._
-reveal_type(np.longfloat()) # E: numpy.floating[numpy.typing._
+reveal_type(np.half()) # E: {half}
+reveal_type(np.single()) # E: {single}
+reveal_type(np.double()) # E: {double}
+reveal_type(np.float_()) # E: {double}
+reveal_type(np.longdouble()) # E: {longdouble}
+reveal_type(np.longfloat()) # E: {longdouble}
-reveal_type(np.csingle()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.singlecomplex()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.cdouble()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.complex_()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.cfloat()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.clongdouble()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.clongfloat()) # E: numpy.complexfloating[numpy.typing._
-reveal_type(np.longcomplex()) # E: numpy.complexfloating[numpy.typing._
+reveal_type(np.csingle()) # E: {csingle}
+reveal_type(np.singlecomplex()) # E: {csingle}
+reveal_type(np.cdouble()) # E: {cdouble}
+reveal_type(np.complex_()) # E: {cdouble}
+reveal_type(np.cfloat()) # E: {cdouble}
+reveal_type(np.clongdouble()) # E: {clongdouble}
+reveal_type(np.clongfloat()) # E: {clongdouble}
+reveal_type(np.longcomplex()) # E: {clongdouble}
diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py
index 90de4fd6d..361688c5d 100644
--- a/numpy/typing/tests/test_typing.py
+++ b/numpy/typing/tests/test_typing.py
@@ -3,9 +3,12 @@ import itertools
import os
import re
from collections import defaultdict
-from typing import Optional
+from typing import Optional, IO, Dict, List
import pytest
+import numpy as np
+from numpy.typing.mypy_plugin import _PRECISION_DICT
+
try:
from mypy import api
except ImportError:
@@ -123,6 +126,79 @@ def _test_fail(path: str, error: str, expected_error: Optional[str], lineno: int
raise AssertionError(_FAIL_MSG2.format(lineno, expected_error, error))
+def _construct_format_dict():
+ dct = {k.split(".")[-1]: v.replace("numpy", "numpy.typing") for
+ k, v in _PRECISION_DICT.items()}
+
+ return {
+ "uint8": "numpy.unsignedinteger[numpy.typing._8Bit]",
+ "uint16": "numpy.unsignedinteger[numpy.typing._16Bit]",
+ "uint32": "numpy.unsignedinteger[numpy.typing._32Bit]",
+ "uint64": "numpy.unsignedinteger[numpy.typing._64Bit]",
+ "int8": "numpy.signedinteger[numpy.typing._8Bit]",
+ "int16": "numpy.signedinteger[numpy.typing._16Bit]",
+ "int32": "numpy.signedinteger[numpy.typing._32Bit]",
+ "int64": "numpy.signedinteger[numpy.typing._64Bit]",
+ "float16": "numpy.floating[numpy.typing._16Bit]",
+ "float32": "numpy.floating[numpy.typing._32Bit]",
+ "float64": "numpy.floating[numpy.typing._64Bit]",
+ "complex64": "numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]",
+ "complex128": "numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit]",
+
+ "ubyte": f"numpy.unsignedinteger[{dct['_NBitByte']}]",
+ "ushort": f"numpy.unsignedinteger[{dct['_NBitShort']}]",
+ "uintc": f"numpy.unsignedinteger[{dct['_NBitIntC']}]",
+ "uintp": f"numpy.unsignedinteger[{dct['_NBitIntP']}]",
+ "uint": f"numpy.unsignedinteger[{dct['_NBitInt']}]",
+ "ulonglong": f"numpy.unsignedinteger[{dct['_NBitLongLong']}]",
+ "byte": f"numpy.signedinteger[{dct['_NBitByte']}]",
+ "short": f"numpy.signedinteger[{dct['_NBitShort']}]",
+ "intc": f"numpy.signedinteger[{dct['_NBitIntC']}]",
+ "intp": f"numpy.signedinteger[{dct['_NBitIntP']}]",
+ "int_": f"numpy.signedinteger[{dct['_NBitInt']}]",
+ "longlong": f"numpy.signedinteger[{dct['_NBitLongLong']}]",
+
+ "half": f"numpy.floating[{dct['_NBitHalf']}]",
+ "single": f"numpy.floating[{dct['_NBitSingle']}]",
+ "double": f"numpy.floating[{dct['_NBitDouble']}]",
+ "longdouble": f"numpy.floating[{dct['_NBitLongDouble']}]",
+ "csingle": f"numpy.complexfloating[{dct['_NBitSingle']}, {dct['_NBitSingle']}]",
+ "cdouble": f"numpy.complexfloating[{dct['_NBitDouble']}, {dct['_NBitDouble']}]",
+ "clongdouble": f"numpy.complexfloating[{dct['_NBitLongDouble']}, {dct['_NBitLongDouble']}]",
+
+ # numpy.typing
+ "_NBitInt": dct['_NBitInt'],
+ }
+
+
+#: A dictionary with all supported format keys (as keys)
+#: and matching values
+FORMAT_DICT: Dict[str, str] = _construct_format_dict()
+
+
+def _parse_reveals(file: IO[str]) -> List[str]:
+ """Extract and parse all ``" # E: "`` comments from the passed file-like object.
+
+ All format keys will be substituted for their respective value from `FORMAT_DICT`,
+ *e.g.* ``"{float64}"`` becomes ``"numpy.floating[numpy.typing._64Bit]"``.
+ """
+ string = file.read().replace("*", "")
+
+ # Grab all `# E:`-based comments
+ comments_array = np.char.partition(string.split("\n"), sep=" # E: ")[:, 2]
+ comments = "/n".join(comments_array)
+
+ # Only search for the `{*}` pattern within comments,
+ # otherwise there is the risk of accidently grabbing dictionaries and sets
+ key_set = set(re.findall(r"\{(.*?)\}", comments))
+ kwargs = {
+ k: FORMAT_DICT.get(k, f"<UNRECOGNIZED FORMAT KEY {k!r}>") for k in key_set
+ }
+ fmt_str = comments.format(**kwargs)
+
+ return fmt_str.split("/n")
+
+
@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason="Mypy is not installed")
@pytest.mark.parametrize("path", get_test_cases(REVEAL_DIR))
@@ -138,7 +214,7 @@ def test_reveal(path):
])
with open(path) as fin:
- lines = fin.read().replace('*', '').split("\n")
+ lines = _parse_reveals(fin)
stdout_list = stdout.replace('*', '').split("\n")
for error_line in stdout_list:
@@ -155,7 +231,7 @@ def test_reveal(path):
lineno = int(match.group('lineno')) - 1
assert "Revealed type is" in error_line
- marker = lines[lineno].split("# E:")[-1].strip()
+ marker = lines[lineno]
_test_reveal(path, marker, error_line, 1 + lineno)