Search is not available for this dataset
repo_id
stringlengths
12
110
file_path
stringlengths
24
164
content
stringlengths
3
89.3M
__index_level_0__
int64
0
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/tests/test_ccompiler_opt.py
import re, textwrap, os from os import sys, path from distutils.errors import DistutilsError is_standalone = __name__ == '__main__' and __package__ is None if is_standalone: import unittest, contextlib, tempfile, shutil sys.path.append(path.abspath(path.join(path.dirname(__file__), ".."))) from ccompiler_o...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/tests/test_ccompiler_opt_conf.py
import unittest from os import sys, path is_standalone = __name__ == '__main__' and __package__ is None if is_standalone: sys.path.append(path.abspath(path.join(path.dirname(__file__), ".."))) from ccompiler_opt import CCompilerOpt else: from numpy.distutils.ccompiler_opt import CCompilerOpt arch_compiler...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/tests/test_fcompiler_gnu.py
from numpy.testing import assert_ import numpy.distutils.fcompiler g77_version_strings = [ ('GNU Fortran 0.5.25 20010319 (prerelease)', '0.5.25'), ('GNU Fortran (GCC 3.2) 3.2 20020814 (release)', '3.2'), ('GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)', '3.3.3'), ('GNU Fortran (GCC) 3.3.3 (De...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/mingw/gfortran_vs2003_hack.c
int _get_output_format(void) { return 0; } int _imp____lc_codepage = 0;
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_popcnt.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/extra_avx512f_reduce.c
#include <immintrin.h> /** * The following intrinsics don't have direct native support but compilers * tend to emulate them. * They're usually supported by gcc >= 7.1, clang >= 4 and icc >= 19 */ int main(void) { __m512 one_ps = _mm512_set1_ps(1.0f); __m512d one_pd = _mm512_set1_pd(1.0); __m512i one_i6...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx2.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_asimd.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { float *src = (float*)argv[argc-1]; float32x4_t v1 = vdupq_n_f32(src[0]), v2 = vdupq_n_f32(src[1]); /* MAXMIN */ int ret = (int)vgetq_lane_f32(vmaxnmq_f32(v1, v2), 0); ret += (int)vgetq_lane_f...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vxe.c
#if (__VEC__ < 10302) || (__ARCH__ < 12) #error VXE not supported #endif #include <vecintrin.h> int main(int argc, char **argv) { __vector float x = vec_nabs(vec_xl(argc, (float*)argv)); __vector float y = vec_load_len((float*)argv, (unsigned int)argc); x = vec_round(vec_ceil(x) + vec_floor(y)); ...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_ssse3.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_knl.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_icl.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_neon.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { // passing from untraced pointers to avoid optimizing out any constants // so we can test against the linker. float *src = (float*)argv[argc-1]; float32x4_t v1 = vdupq_n_f32(src[0]), v2 = vdupq_n_f32(...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/test_flags.c
int test_flags;
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_neon_fp16.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { short *src = (short*)argv[argc-1]; float32x4_t v_z4 = vcvt_f32_f16((float16x4_t)vld1_s16(src)); return (int)vgetq_lane_f32(v_z4, 0); }
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/extra_vsx3_half_double.c
/** * Assembler may not fully support the following VSX3 scalar * instructions, even though compilers report VSX3 support. */ int main(void) { unsigned short bits = 0xFF; double f; __asm__ __volatile__("xscvhpdp %x0,%x1" : "=wa"(f) : "wa"(bits)); __asm__ __volatile__ ("xscvdphp %x0,%x1" : "=wa" (bits...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vsx4.c
#ifndef __VSX__ #error "VSX is not supported" #endif #include <altivec.h> typedef __vector unsigned int v_uint32x4; int main(void) { v_uint32x4 v1 = (v_uint32x4){2, 4, 8, 16}; v_uint32x4 v2 = (v_uint32x4){2, 2, 2, 2}; v_uint32x4 v3 = vec_mod(v1, v2); return (int)vec_extractm(v3); }
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vsx3.c
#ifndef __VSX__ #error "VSX is not supported" #endif #include <altivec.h> typedef __vector unsigned int v_uint32x4; int main(void) { v_uint32x4 z4 = (v_uint32x4){0, 0, 0, 0}; z4 = vec_absd(z4, z4); return (int)vec_extract(z4, 0); }
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_asimdhp.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { float16_t *src = (float16_t*)argv[argc-1]; float16x8_t vhp = vdupq_n_f16(src[0]); float16x4_t vlhp = vdup_n_f16(src[1]); int ret = (int)vgetq_lane_f16(vabdq_f16(vhp, vhp), 0); ret += (int...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/extra_vsx_asm.c
/** * Testing ASM VSX register number fixer '%x<n>' * * old versions of CLANG doesn't support %x<n> in the inline asm template * which fixes register number when using any of the register constraints wa, wd, wf. * * xref: * - https://bugs.llvm.org/show_bug.cgi?id=31837 * - https://gcc.gnu.org/onlinedocs/gcc/Mac...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_asimdfhm.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { float16_t *src = (float16_t*)argv[argc-1]; float *src2 = (float*)argv[argc-2]; float16x8_t vhp = vdupq_n_f16(src[0]); float16x4_t vlhp = vdup_n_f16(src[1]); float32x4_t vf = vdupq_n_f32(src2[0]...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_clx.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512f.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_sse42.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_cnl.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vx.c
#if (__VEC__ < 10301) || (__ARCH__ < 11) #error VX not supported #endif #include <vecintrin.h> int main(int argc, char **argv) { __vector double x = vec_abs(vec_xl(argc, (double*)argv)); __vector double y = vec_load_len((double*)argv, (unsigned int)argc); x = vec_round(vec_ceil(x) + vec_floor(y)); ...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/extra_avx512bw_mask.c
#include <immintrin.h> /** * Test BW mask operations due to: * - MSVC has supported it since vs2019 see, * https://developercommunity.visualstudio.com/content/problem/518298/missing-avx512bw-mask-intrinsics.html * - Clang >= v8.0 * - GCC >= v7.1 */ int main(void) { __mmask64 m64 = _mm512_cmpeq_epi8_mask...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_sse41.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_f16c.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_spr.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_asimddp.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { unsigned char *src = (unsigned char*)argv[argc-1]; uint8x16_t v1 = vdupq_n_u8(src[0]), v2 = vdupq_n_u8(src[1]); uint32x4_t va = vdupq_n_u32(3); int ret = (int)vgetq_lane_u32(vdotq_u32(va, v1, v2), 0);...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/extra_vsx4_mma.c
#ifndef __VSX__ #error "VSX is not supported" #endif #include <altivec.h> typedef __vector float fv4sf_t; typedef __vector unsigned char vec_t; int main(void) { __vector_quad acc0; float a[4] = {0,1,2,3}; float b[4] = {0,1,2,3}; vec_t *va = (vec_t *) a; vec_t *vb = (vec_t *) b; __builtin_m...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vsx.c
#ifndef __VSX__ #error "VSX is not supported" #endif #include <altivec.h> #if (defined(__GNUC__) && !defined(vec_xl)) || (defined(__clang__) && !defined(__IBMC__)) #define vsx_ld vec_vsx_ld #define vsx_st vec_vsx_st #else #define vsx_ld vec_xl #define vsx_st vec_xst #endif int main(void) { ...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vxe2.c
#if (__VEC__ < 10303) || (__ARCH__ < 13) #error VXE2 not supported #endif #include <vecintrin.h> int main(int argc, char **argv) { int val; __vector signed short large = { 'a', 'b', 'c', 'a', 'g', 'h', 'g', 'o' }; __vector signed short search = { 'g', 'h', 'g', 'o' }; __vector unsigned char len = ...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_skx.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512cd.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_sse2.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_vsx2.c
#ifndef __VSX__ #error "VSX is not supported" #endif #include <altivec.h> typedef __vector unsigned long long v_uint64x2; int main(void) { v_uint64x2 z2 = (v_uint64x2){0, 0}; z2 = (v_uint64x2)vec_cmpeq(z2, z2); return (int)vec_extract(z2, 0); }
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/extra_avx512dq_mask.c
#include <immintrin.h> /** * Test DQ mask operations due to: * - MSVC has supported it since vs2019 see, * https://developercommunity.visualstudio.com/content/problem/518298/missing-avx512bw-mask-intrinsics.html * - Clang >= v8.0 * - GCC >= v7.1 */ int main(void) { __mmask8 m8 = _mm512_cmpeq_epi64_mask(...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx512_knm.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_sse.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_sse3.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_neon_vfpv4.c
#ifdef _MSC_VER #include <Intrin.h> #endif #include <arm_neon.h> int main(int argc, char **argv) { float *src = (float*)argv[argc-1]; float32x4_t v1 = vdupq_n_f32(src[0]); float32x4_t v2 = vdupq_n_f32(src[1]); float32x4_t v3 = vdupq_n_f32(src[2]); int ret = (int)vgetq_lane_f32(vfmaq_f32(v1, v2,...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_fma4.c
#include <immintrin.h> #ifdef _MSC_VER #include <ammintrin.h> #else #include <x86intrin.h> #endif int main(int argc, char **argv) { __m256 a = _mm256_loadu_ps((const float*)argv[argc-1]); a = _mm256_macc_ps(a, a, a); return (int)_mm_cvtss_f32(_mm256_castps256_ps128(a)); }
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_fma3.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_avx.c
#if defined(DETECT_FEATURES) && defined(__INTEL_COMPILER) /* * Unlike GCC and CLANG, Intel Compiler exposes all supported intrinsics, * whether or not the build options for those features are specified. * Therefore, we must test #definitions of CPU features when option native/host * is enabled v...
0
public_repos/numpy/numpy/distutils
public_repos/numpy/numpy/distutils/checks/cpu_xop.c
#include <immintrin.h> #ifdef _MSC_VER #include <ammintrin.h> #else #include <x86intrin.h> #endif int main(void) { __m128i a = _mm_comge_epu32(_mm_setzero_si128(), _mm_setzero_si128()); return _mm_cvtsi128_si32(a); }
0
public_repos/numpy/numpy
public_repos/numpy/numpy/typing/mypy_plugin.py
"""A mypy_ plugin for managing a number of platform-specific annotations. Its functionality can be split into three distinct parts: * Assigning the (platform-dependent) precisions of certain `~numpy.number` subclasses, including the likes of `~numpy.int_`, `~numpy.intp` and `~numpy.longlong`. See the documentation...
0
public_repos/numpy/numpy
public_repos/numpy/numpy/typing/__init__.py
""" ============================ Typing (:mod:`numpy.typing`) ============================ .. versionadded:: 1.20 Large parts of the NumPy API have :pep:`484`-style type annotations. In addition a number of type aliases are available to users, most prominently the two below: - `ArrayLike`: objects that can be conver...
0
public_repos/numpy/numpy/typing
public_repos/numpy/numpy/typing/tests/test_typing.py
from __future__ import annotations import importlib.util import os import re import shutil from collections import defaultdict from collections.abc import Iterator from typing import TYPE_CHECKING import pytest from numpy.typing.mypy_plugin import _EXTENDED_PRECISION_LIST # Only trigger a full `mypy` run if this en...
0
public_repos/numpy/numpy/typing
public_repos/numpy/numpy/typing/tests/test_isfile.py
import os import sys from pathlib import Path import numpy as np from numpy.testing import assert_ ROOT = Path(np.__file__).parents[0] FILES = [ ROOT / "py.typed", ROOT / "__init__.pyi", ROOT / "ctypeslib.pyi", ROOT / "_core" / "__init__.pyi", ROOT / "f2py" / "__init__.pyi", ROOT / "fft" / "__...
0
public_repos/numpy/numpy/typing
public_repos/numpy/numpy/typing/tests/test_runtime.py
"""Test the runtime usage of `numpy.typing`.""" from __future__ import annotations from typing import ( get_type_hints, Union, NamedTuple, get_args, get_origin, Any, ) import pytest import numpy as np import numpy.typing as npt import numpy._typing as _npt class TypeTup(NamedTuple): typ...
0
public_repos/numpy/numpy/typing/tests
public_repos/numpy/numpy/typing/tests/data/mypy.ini
[mypy] plugins = numpy.typing.mypy_plugin show_absolute_path = True implicit_reexport = False pretty = True disallow_any_unimported = True disallow_any_generics = True
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/histograms.pyi
import numpy as np import numpy.typing as npt AR_i8: npt.NDArray[np.int64] AR_f8: npt.NDArray[np.float64] np.histogram_bin_edges(AR_i8, range=(0, 1, 2)) # E: incompatible type np.histogram(AR_i8, range=(0, 1, 2)) # E: incompatible type np.histogramdd(AR_i8, range=(0, 1)) # E: incompatible type np.histogramdd(AR_...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/lib_utils.pyi
import numpy.lib.array_utils as array_utils array_utils.byte_bounds(1) # E: incompatible type
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/lib_function_base.pyi
from typing import Any import numpy as np import numpy.typing as npt AR_f8: npt.NDArray[np.float64] AR_c16: npt.NDArray[np.complex128] AR_m: npt.NDArray[np.timedelta64] AR_M: npt.NDArray[np.datetime64] AR_O: npt.NDArray[np.object_] def func(a: int) -> None: ... np.average(AR_m) # E: incompatible type np.select(1, ...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/flatiter.pyi
from typing import Any import numpy as np import numpy._typing as npt class Index: def __index__(self) -> int: ... a: np.flatiter[npt.NDArray[np.float64]] supports_array: npt._SupportsArray[np.dtype[np.float64]] a.base = Any # E: Property "base" defined in "flatiter" is read-only a.coords = Any # E:...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/arrayterator.pyi
import numpy as np import numpy.typing as npt AR_i8: npt.NDArray[np.int64] ar_iter = np.lib.Arrayterator(AR_i8) np.lib.Arrayterator(np.int64()) # E: incompatible type ar_iter.shape = (10, 5) # E: is read-only ar_iter[None] # E: Invalid index type ar_iter[None, 1] # E: Invalid index type ar_iter[np.intp()] # E: I...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/array_constructors.pyi
import numpy as np import numpy.typing as npt a: npt.NDArray[np.float64] generator = (i for i in range(10)) np.require(a, requirements=1) # E: No overload variant np.require(a, requirements="TEST") # E: incompatible type np.zeros("test") # E: incompatible type np.zeros() # E: require at least one argument np.on...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/chararray.pyi
import numpy as np from typing import Any AR_U: np.char.chararray[Any, np.dtype[np.str_]] AR_S: np.char.chararray[Any, np.dtype[np.bytes_]] AR_S.encode() # E: Invalid self argument AR_U.decode() # E: Invalid self argument AR_U.join(b"_") # E: incompatible type AR_S.join("_") # E: incompatible type AR_U.ljust(5,...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/index_tricks.pyi
import numpy as np AR_LIKE_i: list[int] AR_LIKE_f: list[float] np.ndindex([1, 2, 3]) # E: No overload variant np.unravel_index(AR_LIKE_f, (1, 2, 3)) # E: incompatible type np.ravel_multi_index(AR_LIKE_i, (1, 2, 3), mode="bob") # E: No overload variant np.mgrid[1] # E: Invalid index type np.mgrid[...] # E: Invali...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/scalars.pyi
import sys import numpy as np f2: np.float16 f8: np.float64 c8: np.complex64 # Construction np.float32(3j) # E: incompatible type # Technically the following examples are valid NumPy code. But they # are not considered a best practice, and people who wish to use the # stubs should instead do # # np.array([1.0, 0.0...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/comparisons.pyi
import numpy as np import numpy.typing as npt AR_i: npt.NDArray[np.int64] AR_f: npt.NDArray[np.float64] AR_c: npt.NDArray[np.complex128] AR_m: npt.NDArray[np.timedelta64] AR_M: npt.NDArray[np.datetime64] AR_f > AR_m # E: Unsupported operand types AR_c > AR_m # E: Unsupported operand types AR_m > AR_f # E: Unsuppo...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/lib_version.pyi
from numpy.lib import NumpyVersion version: NumpyVersion NumpyVersion(b"1.8.0") # E: incompatible type version >= b"1.8.0" # E: Unsupported operand types
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/constants.pyi
import numpy as np np.little_endian = np.little_endian # E: Cannot assign to final
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/linalg.pyi
import numpy as np import numpy.typing as npt AR_f8: npt.NDArray[np.float64] AR_O: npt.NDArray[np.object_] AR_M: npt.NDArray[np.datetime64] np.linalg.tensorsolve(AR_O, AR_O) # E: incompatible type np.linalg.solve(AR_O, AR_O) # E: incompatible type np.linalg.tensorinv(AR_O) # E: incompatible type np.linalg.inv(A...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/ufunc_config.pyi
"""Typing tests for `numpy._core._ufunc_config`.""" import numpy as np def func1(a: str, b: int, c: float) -> None: ... def func2(a: str, *, b: int) -> None: ... class Write1: def write1(self, a: str) -> None: ... class Write2: def write(self, a: str, b: str) -> None: ... class Write3: def write(self, ...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/fromnumeric.pyi
"""Tests for :mod:`numpy._core.fromnumeric`.""" import numpy as np import numpy.typing as npt A = np.array(True, ndmin=2, dtype=bool) A.setflags(write=False) AR_U: npt.NDArray[np.str_] a = np.bool_(True) np.take(a, None) # E: No overload variant np.take(a, axis=1.0) # E: No overload variant np.take(A, out=1) # E...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/bitwise_ops.pyi
import numpy as np i8 = np.int64() i4 = np.int32() u8 = np.uint64() b_ = np.bool_() i = int() f8 = np.float64() b_ >> f8 # E: No overload variant i8 << f8 # E: No overload variant i | f8 # E: Unsupported operand types i8 ^ f8 # E: No overload variant u8 & f8 # E: No overload variant ~f8 # E: Unsupported operan...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/numerictypes.pyi
import numpy as np np.issubdtype(1, np.int64) # E: incompatible type
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/memmap.pyi
import numpy as np with open("file.txt", "r") as f: np.memmap(f) # E: No overload variant np.memmap("test.txt", shape=[10, 5]) # E: No overload variant
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/nditer.pyi
import numpy as np class Test(np.nditer): ... # E: Cannot inherit from final class np.nditer([0, 1], flags=["test"]) # E: incompatible type np.nditer([0, 1], op_flags=[["test"]]) # E: incompatible type np.nditer([0, 1], itershape=(1.0,)) # E: incompatible type np.nditer([0, 1], buffersize=1.0) # E: incompatible ...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/type_check.pyi
import numpy as np import numpy.typing as npt DTYPE_i8: np.dtype[np.int64] np.mintypecode(DTYPE_i8) # E: incompatible type np.iscomplexobj(DTYPE_i8) # E: incompatible type np.isrealobj(DTYPE_i8) # E: incompatible type np.typename(DTYPE_i8) # E: No overload variant np.typename("invalid") # E: No overload variant...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/random.pyi
import numpy as np import numpy.typing as npt SEED_FLOAT: float = 457.3 SEED_ARR_FLOAT: npt.NDArray[np.float64] = np.array([1.0, 2, 3, 4]) SEED_ARRLIKE_FLOAT: list[float] = [1.0, 2.0, 3.0, 4.0] SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0) SEED_STR: str = "String seeding not allowed" # default rng...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/shape_base.pyi
import numpy as np class DTypeLike: dtype: np.dtype[np.int_] dtype_like: DTypeLike np.expand_dims(dtype_like, (5, 10)) # E: No overload variant
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/char.pyi
import numpy as np import numpy.typing as npt AR_U: npt.NDArray[np.str_] AR_S: npt.NDArray[np.bytes_] np.char.equal(AR_U, AR_S) # E: incompatible type np.char.not_equal(AR_U, AR_S) # E: incompatible type np.char.greater_equal(AR_U, AR_S) # E: incompatible type np.char.less_equal(AR_U, AR_S) # E: incompatible t...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/einsumfunc.pyi
import numpy as np import numpy.typing as npt AR_i: npt.NDArray[np.int64] AR_f: npt.NDArray[np.float64] AR_m: npt.NDArray[np.timedelta64] AR_U: npt.NDArray[np.str_] np.einsum("i,i->i", AR_i, AR_m) # E: incompatible type np.einsum("i,i->i", AR_f, AR_f, dtype=np.int32) # E: incompatible type np.einsum("i,i->i", AR_i,...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/npyio.pyi
import pathlib from typing import IO import numpy.typing as npt import numpy as np str_path: str bytes_path: bytes pathlib_path: pathlib.Path str_file: IO[str] AR_i8: npt.NDArray[np.int64] np.load(str_file) # E: incompatible type np.save(bytes_path, AR_i8) # E: incompatible type np.savez(bytes_path, AR_i8) # E:...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/ndarray.pyi
import numpy as np # Ban setting dtype since mutating the type of the array in place # makes having ndarray be generic over dtype impossible. Generally # users should use `ndarray.view` in this situation anyway. See # # https://github.com/numpy/numpy-stubs/issues/7 # # for more context. float_array = np.array([1.0]) f...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/warnings_and_errors.pyi
import numpy.exceptions as ex ex.AxisError(1.0) # E: No overload variant ex.AxisError(1, ndim=2.0) # E: No overload variant ex.AxisError(2, msg_prefix=404) # E: No overload variant
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/array_like.pyi
import numpy as np from numpy._typing import ArrayLike class A: pass x1: ArrayLike = (i for i in range(10)) # E: Incompatible types in assignment x2: ArrayLike = A() # E: Incompatible types in assignment x3: ArrayLike = {1: "foo", 2: "bar"} # E: Incompatible types in assignment scalar = np.int64(1) scalar._...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/stride_tricks.pyi
import numpy as np import numpy.typing as npt AR_f8: npt.NDArray[np.float64] np.lib.stride_tricks.as_strided(AR_f8, shape=8) # E: No overload variant np.lib.stride_tricks.as_strided(AR_f8, strides=8) # E: No overload variant np.lib.stride_tricks.sliding_window_view(AR_f8, axis=(1,)) # E: No overload variant
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/ufunclike.pyi
import numpy as np import numpy.typing as npt AR_c: npt.NDArray[np.complex128] AR_m: npt.NDArray[np.timedelta64] AR_M: npt.NDArray[np.datetime64] AR_O: npt.NDArray[np.object_] np.fix(AR_c) # E: incompatible type np.fix(AR_m) # E: incompatible type np.fix(AR_M) # E: incompatible type np.isposinf(AR_c) # E: incomp...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/nested_sequence.pyi
from collections.abc import Sequence from numpy._typing import _NestedSequence a: Sequence[float] b: list[complex] c: tuple[str, ...] d: int e: str def func(a: _NestedSequence[int]) -> None: ... reveal_type(func(a)) # E: incompatible type reveal_type(func(b)) # E: incompatible type reveal_type(func(c)) # E: i...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/false_positives.pyi
import numpy as np import numpy.typing as npt AR_f8: npt.NDArray[np.float64] # NOTE: Mypy bug presumably due to the special-casing of heterogeneous tuples; # xref numpy/numpy#20901 # # The expected output should be no different than, e.g., when using a # list instead of a tuple np.concatenate(([1], AR_f8)) # E: Argu...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/ndarray_misc.pyi
""" Tests for miscellaneous (non-magic) ``np.ndarray``/``np.generic`` methods. More extensive tests are performed for the methods' function-based counterpart in `../from_numeric.py`. """ import numpy as np import numpy.typing as npt f8: np.float64 AR_f8: npt.NDArray[np.float64] AR_M: npt.NDArray[np.datetime64] AR_b...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/modules.pyi
import numpy as np np.testing.bob # E: Module has no attribute np.bob # E: Module has no attribute # Stdlib modules in the namespace by accident np.warnings # E: Module has no attribute np.sys # E: Module has no attribute np.os # E: Module "numpy" does not explicitly export np.math # E: Module has no attribute ...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/twodim_base.pyi
from typing import Any, TypeVar import numpy as np import numpy.typing as npt def func1(ar: npt.NDArray[Any], a: int) -> npt.NDArray[np.str_]: pass def func2(ar: npt.NDArray[Any], a: float) -> float: pass AR_b: npt.NDArray[np.bool_] AR_m: npt.NDArray[np.timedelta64] AR_LIKE_b: list[bool] np.eye(10, M=2...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/rec.pyi
import numpy as np import numpy.typing as npt AR_i8: npt.NDArray[np.int64] np.rec.fromarrays(1) # E: No overload variant np.rec.fromarrays([1, 2, 3], dtype=[("f8", "f8")], formats=["f8", "f8"]) # E: No overload variant np.rec.fromrecords(AR_i8) # E: incompatible type np.rec.fromrecords([(1.5,)], dtype=[("f8", "f8...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/multiarray.pyi
import numpy as np import numpy.typing as npt i8: np.int64 AR_b: npt.NDArray[np.bool_] AR_u1: npt.NDArray[np.uint8] AR_i8: npt.NDArray[np.int64] AR_f8: npt.NDArray[np.float64] AR_M: npt.NDArray[np.datetime64] M: np.datetime64 AR_LIKE_f: list[float] def func(a: int) -> None: ... np.where(AR_b, 1) # E: No overload...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/lib_polynomial.pyi
import numpy as np import numpy.typing as npt AR_f8: npt.NDArray[np.float64] AR_c16: npt.NDArray[np.complex128] AR_O: npt.NDArray[np.object_] AR_U: npt.NDArray[np.str_] poly_obj: np.poly1d np.polymul(AR_f8, AR_U) # E: incompatible type np.polydiv(AR_f8, AR_U) # E: incompatible type 5**poly_obj # E: No overload v...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/arrayprint.pyi
from collections.abc import Callable from typing import Any import numpy as np import numpy.typing as npt AR: npt.NDArray[np.float64] func1: Callable[[Any], str] func2: Callable[[np.integer[Any]], str] np.array2string(AR, style=None) # E: Unexpected keyword argument np.array2string(AR, legacy="1.14") # E: incompat...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/dtype.pyi
import numpy as np class Test1: not_dtype = np.dtype(float) class Test2: dtype = float np.dtype(Test1()) # E: No overload variant of "dtype" matches np.dtype(Test2()) # E: incompatible type np.dtype( # E: No overload variant of "dtype" matches { "field1": (float, 1), "field2": (int...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/datasource.pyi
from pathlib import Path import numpy as np path: Path d1: np.lib.npyio.DataSource d1.abspath(path) # E: incompatible type d1.abspath(b"...") # E: incompatible type d1.exists(path) # E: incompatible type d1.exists(b"...") # E: incompatible type d1.open(path, "r") # E: incompatible type d1.open(b"...", encoding...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/array_pad.pyi
import numpy as np import numpy.typing as npt AR_i8: npt.NDArray[np.int64] np.pad(AR_i8, 2, mode="bob") # E: No overload variant
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/ufuncs.pyi
import numpy as np import numpy.typing as npt AR_f8: npt.NDArray[np.float64] np.sin.nin + "foo" # E: Unsupported operand types np.sin(1, foo="bar") # E: No overload variant np.abs(None) # E: No overload variant np.add(1, 1, 1) # E: No overload variant np.add(1, 1, axis=0) # E: No overload variant np.matmul(AR...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/arithmetic.pyi
from typing import Any import numpy as np import numpy.typing as npt b_ = np.bool_() dt = np.datetime64(0, "D") td = np.timedelta64(0, "D") AR_b: npt.NDArray[np.bool_] AR_u: npt.NDArray[np.uint32] AR_i: npt.NDArray[np.int64] AR_f: npt.NDArray[np.float64] AR_c: npt.NDArray[np.complex128] AR_m: npt.NDArray[np.timedelt...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/fail/testing.pyi
import numpy as np import numpy.typing as npt AR_U: npt.NDArray[np.str_] def func() -> bool: ... np.testing.assert_(True, msg=1) # E: incompatible type np.testing.build_err_msg(1, "test") # E: incompatible type np.testing.assert_almost_equal(AR_U, AR_U) # E: incompatible type np.testing.assert_approx_equal([1, 2,...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/misc/extended_precision.pyi
import sys import numpy as np from numpy._typing import _80Bit, _96Bit, _128Bit, _256Bit if sys.version_info >= (3, 11): from typing import assert_type else: from typing_extensions import assert_type assert_type(np.uint128(), np.unsignedinteger[_128Bit]) assert_type(np.uint256(), np.unsignedinteger[_256Bit])...
0
public_repos/numpy/numpy/typing/tests/data
public_repos/numpy/numpy/typing/tests/data/pass/einsumfunc.py
from __future__ import annotations from typing import Any import numpy as np AR_LIKE_b = [True, True, True] AR_LIKE_u = [np.uint32(1), np.uint32(2), np.uint32(3)] AR_LIKE_i = [1, 2, 3] AR_LIKE_f = [1.0, 2.0, 3.0] AR_LIKE_c = [1j, 2j, 3j] AR_LIKE_U = ["1", "2", "3"] OUT_f: np.ndarray[Any, np.dtype[np.float64]] = np....
0