numpy 2.4.1__pp311-pypy311_pp73-macosx_14_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numpy/__config__.py +170 -0
- numpy/__config__.pyi +108 -0
- numpy/__init__.cython-30.pxd +1242 -0
- numpy/__init__.pxd +1155 -0
- numpy/__init__.py +942 -0
- numpy/__init__.pyi +6202 -0
- numpy/_array_api_info.py +346 -0
- numpy/_array_api_info.pyi +206 -0
- numpy/_configtool.py +39 -0
- numpy/_configtool.pyi +1 -0
- numpy/_core/__init__.py +201 -0
- numpy/_core/__init__.pyi +666 -0
- numpy/_core/_add_newdocs.py +7151 -0
- numpy/_core/_add_newdocs.pyi +2 -0
- numpy/_core/_add_newdocs_scalars.py +381 -0
- numpy/_core/_add_newdocs_scalars.pyi +16 -0
- numpy/_core/_asarray.py +130 -0
- numpy/_core/_asarray.pyi +43 -0
- numpy/_core/_dtype.py +366 -0
- numpy/_core/_dtype.pyi +56 -0
- numpy/_core/_dtype_ctypes.py +120 -0
- numpy/_core/_dtype_ctypes.pyi +83 -0
- numpy/_core/_exceptions.py +162 -0
- numpy/_core/_exceptions.pyi +54 -0
- numpy/_core/_internal.py +968 -0
- numpy/_core/_internal.pyi +61 -0
- numpy/_core/_methods.py +252 -0
- numpy/_core/_methods.pyi +22 -0
- numpy/_core/_multiarray_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_multiarray_umath.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_operand_flag_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_rational_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_simd.pyi +35 -0
- numpy/_core/_simd.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_string_helpers.py +100 -0
- numpy/_core/_string_helpers.pyi +12 -0
- numpy/_core/_struct_ufunc_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_type_aliases.py +131 -0
- numpy/_core/_type_aliases.pyi +86 -0
- numpy/_core/_ufunc_config.py +515 -0
- numpy/_core/_ufunc_config.pyi +69 -0
- numpy/_core/_umath_tests.pyi +47 -0
- numpy/_core/_umath_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/arrayprint.py +1779 -0
- numpy/_core/arrayprint.pyi +158 -0
- numpy/_core/cversions.py +13 -0
- numpy/_core/defchararray.py +1414 -0
- numpy/_core/defchararray.pyi +1150 -0
- numpy/_core/einsumfunc.py +1650 -0
- numpy/_core/einsumfunc.pyi +184 -0
- numpy/_core/fromnumeric.py +4233 -0
- numpy/_core/fromnumeric.pyi +1735 -0
- numpy/_core/function_base.py +547 -0
- numpy/_core/function_base.pyi +276 -0
- numpy/_core/getlimits.py +462 -0
- numpy/_core/getlimits.pyi +124 -0
- numpy/_core/include/numpy/__multiarray_api.c +376 -0
- numpy/_core/include/numpy/__multiarray_api.h +1628 -0
- numpy/_core/include/numpy/__ufunc_api.c +55 -0
- numpy/_core/include/numpy/__ufunc_api.h +349 -0
- numpy/_core/include/numpy/_neighborhood_iterator_imp.h +90 -0
- numpy/_core/include/numpy/_numpyconfig.h +33 -0
- numpy/_core/include/numpy/_public_dtype_api_table.h +86 -0
- numpy/_core/include/numpy/arrayobject.h +7 -0
- numpy/_core/include/numpy/arrayscalars.h +198 -0
- numpy/_core/include/numpy/dtype_api.h +547 -0
- numpy/_core/include/numpy/halffloat.h +70 -0
- numpy/_core/include/numpy/ndarrayobject.h +304 -0
- numpy/_core/include/numpy/ndarraytypes.h +1982 -0
- numpy/_core/include/numpy/npy_2_compat.h +249 -0
- numpy/_core/include/numpy/npy_2_complexcompat.h +28 -0
- numpy/_core/include/numpy/npy_3kcompat.h +374 -0
- numpy/_core/include/numpy/npy_common.h +989 -0
- numpy/_core/include/numpy/npy_cpu.h +126 -0
- numpy/_core/include/numpy/npy_endian.h +79 -0
- numpy/_core/include/numpy/npy_math.h +602 -0
- numpy/_core/include/numpy/npy_no_deprecated_api.h +20 -0
- numpy/_core/include/numpy/npy_os.h +42 -0
- numpy/_core/include/numpy/numpyconfig.h +185 -0
- numpy/_core/include/numpy/random/LICENSE.txt +21 -0
- numpy/_core/include/numpy/random/bitgen.h +20 -0
- numpy/_core/include/numpy/random/distributions.h +209 -0
- numpy/_core/include/numpy/random/libdivide.h +2079 -0
- numpy/_core/include/numpy/ufuncobject.h +343 -0
- numpy/_core/include/numpy/utils.h +37 -0
- numpy/_core/lib/libnpymath.a +0 -0
- numpy/_core/lib/npy-pkg-config/mlib.ini +12 -0
- numpy/_core/lib/npy-pkg-config/npymath.ini +20 -0
- numpy/_core/lib/pkgconfig/numpy.pc +7 -0
- numpy/_core/memmap.py +363 -0
- numpy/_core/memmap.pyi +3 -0
- numpy/_core/multiarray.py +1740 -0
- numpy/_core/multiarray.pyi +1316 -0
- numpy/_core/numeric.py +2758 -0
- numpy/_core/numeric.pyi +1276 -0
- numpy/_core/numerictypes.py +633 -0
- numpy/_core/numerictypes.pyi +196 -0
- numpy/_core/overrides.py +188 -0
- numpy/_core/overrides.pyi +47 -0
- numpy/_core/printoptions.py +32 -0
- numpy/_core/printoptions.pyi +28 -0
- numpy/_core/records.py +1088 -0
- numpy/_core/records.pyi +340 -0
- numpy/_core/shape_base.py +996 -0
- numpy/_core/shape_base.pyi +182 -0
- numpy/_core/strings.py +1813 -0
- numpy/_core/strings.pyi +536 -0
- numpy/_core/tests/_locales.py +72 -0
- numpy/_core/tests/_natype.py +144 -0
- numpy/_core/tests/data/astype_copy.pkl +0 -0
- numpy/_core/tests/data/generate_umath_validation_data.cpp +170 -0
- numpy/_core/tests/data/recarray_from_file.fits +0 -0
- numpy/_core/tests/data/umath-validation-set-README.txt +15 -0
- numpy/_core/tests/data/umath-validation-set-arccos.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arccosh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arcsin.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arcsinh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arctan.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arctanh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-cbrt.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-cos.csv +1375 -0
- numpy/_core/tests/data/umath-validation-set-cosh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-exp.csv +412 -0
- numpy/_core/tests/data/umath-validation-set-exp2.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-expm1.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-log.csv +271 -0
- numpy/_core/tests/data/umath-validation-set-log10.csv +1629 -0
- numpy/_core/tests/data/umath-validation-set-log1p.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-log2.csv +1629 -0
- numpy/_core/tests/data/umath-validation-set-sin.csv +1370 -0
- numpy/_core/tests/data/umath-validation-set-sinh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-tan.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-tanh.csv +1429 -0
- numpy/_core/tests/examples/cython/checks.pyx +373 -0
- numpy/_core/tests/examples/cython/meson.build +43 -0
- numpy/_core/tests/examples/cython/setup.py +39 -0
- numpy/_core/tests/examples/limited_api/limited_api1.c +17 -0
- numpy/_core/tests/examples/limited_api/limited_api2.pyx +11 -0
- numpy/_core/tests/examples/limited_api/limited_api_latest.c +19 -0
- numpy/_core/tests/examples/limited_api/meson.build +59 -0
- numpy/_core/tests/examples/limited_api/setup.py +24 -0
- numpy/_core/tests/test__exceptions.py +90 -0
- numpy/_core/tests/test_abc.py +54 -0
- numpy/_core/tests/test_api.py +655 -0
- numpy/_core/tests/test_argparse.py +90 -0
- numpy/_core/tests/test_array_api_info.py +113 -0
- numpy/_core/tests/test_array_coercion.py +928 -0
- numpy/_core/tests/test_array_interface.py +222 -0
- numpy/_core/tests/test_arraymethod.py +84 -0
- numpy/_core/tests/test_arrayobject.py +75 -0
- numpy/_core/tests/test_arrayprint.py +1324 -0
- numpy/_core/tests/test_casting_floatingpoint_errors.py +154 -0
- numpy/_core/tests/test_casting_unittests.py +955 -0
- numpy/_core/tests/test_conversion_utils.py +209 -0
- numpy/_core/tests/test_cpu_dispatcher.py +48 -0
- numpy/_core/tests/test_cpu_features.py +450 -0
- numpy/_core/tests/test_custom_dtypes.py +393 -0
- numpy/_core/tests/test_cython.py +352 -0
- numpy/_core/tests/test_datetime.py +2792 -0
- numpy/_core/tests/test_defchararray.py +858 -0
- numpy/_core/tests/test_deprecations.py +460 -0
- numpy/_core/tests/test_dlpack.py +190 -0
- numpy/_core/tests/test_dtype.py +2110 -0
- numpy/_core/tests/test_einsum.py +1351 -0
- numpy/_core/tests/test_errstate.py +131 -0
- numpy/_core/tests/test_extint128.py +217 -0
- numpy/_core/tests/test_finfo.py +86 -0
- numpy/_core/tests/test_function_base.py +504 -0
- numpy/_core/tests/test_getlimits.py +171 -0
- numpy/_core/tests/test_half.py +593 -0
- numpy/_core/tests/test_hashtable.py +36 -0
- numpy/_core/tests/test_indexerrors.py +122 -0
- numpy/_core/tests/test_indexing.py +1692 -0
- numpy/_core/tests/test_item_selection.py +167 -0
- numpy/_core/tests/test_limited_api.py +102 -0
- numpy/_core/tests/test_longdouble.py +370 -0
- numpy/_core/tests/test_mem_overlap.py +933 -0
- numpy/_core/tests/test_mem_policy.py +453 -0
- numpy/_core/tests/test_memmap.py +248 -0
- numpy/_core/tests/test_multiarray.py +11008 -0
- numpy/_core/tests/test_multiprocessing.py +55 -0
- numpy/_core/tests/test_multithreading.py +377 -0
- numpy/_core/tests/test_nditer.py +3533 -0
- numpy/_core/tests/test_nep50_promotions.py +287 -0
- numpy/_core/tests/test_numeric.py +4295 -0
- numpy/_core/tests/test_numerictypes.py +650 -0
- numpy/_core/tests/test_overrides.py +800 -0
- numpy/_core/tests/test_print.py +202 -0
- numpy/_core/tests/test_protocols.py +46 -0
- numpy/_core/tests/test_records.py +544 -0
- numpy/_core/tests/test_regression.py +2677 -0
- numpy/_core/tests/test_scalar_ctors.py +203 -0
- numpy/_core/tests/test_scalar_methods.py +328 -0
- numpy/_core/tests/test_scalarbuffer.py +153 -0
- numpy/_core/tests/test_scalarinherit.py +105 -0
- numpy/_core/tests/test_scalarmath.py +1168 -0
- numpy/_core/tests/test_scalarprint.py +403 -0
- numpy/_core/tests/test_shape_base.py +904 -0
- numpy/_core/tests/test_simd.py +1345 -0
- numpy/_core/tests/test_simd_module.py +105 -0
- numpy/_core/tests/test_stringdtype.py +1855 -0
- numpy/_core/tests/test_strings.py +1523 -0
- numpy/_core/tests/test_ufunc.py +3405 -0
- numpy/_core/tests/test_umath.py +4962 -0
- numpy/_core/tests/test_umath_accuracy.py +132 -0
- numpy/_core/tests/test_umath_complex.py +631 -0
- numpy/_core/tests/test_unicode.py +369 -0
- numpy/_core/umath.py +60 -0
- numpy/_core/umath.pyi +232 -0
- numpy/_distributor_init.py +15 -0
- numpy/_distributor_init.pyi +1 -0
- numpy/_expired_attrs_2_0.py +78 -0
- numpy/_expired_attrs_2_0.pyi +61 -0
- numpy/_globals.py +121 -0
- numpy/_globals.pyi +17 -0
- numpy/_pyinstaller/__init__.py +0 -0
- numpy/_pyinstaller/__init__.pyi +0 -0
- numpy/_pyinstaller/hook-numpy.py +36 -0
- numpy/_pyinstaller/hook-numpy.pyi +6 -0
- numpy/_pyinstaller/tests/__init__.py +16 -0
- numpy/_pyinstaller/tests/pyinstaller-smoke.py +32 -0
- numpy/_pyinstaller/tests/test_pyinstaller.py +35 -0
- numpy/_pytesttester.py +201 -0
- numpy/_pytesttester.pyi +18 -0
- numpy/_typing/__init__.py +173 -0
- numpy/_typing/_add_docstring.py +153 -0
- numpy/_typing/_array_like.py +106 -0
- numpy/_typing/_char_codes.py +213 -0
- numpy/_typing/_dtype_like.py +114 -0
- numpy/_typing/_extended_precision.py +15 -0
- numpy/_typing/_nbit.py +19 -0
- numpy/_typing/_nbit_base.py +94 -0
- numpy/_typing/_nbit_base.pyi +39 -0
- numpy/_typing/_nested_sequence.py +79 -0
- numpy/_typing/_scalars.py +20 -0
- numpy/_typing/_shape.py +8 -0
- numpy/_typing/_ufunc.py +7 -0
- numpy/_typing/_ufunc.pyi +975 -0
- numpy/_utils/__init__.py +95 -0
- numpy/_utils/__init__.pyi +28 -0
- numpy/_utils/_convertions.py +18 -0
- numpy/_utils/_convertions.pyi +4 -0
- numpy/_utils/_inspect.py +192 -0
- numpy/_utils/_inspect.pyi +70 -0
- numpy/_utils/_pep440.py +486 -0
- numpy/_utils/_pep440.pyi +118 -0
- numpy/char/__init__.py +2 -0
- numpy/char/__init__.pyi +111 -0
- numpy/conftest.py +248 -0
- numpy/core/__init__.py +33 -0
- numpy/core/__init__.pyi +0 -0
- numpy/core/_dtype.py +10 -0
- numpy/core/_dtype.pyi +0 -0
- numpy/core/_dtype_ctypes.py +10 -0
- numpy/core/_dtype_ctypes.pyi +0 -0
- numpy/core/_internal.py +27 -0
- numpy/core/_multiarray_umath.py +57 -0
- numpy/core/_utils.py +21 -0
- numpy/core/arrayprint.py +10 -0
- numpy/core/defchararray.py +10 -0
- numpy/core/einsumfunc.py +10 -0
- numpy/core/fromnumeric.py +10 -0
- numpy/core/function_base.py +10 -0
- numpy/core/getlimits.py +10 -0
- numpy/core/multiarray.py +25 -0
- numpy/core/numeric.py +12 -0
- numpy/core/numerictypes.py +10 -0
- numpy/core/overrides.py +10 -0
- numpy/core/overrides.pyi +7 -0
- numpy/core/records.py +10 -0
- numpy/core/shape_base.py +10 -0
- numpy/core/umath.py +10 -0
- numpy/ctypeslib/__init__.py +13 -0
- numpy/ctypeslib/__init__.pyi +15 -0
- numpy/ctypeslib/_ctypeslib.py +603 -0
- numpy/ctypeslib/_ctypeslib.pyi +236 -0
- numpy/distutils/__init__.py +64 -0
- numpy/distutils/__init__.pyi +4 -0
- numpy/distutils/__pycache__/conv_template.pypy311.pyc +0 -0
- numpy/distutils/_shell_utils.py +87 -0
- numpy/distutils/armccompiler.py +26 -0
- numpy/distutils/ccompiler.py +826 -0
- numpy/distutils/ccompiler_opt.py +2668 -0
- numpy/distutils/checks/cpu_asimd.c +27 -0
- numpy/distutils/checks/cpu_asimddp.c +16 -0
- numpy/distutils/checks/cpu_asimdfhm.c +19 -0
- numpy/distutils/checks/cpu_asimdhp.c +15 -0
- numpy/distutils/checks/cpu_avx.c +20 -0
- numpy/distutils/checks/cpu_avx2.c +20 -0
- numpy/distutils/checks/cpu_avx512_clx.c +22 -0
- numpy/distutils/checks/cpu_avx512_cnl.c +24 -0
- numpy/distutils/checks/cpu_avx512_icl.c +26 -0
- numpy/distutils/checks/cpu_avx512_knl.c +25 -0
- numpy/distutils/checks/cpu_avx512_knm.c +30 -0
- numpy/distutils/checks/cpu_avx512_skx.c +26 -0
- numpy/distutils/checks/cpu_avx512_spr.c +26 -0
- numpy/distutils/checks/cpu_avx512cd.c +20 -0
- numpy/distutils/checks/cpu_avx512f.c +20 -0
- numpy/distutils/checks/cpu_f16c.c +22 -0
- numpy/distutils/checks/cpu_fma3.c +22 -0
- numpy/distutils/checks/cpu_fma4.c +13 -0
- numpy/distutils/checks/cpu_lsx.c +11 -0
- numpy/distutils/checks/cpu_neon.c +19 -0
- numpy/distutils/checks/cpu_neon_fp16.c +11 -0
- numpy/distutils/checks/cpu_neon_vfpv4.c +21 -0
- numpy/distutils/checks/cpu_popcnt.c +32 -0
- numpy/distutils/checks/cpu_rvv.c +13 -0
- numpy/distutils/checks/cpu_sse.c +20 -0
- numpy/distutils/checks/cpu_sse2.c +20 -0
- numpy/distutils/checks/cpu_sse3.c +20 -0
- numpy/distutils/checks/cpu_sse41.c +20 -0
- numpy/distutils/checks/cpu_sse42.c +20 -0
- numpy/distutils/checks/cpu_ssse3.c +20 -0
- numpy/distutils/checks/cpu_sve.c +14 -0
- numpy/distutils/checks/cpu_vsx.c +21 -0
- numpy/distutils/checks/cpu_vsx2.c +13 -0
- numpy/distutils/checks/cpu_vsx3.c +13 -0
- numpy/distutils/checks/cpu_vsx4.c +14 -0
- numpy/distutils/checks/cpu_vx.c +16 -0
- numpy/distutils/checks/cpu_vxe.c +25 -0
- numpy/distutils/checks/cpu_vxe2.c +21 -0
- numpy/distutils/checks/cpu_xop.c +12 -0
- numpy/distutils/checks/extra_avx512bw_mask.c +18 -0
- numpy/distutils/checks/extra_avx512dq_mask.c +16 -0
- numpy/distutils/checks/extra_avx512f_reduce.c +41 -0
- numpy/distutils/checks/extra_vsx3_half_double.c +12 -0
- numpy/distutils/checks/extra_vsx4_mma.c +21 -0
- numpy/distutils/checks/extra_vsx_asm.c +36 -0
- numpy/distutils/checks/test_flags.c +1 -0
- numpy/distutils/command/__init__.py +41 -0
- numpy/distutils/command/autodist.py +148 -0
- numpy/distutils/command/bdist_rpm.py +22 -0
- numpy/distutils/command/build.py +62 -0
- numpy/distutils/command/build_clib.py +469 -0
- numpy/distutils/command/build_ext.py +752 -0
- numpy/distutils/command/build_py.py +31 -0
- numpy/distutils/command/build_scripts.py +49 -0
- numpy/distutils/command/build_src.py +773 -0
- numpy/distutils/command/config.py +516 -0
- numpy/distutils/command/config_compiler.py +126 -0
- numpy/distutils/command/develop.py +15 -0
- numpy/distutils/command/egg_info.py +25 -0
- numpy/distutils/command/install.py +79 -0
- numpy/distutils/command/install_clib.py +40 -0
- numpy/distutils/command/install_data.py +24 -0
- numpy/distutils/command/install_headers.py +25 -0
- numpy/distutils/command/sdist.py +27 -0
- numpy/distutils/conv_template.py +329 -0
- numpy/distutils/core.py +215 -0
- numpy/distutils/cpuinfo.py +683 -0
- numpy/distutils/exec_command.py +315 -0
- numpy/distutils/extension.py +101 -0
- numpy/distutils/fcompiler/__init__.py +1035 -0
- numpy/distutils/fcompiler/absoft.py +158 -0
- numpy/distutils/fcompiler/arm.py +71 -0
- numpy/distutils/fcompiler/compaq.py +120 -0
- numpy/distutils/fcompiler/environment.py +88 -0
- numpy/distutils/fcompiler/fujitsu.py +46 -0
- numpy/distutils/fcompiler/g95.py +42 -0
- numpy/distutils/fcompiler/gnu.py +555 -0
- numpy/distutils/fcompiler/hpux.py +41 -0
- numpy/distutils/fcompiler/ibm.py +97 -0
- numpy/distutils/fcompiler/intel.py +211 -0
- numpy/distutils/fcompiler/lahey.py +45 -0
- numpy/distutils/fcompiler/mips.py +54 -0
- numpy/distutils/fcompiler/nag.py +87 -0
- numpy/distutils/fcompiler/none.py +28 -0
- numpy/distutils/fcompiler/nv.py +53 -0
- numpy/distutils/fcompiler/pathf95.py +33 -0
- numpy/distutils/fcompiler/pg.py +128 -0
- numpy/distutils/fcompiler/sun.py +51 -0
- numpy/distutils/fcompiler/vast.py +52 -0
- numpy/distutils/from_template.py +261 -0
- numpy/distutils/fujitsuccompiler.py +28 -0
- numpy/distutils/intelccompiler.py +106 -0
- numpy/distutils/lib2def.py +116 -0
- numpy/distutils/line_endings.py +77 -0
- numpy/distutils/log.py +111 -0
- numpy/distutils/mingw/gfortran_vs2003_hack.c +6 -0
- numpy/distutils/mingw32ccompiler.py +620 -0
- numpy/distutils/misc_util.py +2484 -0
- numpy/distutils/msvc9compiler.py +63 -0
- numpy/distutils/msvccompiler.py +76 -0
- numpy/distutils/npy_pkg_config.py +441 -0
- numpy/distutils/numpy_distribution.py +17 -0
- numpy/distutils/pathccompiler.py +21 -0
- numpy/distutils/system_info.py +3267 -0
- numpy/distutils/tests/__init__.py +0 -0
- numpy/distutils/tests/test_build_ext.py +74 -0
- numpy/distutils/tests/test_ccompiler_opt.py +808 -0
- numpy/distutils/tests/test_ccompiler_opt_conf.py +176 -0
- numpy/distutils/tests/test_exec_command.py +217 -0
- numpy/distutils/tests/test_fcompiler.py +43 -0
- numpy/distutils/tests/test_fcompiler_gnu.py +55 -0
- numpy/distutils/tests/test_fcompiler_intel.py +30 -0
- numpy/distutils/tests/test_fcompiler_nagfor.py +22 -0
- numpy/distutils/tests/test_from_template.py +44 -0
- numpy/distutils/tests/test_log.py +34 -0
- numpy/distutils/tests/test_mingw32ccompiler.py +47 -0
- numpy/distutils/tests/test_misc_util.py +88 -0
- numpy/distutils/tests/test_npy_pkg_config.py +84 -0
- numpy/distutils/tests/test_shell_utils.py +79 -0
- numpy/distutils/tests/test_system_info.py +334 -0
- numpy/distutils/tests/utilities.py +90 -0
- numpy/distutils/unixccompiler.py +141 -0
- numpy/doc/ufuncs.py +138 -0
- numpy/dtypes.py +41 -0
- numpy/dtypes.pyi +630 -0
- numpy/exceptions.py +246 -0
- numpy/exceptions.pyi +27 -0
- numpy/f2py/__init__.py +86 -0
- numpy/f2py/__init__.pyi +5 -0
- numpy/f2py/__main__.py +5 -0
- numpy/f2py/__version__.py +1 -0
- numpy/f2py/__version__.pyi +1 -0
- numpy/f2py/_backends/__init__.py +9 -0
- numpy/f2py/_backends/__init__.pyi +5 -0
- numpy/f2py/_backends/_backend.py +44 -0
- numpy/f2py/_backends/_backend.pyi +46 -0
- numpy/f2py/_backends/_distutils.py +76 -0
- numpy/f2py/_backends/_distutils.pyi +13 -0
- numpy/f2py/_backends/_meson.py +244 -0
- numpy/f2py/_backends/_meson.pyi +62 -0
- numpy/f2py/_backends/meson.build.template +58 -0
- numpy/f2py/_isocbind.py +62 -0
- numpy/f2py/_isocbind.pyi +13 -0
- numpy/f2py/_src_pyf.py +247 -0
- numpy/f2py/_src_pyf.pyi +28 -0
- numpy/f2py/auxfuncs.py +1004 -0
- numpy/f2py/auxfuncs.pyi +262 -0
- numpy/f2py/capi_maps.py +811 -0
- numpy/f2py/capi_maps.pyi +33 -0
- numpy/f2py/cb_rules.py +665 -0
- numpy/f2py/cb_rules.pyi +17 -0
- numpy/f2py/cfuncs.py +1563 -0
- numpy/f2py/cfuncs.pyi +31 -0
- numpy/f2py/common_rules.py +143 -0
- numpy/f2py/common_rules.pyi +9 -0
- numpy/f2py/crackfortran.py +3725 -0
- numpy/f2py/crackfortran.pyi +266 -0
- numpy/f2py/diagnose.py +149 -0
- numpy/f2py/diagnose.pyi +1 -0
- numpy/f2py/f2py2e.py +788 -0
- numpy/f2py/f2py2e.pyi +74 -0
- numpy/f2py/f90mod_rules.py +269 -0
- numpy/f2py/f90mod_rules.pyi +16 -0
- numpy/f2py/func2subr.py +329 -0
- numpy/f2py/func2subr.pyi +7 -0
- numpy/f2py/rules.py +1629 -0
- numpy/f2py/rules.pyi +41 -0
- numpy/f2py/setup.cfg +3 -0
- numpy/f2py/src/fortranobject.c +1436 -0
- numpy/f2py/src/fortranobject.h +173 -0
- numpy/f2py/symbolic.py +1518 -0
- numpy/f2py/symbolic.pyi +219 -0
- numpy/f2py/tests/__init__.py +16 -0
- numpy/f2py/tests/src/abstract_interface/foo.f90 +34 -0
- numpy/f2py/tests/src/abstract_interface/gh18403_mod.f90 +6 -0
- numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +235 -0
- numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap +1 -0
- numpy/f2py/tests/src/assumed_shape/foo_free.f90 +34 -0
- numpy/f2py/tests/src/assumed_shape/foo_mod.f90 +41 -0
- numpy/f2py/tests/src/assumed_shape/foo_use.f90 +19 -0
- numpy/f2py/tests/src/assumed_shape/precision.f90 +4 -0
- numpy/f2py/tests/src/block_docstring/foo.f +6 -0
- numpy/f2py/tests/src/callback/foo.f +62 -0
- numpy/f2py/tests/src/callback/gh17797.f90 +7 -0
- numpy/f2py/tests/src/callback/gh18335.f90 +17 -0
- numpy/f2py/tests/src/callback/gh25211.f +10 -0
- numpy/f2py/tests/src/callback/gh25211.pyf +18 -0
- numpy/f2py/tests/src/callback/gh26681.f90 +18 -0
- numpy/f2py/tests/src/cli/gh_22819.pyf +6 -0
- numpy/f2py/tests/src/cli/hi77.f +3 -0
- numpy/f2py/tests/src/cli/hiworld.f90 +3 -0
- numpy/f2py/tests/src/common/block.f +11 -0
- numpy/f2py/tests/src/common/gh19161.f90 +10 -0
- numpy/f2py/tests/src/crackfortran/accesstype.f90 +13 -0
- numpy/f2py/tests/src/crackfortran/common_with_division.f +17 -0
- numpy/f2py/tests/src/crackfortran/data_common.f +8 -0
- numpy/f2py/tests/src/crackfortran/data_multiplier.f +5 -0
- numpy/f2py/tests/src/crackfortran/data_stmts.f90 +20 -0
- numpy/f2py/tests/src/crackfortran/data_with_comments.f +8 -0
- numpy/f2py/tests/src/crackfortran/foo_deps.f90 +6 -0
- numpy/f2py/tests/src/crackfortran/gh15035.f +16 -0
- numpy/f2py/tests/src/crackfortran/gh17859.f +12 -0
- numpy/f2py/tests/src/crackfortran/gh22648.pyf +7 -0
- numpy/f2py/tests/src/crackfortran/gh23533.f +5 -0
- numpy/f2py/tests/src/crackfortran/gh23598.f90 +4 -0
- numpy/f2py/tests/src/crackfortran/gh23598Warn.f90 +11 -0
- numpy/f2py/tests/src/crackfortran/gh23879.f90 +20 -0
- numpy/f2py/tests/src/crackfortran/gh27697.f90 +12 -0
- numpy/f2py/tests/src/crackfortran/gh2848.f90 +13 -0
- numpy/f2py/tests/src/crackfortran/operators.f90 +49 -0
- numpy/f2py/tests/src/crackfortran/privatemod.f90 +11 -0
- numpy/f2py/tests/src/crackfortran/publicmod.f90 +10 -0
- numpy/f2py/tests/src/crackfortran/pubprivmod.f90 +10 -0
- numpy/f2py/tests/src/crackfortran/unicode_comment.f90 +4 -0
- numpy/f2py/tests/src/f2cmap/.f2py_f2cmap +1 -0
- numpy/f2py/tests/src/f2cmap/isoFortranEnvMap.f90 +9 -0
- numpy/f2py/tests/src/isocintrin/isoCtests.f90 +34 -0
- numpy/f2py/tests/src/kind/foo.f90 +20 -0
- numpy/f2py/tests/src/mixed/foo.f +5 -0
- numpy/f2py/tests/src/mixed/foo_fixed.f90 +8 -0
- numpy/f2py/tests/src/mixed/foo_free.f90 +8 -0
- numpy/f2py/tests/src/modules/gh25337/data.f90 +8 -0
- numpy/f2py/tests/src/modules/gh25337/use_data.f90 +6 -0
- numpy/f2py/tests/src/modules/gh26920/two_mods_with_no_public_entities.f90 +21 -0
- numpy/f2py/tests/src/modules/gh26920/two_mods_with_one_public_routine.f90 +21 -0
- numpy/f2py/tests/src/modules/module_data_docstring.f90 +12 -0
- numpy/f2py/tests/src/modules/use_modules.f90 +20 -0
- numpy/f2py/tests/src/negative_bounds/issue_20853.f90 +7 -0
- numpy/f2py/tests/src/parameter/constant_array.f90 +45 -0
- numpy/f2py/tests/src/parameter/constant_both.f90 +57 -0
- numpy/f2py/tests/src/parameter/constant_compound.f90 +15 -0
- numpy/f2py/tests/src/parameter/constant_integer.f90 +22 -0
- numpy/f2py/tests/src/parameter/constant_non_compound.f90 +23 -0
- numpy/f2py/tests/src/parameter/constant_real.f90 +23 -0
- numpy/f2py/tests/src/quoted_character/foo.f +14 -0
- numpy/f2py/tests/src/regression/AB.inc +1 -0
- numpy/f2py/tests/src/regression/assignOnlyModule.f90 +25 -0
- numpy/f2py/tests/src/regression/datonly.f90 +17 -0
- numpy/f2py/tests/src/regression/f77comments.f +26 -0
- numpy/f2py/tests/src/regression/f77fixedform.f95 +5 -0
- numpy/f2py/tests/src/regression/f90continuation.f90 +9 -0
- numpy/f2py/tests/src/regression/incfile.f90 +5 -0
- numpy/f2py/tests/src/regression/inout.f90 +9 -0
- numpy/f2py/tests/src/regression/lower_f2py_fortran.f90 +5 -0
- numpy/f2py/tests/src/regression/mod_derived_types.f90 +23 -0
- numpy/f2py/tests/src/return_character/foo77.f +45 -0
- numpy/f2py/tests/src/return_character/foo90.f90 +48 -0
- numpy/f2py/tests/src/return_complex/foo77.f +45 -0
- numpy/f2py/tests/src/return_complex/foo90.f90 +48 -0
- numpy/f2py/tests/src/return_integer/foo77.f +56 -0
- numpy/f2py/tests/src/return_integer/foo90.f90 +59 -0
- numpy/f2py/tests/src/return_logical/foo77.f +56 -0
- numpy/f2py/tests/src/return_logical/foo90.f90 +59 -0
- numpy/f2py/tests/src/return_real/foo77.f +45 -0
- numpy/f2py/tests/src/return_real/foo90.f90 +48 -0
- numpy/f2py/tests/src/routines/funcfortranname.f +5 -0
- numpy/f2py/tests/src/routines/funcfortranname.pyf +11 -0
- numpy/f2py/tests/src/routines/subrout.f +4 -0
- numpy/f2py/tests/src/routines/subrout.pyf +10 -0
- numpy/f2py/tests/src/size/foo.f90 +44 -0
- numpy/f2py/tests/src/string/char.f90 +29 -0
- numpy/f2py/tests/src/string/fixed_string.f90 +34 -0
- numpy/f2py/tests/src/string/gh24008.f +8 -0
- numpy/f2py/tests/src/string/gh24662.f90 +7 -0
- numpy/f2py/tests/src/string/gh25286.f90 +14 -0
- numpy/f2py/tests/src/string/gh25286.pyf +12 -0
- numpy/f2py/tests/src/string/gh25286_bc.pyf +12 -0
- numpy/f2py/tests/src/string/scalar_string.f90 +9 -0
- numpy/f2py/tests/src/string/string.f +12 -0
- numpy/f2py/tests/src/value_attrspec/gh21665.f90 +9 -0
- numpy/f2py/tests/test_abstract_interface.py +26 -0
- numpy/f2py/tests/test_array_from_pyobj.py +678 -0
- numpy/f2py/tests/test_assumed_shape.py +50 -0
- numpy/f2py/tests/test_block_docstring.py +20 -0
- numpy/f2py/tests/test_callback.py +263 -0
- numpy/f2py/tests/test_character.py +641 -0
- numpy/f2py/tests/test_common.py +23 -0
- numpy/f2py/tests/test_crackfortran.py +421 -0
- numpy/f2py/tests/test_data.py +71 -0
- numpy/f2py/tests/test_docs.py +66 -0
- numpy/f2py/tests/test_f2cmap.py +17 -0
- numpy/f2py/tests/test_f2py2e.py +983 -0
- numpy/f2py/tests/test_isoc.py +56 -0
- numpy/f2py/tests/test_kind.py +52 -0
- numpy/f2py/tests/test_mixed.py +35 -0
- numpy/f2py/tests/test_modules.py +83 -0
- numpy/f2py/tests/test_parameter.py +129 -0
- numpy/f2py/tests/test_pyf_src.py +43 -0
- numpy/f2py/tests/test_quoted_character.py +18 -0
- numpy/f2py/tests/test_regression.py +187 -0
- numpy/f2py/tests/test_return_character.py +48 -0
- numpy/f2py/tests/test_return_complex.py +67 -0
- numpy/f2py/tests/test_return_integer.py +55 -0
- numpy/f2py/tests/test_return_logical.py +65 -0
- numpy/f2py/tests/test_return_real.py +109 -0
- numpy/f2py/tests/test_routines.py +29 -0
- numpy/f2py/tests/test_semicolon_split.py +75 -0
- numpy/f2py/tests/test_size.py +45 -0
- numpy/f2py/tests/test_string.py +100 -0
- numpy/f2py/tests/test_symbolic.py +500 -0
- numpy/f2py/tests/test_value_attrspec.py +15 -0
- numpy/f2py/tests/util.py +442 -0
- numpy/f2py/use_rules.py +99 -0
- numpy/f2py/use_rules.pyi +9 -0
- numpy/fft/__init__.py +213 -0
- numpy/fft/__init__.pyi +38 -0
- numpy/fft/_helper.py +235 -0
- numpy/fft/_helper.pyi +44 -0
- numpy/fft/_pocketfft.py +1693 -0
- numpy/fft/_pocketfft.pyi +137 -0
- numpy/fft/_pocketfft_umath.pypy311-pp73-darwin.so +0 -0
- numpy/fft/tests/__init__.py +0 -0
- numpy/fft/tests/test_helper.py +167 -0
- numpy/fft/tests/test_pocketfft.py +589 -0
- numpy/lib/__init__.py +97 -0
- numpy/lib/__init__.pyi +52 -0
- numpy/lib/_array_utils_impl.py +62 -0
- numpy/lib/_array_utils_impl.pyi +10 -0
- numpy/lib/_arraypad_impl.py +926 -0
- numpy/lib/_arraypad_impl.pyi +88 -0
- numpy/lib/_arraysetops_impl.py +1158 -0
- numpy/lib/_arraysetops_impl.pyi +462 -0
- numpy/lib/_arrayterator_impl.py +224 -0
- numpy/lib/_arrayterator_impl.pyi +45 -0
- numpy/lib/_datasource.py +700 -0
- numpy/lib/_datasource.pyi +30 -0
- numpy/lib/_format_impl.py +1036 -0
- numpy/lib/_format_impl.pyi +56 -0
- numpy/lib/_function_base_impl.py +5760 -0
- numpy/lib/_function_base_impl.pyi +2324 -0
- numpy/lib/_histograms_impl.py +1085 -0
- numpy/lib/_histograms_impl.pyi +40 -0
- numpy/lib/_index_tricks_impl.py +1048 -0
- numpy/lib/_index_tricks_impl.pyi +267 -0
- numpy/lib/_iotools.py +900 -0
- numpy/lib/_iotools.pyi +116 -0
- numpy/lib/_nanfunctions_impl.py +2006 -0
- numpy/lib/_nanfunctions_impl.pyi +48 -0
- numpy/lib/_npyio_impl.py +2583 -0
- numpy/lib/_npyio_impl.pyi +299 -0
- numpy/lib/_polynomial_impl.py +1465 -0
- numpy/lib/_polynomial_impl.pyi +338 -0
- numpy/lib/_scimath_impl.py +642 -0
- numpy/lib/_scimath_impl.pyi +93 -0
- numpy/lib/_shape_base_impl.py +1289 -0
- numpy/lib/_shape_base_impl.pyi +236 -0
- numpy/lib/_stride_tricks_impl.py +582 -0
- numpy/lib/_stride_tricks_impl.pyi +73 -0
- numpy/lib/_twodim_base_impl.py +1201 -0
- numpy/lib/_twodim_base_impl.pyi +408 -0
- numpy/lib/_type_check_impl.py +710 -0
- numpy/lib/_type_check_impl.pyi +348 -0
- numpy/lib/_ufunclike_impl.py +199 -0
- numpy/lib/_ufunclike_impl.pyi +60 -0
- numpy/lib/_user_array_impl.py +310 -0
- numpy/lib/_user_array_impl.pyi +226 -0
- numpy/lib/_utils_impl.py +784 -0
- numpy/lib/_utils_impl.pyi +22 -0
- numpy/lib/_version.py +153 -0
- numpy/lib/_version.pyi +17 -0
- numpy/lib/array_utils.py +7 -0
- numpy/lib/array_utils.pyi +6 -0
- numpy/lib/format.py +24 -0
- numpy/lib/format.pyi +24 -0
- numpy/lib/introspect.py +94 -0
- numpy/lib/introspect.pyi +3 -0
- numpy/lib/mixins.py +180 -0
- numpy/lib/mixins.pyi +78 -0
- numpy/lib/npyio.py +1 -0
- numpy/lib/npyio.pyi +5 -0
- numpy/lib/recfunctions.py +1681 -0
- numpy/lib/recfunctions.pyi +444 -0
- numpy/lib/scimath.py +13 -0
- numpy/lib/scimath.pyi +12 -0
- numpy/lib/stride_tricks.py +1 -0
- numpy/lib/stride_tricks.pyi +4 -0
- numpy/lib/tests/__init__.py +0 -0
- numpy/lib/tests/data/py2-np0-objarr.npy +0 -0
- numpy/lib/tests/data/py2-objarr.npy +0 -0
- numpy/lib/tests/data/py2-objarr.npz +0 -0
- numpy/lib/tests/data/py3-objarr.npy +0 -0
- numpy/lib/tests/data/py3-objarr.npz +0 -0
- numpy/lib/tests/data/python3.npy +0 -0
- numpy/lib/tests/data/win64python2.npy +0 -0
- numpy/lib/tests/test__datasource.py +328 -0
- numpy/lib/tests/test__iotools.py +358 -0
- numpy/lib/tests/test__version.py +64 -0
- numpy/lib/tests/test_array_utils.py +32 -0
- numpy/lib/tests/test_arraypad.py +1427 -0
- numpy/lib/tests/test_arraysetops.py +1302 -0
- numpy/lib/tests/test_arrayterator.py +45 -0
- numpy/lib/tests/test_format.py +1054 -0
- numpy/lib/tests/test_function_base.py +4750 -0
- numpy/lib/tests/test_histograms.py +855 -0
- numpy/lib/tests/test_index_tricks.py +693 -0
- numpy/lib/tests/test_io.py +2857 -0
- numpy/lib/tests/test_loadtxt.py +1099 -0
- numpy/lib/tests/test_mixins.py +215 -0
- numpy/lib/tests/test_nanfunctions.py +1438 -0
- numpy/lib/tests/test_packbits.py +376 -0
- numpy/lib/tests/test_polynomial.py +325 -0
- numpy/lib/tests/test_recfunctions.py +1042 -0
- numpy/lib/tests/test_regression.py +231 -0
- numpy/lib/tests/test_shape_base.py +813 -0
- numpy/lib/tests/test_stride_tricks.py +655 -0
- numpy/lib/tests/test_twodim_base.py +559 -0
- numpy/lib/tests/test_type_check.py +473 -0
- numpy/lib/tests/test_ufunclike.py +97 -0
- numpy/lib/tests/test_utils.py +80 -0
- numpy/lib/user_array.py +1 -0
- numpy/lib/user_array.pyi +1 -0
- numpy/linalg/__init__.py +95 -0
- numpy/linalg/__init__.pyi +71 -0
- numpy/linalg/_linalg.py +3657 -0
- numpy/linalg/_linalg.pyi +548 -0
- numpy/linalg/_umath_linalg.pyi +60 -0
- numpy/linalg/_umath_linalg.pypy311-pp73-darwin.so +0 -0
- numpy/linalg/lapack_lite.pyi +143 -0
- numpy/linalg/lapack_lite.pypy311-pp73-darwin.so +0 -0
- numpy/linalg/tests/__init__.py +0 -0
- numpy/linalg/tests/test_deprecations.py +21 -0
- numpy/linalg/tests/test_linalg.py +2442 -0
- numpy/linalg/tests/test_regression.py +182 -0
- numpy/ma/API_CHANGES.txt +135 -0
- numpy/ma/LICENSE +24 -0
- numpy/ma/README.rst +236 -0
- numpy/ma/__init__.py +53 -0
- numpy/ma/__init__.pyi +458 -0
- numpy/ma/core.py +8929 -0
- numpy/ma/core.pyi +3720 -0
- numpy/ma/extras.py +2266 -0
- numpy/ma/extras.pyi +297 -0
- numpy/ma/mrecords.py +762 -0
- numpy/ma/mrecords.pyi +96 -0
- numpy/ma/tests/__init__.py +0 -0
- numpy/ma/tests/test_arrayobject.py +40 -0
- numpy/ma/tests/test_core.py +6008 -0
- numpy/ma/tests/test_deprecations.py +65 -0
- numpy/ma/tests/test_extras.py +1945 -0
- numpy/ma/tests/test_mrecords.py +495 -0
- numpy/ma/tests/test_old_ma.py +939 -0
- numpy/ma/tests/test_regression.py +83 -0
- numpy/ma/tests/test_subclassing.py +469 -0
- numpy/ma/testutils.py +294 -0
- numpy/ma/testutils.pyi +69 -0
- numpy/matlib.py +380 -0
- numpy/matlib.pyi +580 -0
- numpy/matrixlib/__init__.py +12 -0
- numpy/matrixlib/__init__.pyi +3 -0
- numpy/matrixlib/defmatrix.py +1119 -0
- numpy/matrixlib/defmatrix.pyi +218 -0
- numpy/matrixlib/tests/__init__.py +0 -0
- numpy/matrixlib/tests/test_defmatrix.py +455 -0
- numpy/matrixlib/tests/test_interaction.py +360 -0
- numpy/matrixlib/tests/test_masked_matrix.py +240 -0
- numpy/matrixlib/tests/test_matrix_linalg.py +110 -0
- numpy/matrixlib/tests/test_multiarray.py +17 -0
- numpy/matrixlib/tests/test_numeric.py +18 -0
- numpy/matrixlib/tests/test_regression.py +31 -0
- numpy/polynomial/__init__.py +187 -0
- numpy/polynomial/__init__.pyi +31 -0
- numpy/polynomial/_polybase.py +1191 -0
- numpy/polynomial/_polybase.pyi +262 -0
- numpy/polynomial/_polytypes.pyi +501 -0
- numpy/polynomial/chebyshev.py +2001 -0
- numpy/polynomial/chebyshev.pyi +180 -0
- numpy/polynomial/hermite.py +1738 -0
- numpy/polynomial/hermite.pyi +106 -0
- numpy/polynomial/hermite_e.py +1640 -0
- numpy/polynomial/hermite_e.pyi +106 -0
- numpy/polynomial/laguerre.py +1673 -0
- numpy/polynomial/laguerre.pyi +100 -0
- numpy/polynomial/legendre.py +1603 -0
- numpy/polynomial/legendre.pyi +100 -0
- numpy/polynomial/polynomial.py +1625 -0
- numpy/polynomial/polynomial.pyi +109 -0
- numpy/polynomial/polyutils.py +759 -0
- numpy/polynomial/polyutils.pyi +307 -0
- numpy/polynomial/tests/__init__.py +0 -0
- numpy/polynomial/tests/test_chebyshev.py +618 -0
- numpy/polynomial/tests/test_classes.py +613 -0
- numpy/polynomial/tests/test_hermite.py +553 -0
- numpy/polynomial/tests/test_hermite_e.py +554 -0
- numpy/polynomial/tests/test_laguerre.py +535 -0
- numpy/polynomial/tests/test_legendre.py +566 -0
- numpy/polynomial/tests/test_polynomial.py +691 -0
- numpy/polynomial/tests/test_polyutils.py +123 -0
- numpy/polynomial/tests/test_printing.py +557 -0
- numpy/polynomial/tests/test_symbol.py +217 -0
- numpy/py.typed +0 -0
- numpy/random/LICENSE.md +71 -0
- numpy/random/__init__.pxd +14 -0
- numpy/random/__init__.py +213 -0
- numpy/random/__init__.pyi +124 -0
- numpy/random/_bounded_integers.pxd +29 -0
- numpy/random/_bounded_integers.pyi +1 -0
- numpy/random/_bounded_integers.pypy311-pp73-darwin.so +0 -0
- numpy/random/_common.pxd +110 -0
- numpy/random/_common.pyi +16 -0
- numpy/random/_common.pypy311-pp73-darwin.so +0 -0
- numpy/random/_examples/cffi/extending.py +44 -0
- numpy/random/_examples/cffi/parse.py +53 -0
- numpy/random/_examples/cython/extending.pyx +77 -0
- numpy/random/_examples/cython/extending_distributions.pyx +117 -0
- numpy/random/_examples/cython/meson.build +53 -0
- numpy/random/_examples/numba/extending.py +86 -0
- numpy/random/_examples/numba/extending_distributions.py +67 -0
- numpy/random/_generator.pyi +862 -0
- numpy/random/_generator.pypy311-pp73-darwin.so +0 -0
- numpy/random/_mt19937.pyi +27 -0
- numpy/random/_mt19937.pypy311-pp73-darwin.so +0 -0
- numpy/random/_pcg64.pyi +41 -0
- numpy/random/_pcg64.pypy311-pp73-darwin.so +0 -0
- numpy/random/_philox.pyi +36 -0
- numpy/random/_philox.pypy311-pp73-darwin.so +0 -0
- numpy/random/_pickle.py +88 -0
- numpy/random/_pickle.pyi +43 -0
- numpy/random/_sfc64.pyi +25 -0
- numpy/random/_sfc64.pypy311-pp73-darwin.so +0 -0
- numpy/random/bit_generator.pxd +40 -0
- numpy/random/bit_generator.pyi +123 -0
- numpy/random/bit_generator.pypy311-pp73-darwin.so +0 -0
- numpy/random/c_distributions.pxd +119 -0
- numpy/random/lib/libnpyrandom.a +0 -0
- numpy/random/mtrand.pyi +759 -0
- numpy/random/mtrand.pypy311-pp73-darwin.so +0 -0
- numpy/random/tests/__init__.py +0 -0
- numpy/random/tests/data/__init__.py +0 -0
- numpy/random/tests/data/generator_pcg64_np121.pkl.gz +0 -0
- numpy/random/tests/data/generator_pcg64_np126.pkl.gz +0 -0
- numpy/random/tests/data/mt19937-testset-1.csv +1001 -0
- numpy/random/tests/data/mt19937-testset-2.csv +1001 -0
- numpy/random/tests/data/pcg64-testset-1.csv +1001 -0
- numpy/random/tests/data/pcg64-testset-2.csv +1001 -0
- numpy/random/tests/data/pcg64dxsm-testset-1.csv +1001 -0
- numpy/random/tests/data/pcg64dxsm-testset-2.csv +1001 -0
- numpy/random/tests/data/philox-testset-1.csv +1001 -0
- numpy/random/tests/data/philox-testset-2.csv +1001 -0
- numpy/random/tests/data/sfc64-testset-1.csv +1001 -0
- numpy/random/tests/data/sfc64-testset-2.csv +1001 -0
- numpy/random/tests/data/sfc64_np126.pkl.gz +0 -0
- numpy/random/tests/test_direct.py +595 -0
- numpy/random/tests/test_extending.py +131 -0
- numpy/random/tests/test_generator_mt19937.py +2825 -0
- numpy/random/tests/test_generator_mt19937_regressions.py +221 -0
- numpy/random/tests/test_random.py +1724 -0
- numpy/random/tests/test_randomstate.py +2099 -0
- numpy/random/tests/test_randomstate_regression.py +213 -0
- numpy/random/tests/test_regression.py +175 -0
- numpy/random/tests/test_seed_sequence.py +79 -0
- numpy/random/tests/test_smoke.py +882 -0
- numpy/rec/__init__.py +2 -0
- numpy/rec/__init__.pyi +23 -0
- numpy/strings/__init__.py +2 -0
- numpy/strings/__init__.pyi +97 -0
- numpy/testing/__init__.py +22 -0
- numpy/testing/__init__.pyi +107 -0
- numpy/testing/_private/__init__.py +0 -0
- numpy/testing/_private/__init__.pyi +0 -0
- numpy/testing/_private/extbuild.py +250 -0
- numpy/testing/_private/extbuild.pyi +25 -0
- numpy/testing/_private/utils.py +2830 -0
- numpy/testing/_private/utils.pyi +505 -0
- numpy/testing/overrides.py +84 -0
- numpy/testing/overrides.pyi +10 -0
- numpy/testing/print_coercion_tables.py +207 -0
- numpy/testing/print_coercion_tables.pyi +26 -0
- numpy/testing/tests/__init__.py +0 -0
- numpy/testing/tests/test_utils.py +2123 -0
- numpy/tests/__init__.py +0 -0
- numpy/tests/test__all__.py +10 -0
- numpy/tests/test_configtool.py +51 -0
- numpy/tests/test_ctypeslib.py +383 -0
- numpy/tests/test_lazyloading.py +42 -0
- numpy/tests/test_matlib.py +59 -0
- numpy/tests/test_numpy_config.py +47 -0
- numpy/tests/test_numpy_version.py +54 -0
- numpy/tests/test_public_api.py +807 -0
- numpy/tests/test_reloading.py +76 -0
- numpy/tests/test_scripts.py +48 -0
- numpy/tests/test_warnings.py +79 -0
- numpy/typing/__init__.py +233 -0
- numpy/typing/__init__.pyi +3 -0
- numpy/typing/mypy_plugin.py +200 -0
- numpy/typing/tests/__init__.py +0 -0
- numpy/typing/tests/data/fail/arithmetic.pyi +126 -0
- numpy/typing/tests/data/fail/array_constructors.pyi +34 -0
- numpy/typing/tests/data/fail/array_like.pyi +15 -0
- numpy/typing/tests/data/fail/array_pad.pyi +6 -0
- numpy/typing/tests/data/fail/arrayprint.pyi +15 -0
- numpy/typing/tests/data/fail/arrayterator.pyi +14 -0
- numpy/typing/tests/data/fail/bitwise_ops.pyi +17 -0
- numpy/typing/tests/data/fail/char.pyi +63 -0
- numpy/typing/tests/data/fail/chararray.pyi +61 -0
- numpy/typing/tests/data/fail/comparisons.pyi +27 -0
- numpy/typing/tests/data/fail/constants.pyi +3 -0
- numpy/typing/tests/data/fail/datasource.pyi +16 -0
- numpy/typing/tests/data/fail/dtype.pyi +17 -0
- numpy/typing/tests/data/fail/einsumfunc.pyi +12 -0
- numpy/typing/tests/data/fail/flatiter.pyi +38 -0
- numpy/typing/tests/data/fail/fromnumeric.pyi +148 -0
- numpy/typing/tests/data/fail/histograms.pyi +12 -0
- numpy/typing/tests/data/fail/index_tricks.pyi +14 -0
- numpy/typing/tests/data/fail/lib_function_base.pyi +60 -0
- numpy/typing/tests/data/fail/lib_polynomial.pyi +29 -0
- numpy/typing/tests/data/fail/lib_utils.pyi +3 -0
- numpy/typing/tests/data/fail/lib_version.pyi +6 -0
- numpy/typing/tests/data/fail/linalg.pyi +52 -0
- numpy/typing/tests/data/fail/ma.pyi +155 -0
- numpy/typing/tests/data/fail/memmap.pyi +5 -0
- numpy/typing/tests/data/fail/modules.pyi +17 -0
- numpy/typing/tests/data/fail/multiarray.pyi +52 -0
- numpy/typing/tests/data/fail/ndarray.pyi +11 -0
- numpy/typing/tests/data/fail/ndarray_misc.pyi +49 -0
- numpy/typing/tests/data/fail/nditer.pyi +8 -0
- numpy/typing/tests/data/fail/nested_sequence.pyi +17 -0
- numpy/typing/tests/data/fail/npyio.pyi +24 -0
- numpy/typing/tests/data/fail/numerictypes.pyi +5 -0
- numpy/typing/tests/data/fail/random.pyi +62 -0
- numpy/typing/tests/data/fail/rec.pyi +17 -0
- numpy/typing/tests/data/fail/scalars.pyi +86 -0
- numpy/typing/tests/data/fail/shape.pyi +7 -0
- numpy/typing/tests/data/fail/shape_base.pyi +8 -0
- numpy/typing/tests/data/fail/stride_tricks.pyi +9 -0
- numpy/typing/tests/data/fail/strings.pyi +52 -0
- numpy/typing/tests/data/fail/testing.pyi +28 -0
- numpy/typing/tests/data/fail/twodim_base.pyi +39 -0
- numpy/typing/tests/data/fail/type_check.pyi +12 -0
- numpy/typing/tests/data/fail/ufunc_config.pyi +21 -0
- numpy/typing/tests/data/fail/ufunclike.pyi +21 -0
- numpy/typing/tests/data/fail/ufuncs.pyi +17 -0
- numpy/typing/tests/data/fail/warnings_and_errors.pyi +5 -0
- numpy/typing/tests/data/misc/extended_precision.pyi +9 -0
- numpy/typing/tests/data/mypy.ini +8 -0
- numpy/typing/tests/data/pass/arithmetic.py +614 -0
- numpy/typing/tests/data/pass/array_constructors.py +138 -0
- numpy/typing/tests/data/pass/array_like.py +43 -0
- numpy/typing/tests/data/pass/arrayprint.py +37 -0
- numpy/typing/tests/data/pass/arrayterator.py +28 -0
- numpy/typing/tests/data/pass/bitwise_ops.py +131 -0
- numpy/typing/tests/data/pass/comparisons.py +316 -0
- numpy/typing/tests/data/pass/dtype.py +57 -0
- numpy/typing/tests/data/pass/einsumfunc.py +36 -0
- numpy/typing/tests/data/pass/flatiter.py +26 -0
- numpy/typing/tests/data/pass/fromnumeric.py +272 -0
- numpy/typing/tests/data/pass/index_tricks.py +62 -0
- numpy/typing/tests/data/pass/lib_user_array.py +22 -0
- numpy/typing/tests/data/pass/lib_utils.py +19 -0
- numpy/typing/tests/data/pass/lib_version.py +18 -0
- numpy/typing/tests/data/pass/literal.py +52 -0
- numpy/typing/tests/data/pass/ma.py +199 -0
- numpy/typing/tests/data/pass/mod.py +149 -0
- numpy/typing/tests/data/pass/modules.py +45 -0
- numpy/typing/tests/data/pass/multiarray.py +77 -0
- numpy/typing/tests/data/pass/ndarray_conversion.py +81 -0
- numpy/typing/tests/data/pass/ndarray_misc.py +199 -0
- numpy/typing/tests/data/pass/ndarray_shape_manipulation.py +47 -0
- numpy/typing/tests/data/pass/nditer.py +4 -0
- numpy/typing/tests/data/pass/numeric.py +90 -0
- numpy/typing/tests/data/pass/numerictypes.py +17 -0
- numpy/typing/tests/data/pass/random.py +1498 -0
- numpy/typing/tests/data/pass/recfunctions.py +164 -0
- numpy/typing/tests/data/pass/scalars.py +249 -0
- numpy/typing/tests/data/pass/shape.py +19 -0
- numpy/typing/tests/data/pass/simple.py +170 -0
- numpy/typing/tests/data/pass/ufunc_config.py +64 -0
- numpy/typing/tests/data/pass/ufunclike.py +52 -0
- numpy/typing/tests/data/pass/ufuncs.py +16 -0
- numpy/typing/tests/data/pass/warnings_and_errors.py +6 -0
- numpy/typing/tests/data/reveal/arithmetic.pyi +719 -0
- numpy/typing/tests/data/reveal/array_api_info.pyi +70 -0
- numpy/typing/tests/data/reveal/array_constructors.pyi +277 -0
- numpy/typing/tests/data/reveal/arraypad.pyi +27 -0
- numpy/typing/tests/data/reveal/arrayprint.pyi +25 -0
- numpy/typing/tests/data/reveal/arraysetops.pyi +74 -0
- numpy/typing/tests/data/reveal/arrayterator.pyi +27 -0
- numpy/typing/tests/data/reveal/bitwise_ops.pyi +166 -0
- numpy/typing/tests/data/reveal/char.pyi +225 -0
- numpy/typing/tests/data/reveal/chararray.pyi +138 -0
- numpy/typing/tests/data/reveal/comparisons.pyi +264 -0
- numpy/typing/tests/data/reveal/constants.pyi +14 -0
- numpy/typing/tests/data/reveal/ctypeslib.pyi +81 -0
- numpy/typing/tests/data/reveal/datasource.pyi +23 -0
- numpy/typing/tests/data/reveal/dtype.pyi +132 -0
- numpy/typing/tests/data/reveal/einsumfunc.pyi +39 -0
- numpy/typing/tests/data/reveal/emath.pyi +54 -0
- numpy/typing/tests/data/reveal/fft.pyi +37 -0
- numpy/typing/tests/data/reveal/flatiter.pyi +86 -0
- numpy/typing/tests/data/reveal/fromnumeric.pyi +347 -0
- numpy/typing/tests/data/reveal/getlimits.pyi +53 -0
- numpy/typing/tests/data/reveal/histograms.pyi +25 -0
- numpy/typing/tests/data/reveal/index_tricks.pyi +70 -0
- numpy/typing/tests/data/reveal/lib_function_base.pyi +409 -0
- numpy/typing/tests/data/reveal/lib_polynomial.pyi +147 -0
- numpy/typing/tests/data/reveal/lib_utils.pyi +17 -0
- numpy/typing/tests/data/reveal/lib_version.pyi +20 -0
- numpy/typing/tests/data/reveal/linalg.pyi +154 -0
- numpy/typing/tests/data/reveal/ma.pyi +1098 -0
- numpy/typing/tests/data/reveal/matrix.pyi +73 -0
- numpy/typing/tests/data/reveal/memmap.pyi +19 -0
- numpy/typing/tests/data/reveal/mod.pyi +178 -0
- numpy/typing/tests/data/reveal/modules.pyi +51 -0
- numpy/typing/tests/data/reveal/multiarray.pyi +197 -0
- numpy/typing/tests/data/reveal/nbit_base_example.pyi +20 -0
- numpy/typing/tests/data/reveal/ndarray_assignability.pyi +82 -0
- numpy/typing/tests/data/reveal/ndarray_conversion.pyi +83 -0
- numpy/typing/tests/data/reveal/ndarray_misc.pyi +246 -0
- numpy/typing/tests/data/reveal/ndarray_shape_manipulation.pyi +47 -0
- numpy/typing/tests/data/reveal/nditer.pyi +49 -0
- numpy/typing/tests/data/reveal/nested_sequence.pyi +25 -0
- numpy/typing/tests/data/reveal/npyio.pyi +83 -0
- numpy/typing/tests/data/reveal/numeric.pyi +170 -0
- numpy/typing/tests/data/reveal/numerictypes.pyi +16 -0
- numpy/typing/tests/data/reveal/polynomial_polybase.pyi +217 -0
- numpy/typing/tests/data/reveal/polynomial_polyutils.pyi +218 -0
- numpy/typing/tests/data/reveal/polynomial_series.pyi +138 -0
- numpy/typing/tests/data/reveal/random.pyi +1546 -0
- numpy/typing/tests/data/reveal/rec.pyi +171 -0
- numpy/typing/tests/data/reveal/scalars.pyi +191 -0
- numpy/typing/tests/data/reveal/shape.pyi +13 -0
- numpy/typing/tests/data/reveal/shape_base.pyi +52 -0
- numpy/typing/tests/data/reveal/stride_tricks.pyi +27 -0
- numpy/typing/tests/data/reveal/strings.pyi +196 -0
- numpy/typing/tests/data/reveal/testing.pyi +198 -0
- numpy/typing/tests/data/reveal/twodim_base.pyi +225 -0
- numpy/typing/tests/data/reveal/type_check.pyi +67 -0
- numpy/typing/tests/data/reveal/ufunc_config.pyi +29 -0
- numpy/typing/tests/data/reveal/ufunclike.pyi +31 -0
- numpy/typing/tests/data/reveal/ufuncs.pyi +142 -0
- numpy/typing/tests/data/reveal/warnings_and_errors.pyi +11 -0
- numpy/typing/tests/test_isfile.py +38 -0
- numpy/typing/tests/test_runtime.py +110 -0
- numpy/typing/tests/test_typing.py +205 -0
- numpy/version.py +11 -0
- numpy/version.pyi +9 -0
- numpy-2.4.1.dist-info/METADATA +139 -0
- numpy-2.4.1.dist-info/RECORD +1039 -0
- numpy-2.4.1.dist-info/WHEEL +6 -0
- numpy-2.4.1.dist-info/entry_points.txt +13 -0
- numpy-2.4.1.dist-info/licenses/LICENSE.txt +935 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/include/numpy/libdivide/LICENSE.txt +21 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/common/pythoncapi-compat/COPYING +14 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/highway/LICENSE +371 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/multiarray/dragon4_LICENSE.txt +27 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/npysort/x86-simd-sort/LICENSE.md +28 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/umath/svml/LICENSE +30 -0
- numpy-2.4.1.dist-info/licenses/numpy/fft/pocketfft/LICENSE.md +25 -0
- numpy-2.4.1.dist-info/licenses/numpy/linalg/lapack_lite/LICENSE.txt +48 -0
- numpy-2.4.1.dist-info/licenses/numpy/ma/LICENSE +24 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/LICENSE.md +71 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/distributions/LICENSE.md +61 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/mt19937/LICENSE.md +61 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/pcg64/LICENSE.md +22 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/philox/LICENSE.md +31 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/sfc64/LICENSE.md +27 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/splitmix64/LICENSE.md +9 -0
|
@@ -0,0 +1,1982 @@
|
|
|
1
|
+
#ifndef NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_
|
|
2
|
+
#define NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_
|
|
3
|
+
|
|
4
|
+
#include "npy_common.h"
|
|
5
|
+
#include "npy_endian.h"
|
|
6
|
+
#include "npy_cpu.h"
|
|
7
|
+
#include "utils.h"
|
|
8
|
+
|
|
9
|
+
#ifdef __cplusplus
|
|
10
|
+
extern "C" {
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN
|
|
14
|
+
|
|
15
|
+
/* Always allow threading unless it was explicitly disabled at build time */
|
|
16
|
+
#if !NPY_NO_SMP
|
|
17
|
+
#define NPY_ALLOW_THREADS 1
|
|
18
|
+
#else
|
|
19
|
+
#define NPY_ALLOW_THREADS 0
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
#ifndef __has_extension
|
|
23
|
+
#define __has_extension(x) 0
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* There are several places in the code where an array of dimensions
|
|
28
|
+
* is allocated statically. This is the size of that static
|
|
29
|
+
* allocation.
|
|
30
|
+
*
|
|
31
|
+
* The array creation itself could have arbitrary dimensions but all
|
|
32
|
+
* the places where static allocation is used would need to be changed
|
|
33
|
+
* to dynamic (including inside of several structures)
|
|
34
|
+
*
|
|
35
|
+
* As of NumPy 2.0, we strongly discourage the downstream use of NPY_MAXDIMS,
|
|
36
|
+
* but since auditing everything seems a big ask, define it as 64.
|
|
37
|
+
* A future version could:
|
|
38
|
+
* - Increase or remove the limit and require recompilation (like 2.0 did)
|
|
39
|
+
* - Deprecate or remove the macro but keep the limit (at basically any time)
|
|
40
|
+
*/
|
|
41
|
+
#define NPY_MAXDIMS 64
|
|
42
|
+
/* We cannot change this as it would break ABI: */
|
|
43
|
+
#define NPY_MAXDIMS_LEGACY_ITERS 32
|
|
44
|
+
/* NPY_MAXARGS is version dependent and defined in npy_2_compat.h */
|
|
45
|
+
|
|
46
|
+
/* Used for Converter Functions "O&" code in ParseTuple */
|
|
47
|
+
#define NPY_FAIL 0
|
|
48
|
+
#define NPY_SUCCEED 1
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
enum NPY_TYPES { NPY_BOOL=0,
|
|
52
|
+
NPY_BYTE, NPY_UBYTE,
|
|
53
|
+
NPY_SHORT, NPY_USHORT,
|
|
54
|
+
NPY_INT, NPY_UINT,
|
|
55
|
+
NPY_LONG, NPY_ULONG,
|
|
56
|
+
NPY_LONGLONG, NPY_ULONGLONG,
|
|
57
|
+
NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE,
|
|
58
|
+
NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE,
|
|
59
|
+
NPY_OBJECT=17,
|
|
60
|
+
NPY_STRING, NPY_UNICODE,
|
|
61
|
+
NPY_VOID,
|
|
62
|
+
/*
|
|
63
|
+
* New 1.6 types appended, may be integrated
|
|
64
|
+
* into the above in 2.0.
|
|
65
|
+
*/
|
|
66
|
+
NPY_DATETIME, NPY_TIMEDELTA, NPY_HALF,
|
|
67
|
+
|
|
68
|
+
NPY_CHAR, /* Deprecated, will raise if used */
|
|
69
|
+
|
|
70
|
+
/* The number of *legacy* dtypes */
|
|
71
|
+
NPY_NTYPES_LEGACY=24,
|
|
72
|
+
|
|
73
|
+
/* assign a high value to avoid changing this in the
|
|
74
|
+
future when new dtypes are added */
|
|
75
|
+
NPY_NOTYPE=25,
|
|
76
|
+
|
|
77
|
+
NPY_USERDEF=256, /* leave room for characters */
|
|
78
|
+
|
|
79
|
+
/* The number of types not including the new 1.6 types */
|
|
80
|
+
NPY_NTYPES_ABI_COMPATIBLE=21,
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* New DTypes which do not share the legacy layout
|
|
84
|
+
* (added after NumPy 2.0). VSTRING is the first of these
|
|
85
|
+
* we may open up a block for user-defined dtypes in the
|
|
86
|
+
* future.
|
|
87
|
+
*/
|
|
88
|
+
NPY_VSTRING=2056,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/* basetype array priority */
|
|
93
|
+
#define NPY_PRIORITY 0.0
|
|
94
|
+
|
|
95
|
+
/* default subtype priority */
|
|
96
|
+
#define NPY_SUBTYPE_PRIORITY 1.0
|
|
97
|
+
|
|
98
|
+
/* default scalar priority */
|
|
99
|
+
#define NPY_SCALAR_PRIORITY -1000000.0
|
|
100
|
+
|
|
101
|
+
/* How many floating point types are there (excluding half) */
|
|
102
|
+
#define NPY_NUM_FLOATTYPE 3
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* These characters correspond to the array type and the struct
|
|
106
|
+
* module
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
enum NPY_TYPECHAR {
|
|
110
|
+
NPY_BOOLLTR = '?',
|
|
111
|
+
NPY_BYTELTR = 'b',
|
|
112
|
+
NPY_UBYTELTR = 'B',
|
|
113
|
+
NPY_SHORTLTR = 'h',
|
|
114
|
+
NPY_USHORTLTR = 'H',
|
|
115
|
+
NPY_INTLTR = 'i',
|
|
116
|
+
NPY_UINTLTR = 'I',
|
|
117
|
+
NPY_LONGLTR = 'l',
|
|
118
|
+
NPY_ULONGLTR = 'L',
|
|
119
|
+
NPY_LONGLONGLTR = 'q',
|
|
120
|
+
NPY_ULONGLONGLTR = 'Q',
|
|
121
|
+
NPY_HALFLTR = 'e',
|
|
122
|
+
NPY_FLOATLTR = 'f',
|
|
123
|
+
NPY_DOUBLELTR = 'd',
|
|
124
|
+
NPY_LONGDOUBLELTR = 'g',
|
|
125
|
+
NPY_CFLOATLTR = 'F',
|
|
126
|
+
NPY_CDOUBLELTR = 'D',
|
|
127
|
+
NPY_CLONGDOUBLELTR = 'G',
|
|
128
|
+
NPY_OBJECTLTR = 'O',
|
|
129
|
+
NPY_STRINGLTR = 'S',
|
|
130
|
+
NPY_DEPRECATED_STRINGLTR2 = 'a',
|
|
131
|
+
NPY_UNICODELTR = 'U',
|
|
132
|
+
NPY_VOIDLTR = 'V',
|
|
133
|
+
NPY_DATETIMELTR = 'M',
|
|
134
|
+
NPY_TIMEDELTALTR = 'm',
|
|
135
|
+
NPY_CHARLTR = 'c',
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
* New non-legacy DTypes
|
|
139
|
+
*/
|
|
140
|
+
NPY_VSTRINGLTR = 'T',
|
|
141
|
+
|
|
142
|
+
/*
|
|
143
|
+
* Note, we removed `NPY_INTPLTR` due to changing its definition
|
|
144
|
+
* to 'n', rather than 'p'. On any typical platform this is the
|
|
145
|
+
* same integer. 'n' should be used for the `np.intp` with the same
|
|
146
|
+
* size as `size_t` while 'p' remains pointer sized.
|
|
147
|
+
*
|
|
148
|
+
* 'p', 'P', 'n', and 'N' are valid and defined explicitly
|
|
149
|
+
* in `arraytypes.c.src`.
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* These are for dtype 'kinds', not dtype 'typecodes'
|
|
154
|
+
* as the above are for.
|
|
155
|
+
*/
|
|
156
|
+
NPY_GENBOOLLTR ='b',
|
|
157
|
+
NPY_SIGNEDLTR = 'i',
|
|
158
|
+
NPY_UNSIGNEDLTR = 'u',
|
|
159
|
+
NPY_FLOATINGLTR = 'f',
|
|
160
|
+
NPY_COMPLEXLTR = 'c',
|
|
161
|
+
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/*
|
|
165
|
+
* Changing this may break Numpy API compatibility due to changing offsets in
|
|
166
|
+
* PyArray_ArrFuncs, so be careful. Here we have reused the mergesort slot for
|
|
167
|
+
* any kind of stable sort, the actual implementation will depend on the data
|
|
168
|
+
* type.
|
|
169
|
+
*
|
|
170
|
+
* Updated in NumPy 2.4
|
|
171
|
+
*
|
|
172
|
+
* Updated with new names denoting requirements rather than specifying a
|
|
173
|
+
* particular algorithm. All the previous values are reused in a way that
|
|
174
|
+
* should be downstream compatible, but the actual algorithms used may be
|
|
175
|
+
* different than before. The new approach should be more flexible and easier
|
|
176
|
+
* to update.
|
|
177
|
+
*
|
|
178
|
+
* Names with a leading underscore are private, and should only be used
|
|
179
|
+
* internally by NumPy.
|
|
180
|
+
*
|
|
181
|
+
* NPY_NSORTS remains the same for backwards compatibility, it should not be
|
|
182
|
+
* changed.
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
typedef enum {
|
|
186
|
+
_NPY_SORT_UNDEFINED = -1,
|
|
187
|
+
NPY_QUICKSORT = 0,
|
|
188
|
+
NPY_HEAPSORT = 1,
|
|
189
|
+
NPY_MERGESORT = 2,
|
|
190
|
+
NPY_STABLESORT = 2,
|
|
191
|
+
// new style names
|
|
192
|
+
_NPY_SORT_HEAPSORT = 1,
|
|
193
|
+
NPY_SORT_DEFAULT = 0,
|
|
194
|
+
NPY_SORT_STABLE = 2,
|
|
195
|
+
NPY_SORT_DESCENDING = 4,
|
|
196
|
+
} NPY_SORTKIND;
|
|
197
|
+
#define NPY_NSORTS (NPY_STABLESORT + 1)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
typedef enum {
|
|
201
|
+
NPY_INTROSELECT=0
|
|
202
|
+
} NPY_SELECTKIND;
|
|
203
|
+
#define NPY_NSELECTS (NPY_INTROSELECT + 1)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
typedef enum {
|
|
207
|
+
NPY_SEARCHLEFT=0,
|
|
208
|
+
NPY_SEARCHRIGHT=1
|
|
209
|
+
} NPY_SEARCHSIDE;
|
|
210
|
+
#define NPY_NSEARCHSIDES (NPY_SEARCHRIGHT + 1)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
typedef enum {
|
|
214
|
+
NPY_NOSCALAR=-1,
|
|
215
|
+
NPY_BOOL_SCALAR,
|
|
216
|
+
NPY_INTPOS_SCALAR,
|
|
217
|
+
NPY_INTNEG_SCALAR,
|
|
218
|
+
NPY_FLOAT_SCALAR,
|
|
219
|
+
NPY_COMPLEX_SCALAR,
|
|
220
|
+
NPY_OBJECT_SCALAR
|
|
221
|
+
} NPY_SCALARKIND;
|
|
222
|
+
#define NPY_NSCALARKINDS (NPY_OBJECT_SCALAR + 1)
|
|
223
|
+
|
|
224
|
+
/* For specifying array memory layout or iteration order */
|
|
225
|
+
typedef enum {
|
|
226
|
+
/* Fortran order if inputs are all Fortran, C otherwise */
|
|
227
|
+
NPY_ANYORDER=-1,
|
|
228
|
+
/* C order */
|
|
229
|
+
NPY_CORDER=0,
|
|
230
|
+
/* Fortran order */
|
|
231
|
+
NPY_FORTRANORDER=1,
|
|
232
|
+
/* An order as close to the inputs as possible */
|
|
233
|
+
NPY_KEEPORDER=2
|
|
234
|
+
} NPY_ORDER;
|
|
235
|
+
|
|
236
|
+
#if NPY_FEATURE_VERSION >= NPY_2_4_API_VERSION
|
|
237
|
+
/*
|
|
238
|
+
* check that no values overflow/change during casting
|
|
239
|
+
* Used explicitly only in the ArrayMethod creation or resolve_dtypes functions to
|
|
240
|
+
* indicate that a same-value cast is supported. In external APIs, use only
|
|
241
|
+
* NPY_SAME_VALUE_CASTING
|
|
242
|
+
*/
|
|
243
|
+
#define NPY_SAME_VALUE_CASTING_FLAG 64
|
|
244
|
+
#endif
|
|
245
|
+
|
|
246
|
+
/* For specifying allowed casting in operations which support it */
|
|
247
|
+
typedef enum {
|
|
248
|
+
_NPY_ERROR_OCCURRED_IN_CAST = -1,
|
|
249
|
+
/* Only allow identical types */
|
|
250
|
+
NPY_NO_CASTING=0,
|
|
251
|
+
/* Allow identical and byte swapped types */
|
|
252
|
+
NPY_EQUIV_CASTING=1,
|
|
253
|
+
/* Only allow safe casts */
|
|
254
|
+
NPY_SAFE_CASTING=2,
|
|
255
|
+
/* Allow safe casts or casts within the same kind */
|
|
256
|
+
NPY_SAME_KIND_CASTING=3,
|
|
257
|
+
/* Allow any casts */
|
|
258
|
+
NPY_UNSAFE_CASTING=4,
|
|
259
|
+
#if NPY_FEATURE_VERSION >= NPY_2_4_API_VERSION
|
|
260
|
+
NPY_SAME_VALUE_CASTING=NPY_UNSAFE_CASTING | NPY_SAME_VALUE_CASTING_FLAG,
|
|
261
|
+
#endif
|
|
262
|
+
} NPY_CASTING;
|
|
263
|
+
|
|
264
|
+
typedef enum {
|
|
265
|
+
NPY_CLIP=0,
|
|
266
|
+
NPY_WRAP=1,
|
|
267
|
+
NPY_RAISE=2
|
|
268
|
+
} NPY_CLIPMODE;
|
|
269
|
+
|
|
270
|
+
typedef enum {
|
|
271
|
+
NPY_VALID=0,
|
|
272
|
+
NPY_SAME=1,
|
|
273
|
+
NPY_FULL=2
|
|
274
|
+
} NPY_CORRELATEMODE;
|
|
275
|
+
|
|
276
|
+
/* The special not-a-time (NaT) value */
|
|
277
|
+
#define NPY_DATETIME_NAT NPY_MIN_INT64
|
|
278
|
+
|
|
279
|
+
/*
|
|
280
|
+
* Upper bound on the length of a DATETIME ISO 8601 string
|
|
281
|
+
* YEAR: 21 (64-bit year)
|
|
282
|
+
* MONTH: 3
|
|
283
|
+
* DAY: 3
|
|
284
|
+
* HOURS: 3
|
|
285
|
+
* MINUTES: 3
|
|
286
|
+
* SECONDS: 3
|
|
287
|
+
* ATTOSECONDS: 1 + 3*6
|
|
288
|
+
* TIMEZONE: 5
|
|
289
|
+
* NULL TERMINATOR: 1
|
|
290
|
+
*/
|
|
291
|
+
#define NPY_DATETIME_MAX_ISO8601_STRLEN (21 + 3*5 + 1 + 3*6 + 6 + 1)
|
|
292
|
+
|
|
293
|
+
/* The FR in the unit names stands for frequency */
|
|
294
|
+
typedef enum {
|
|
295
|
+
/* Force signed enum type, must be -1 for code compatibility */
|
|
296
|
+
NPY_FR_ERROR = -1, /* error or undetermined */
|
|
297
|
+
|
|
298
|
+
/* Start of valid units */
|
|
299
|
+
NPY_FR_Y = 0, /* Years */
|
|
300
|
+
NPY_FR_M = 1, /* Months */
|
|
301
|
+
NPY_FR_W = 2, /* Weeks */
|
|
302
|
+
/* Gap where 1.6 NPY_FR_B (value 3) was */
|
|
303
|
+
NPY_FR_D = 4, /* Days */
|
|
304
|
+
NPY_FR_h = 5, /* hours */
|
|
305
|
+
NPY_FR_m = 6, /* minutes */
|
|
306
|
+
NPY_FR_s = 7, /* seconds */
|
|
307
|
+
NPY_FR_ms = 8, /* milliseconds */
|
|
308
|
+
NPY_FR_us = 9, /* microseconds */
|
|
309
|
+
NPY_FR_ns = 10, /* nanoseconds */
|
|
310
|
+
NPY_FR_ps = 11, /* picoseconds */
|
|
311
|
+
NPY_FR_fs = 12, /* femtoseconds */
|
|
312
|
+
NPY_FR_as = 13, /* attoseconds */
|
|
313
|
+
NPY_FR_GENERIC = 14 /* unbound units, can convert to anything */
|
|
314
|
+
} NPY_DATETIMEUNIT;
|
|
315
|
+
|
|
316
|
+
/*
|
|
317
|
+
* NOTE: With the NPY_FR_B gap for 1.6 ABI compatibility, NPY_DATETIME_NUMUNITS
|
|
318
|
+
* is technically one more than the actual number of units.
|
|
319
|
+
*/
|
|
320
|
+
#define NPY_DATETIME_NUMUNITS (NPY_FR_GENERIC + 1)
|
|
321
|
+
#define NPY_DATETIME_DEFAULTUNIT NPY_FR_GENERIC
|
|
322
|
+
|
|
323
|
+
/*
|
|
324
|
+
* Business day conventions for mapping invalid business
|
|
325
|
+
* days to valid business days.
|
|
326
|
+
*/
|
|
327
|
+
typedef enum {
|
|
328
|
+
/* Go forward in time to the following business day. */
|
|
329
|
+
NPY_BUSDAY_FORWARD,
|
|
330
|
+
NPY_BUSDAY_FOLLOWING = NPY_BUSDAY_FORWARD,
|
|
331
|
+
/* Go backward in time to the preceding business day. */
|
|
332
|
+
NPY_BUSDAY_BACKWARD,
|
|
333
|
+
NPY_BUSDAY_PRECEDING = NPY_BUSDAY_BACKWARD,
|
|
334
|
+
/*
|
|
335
|
+
* Go forward in time to the following business day, unless it
|
|
336
|
+
* crosses a month boundary, in which case go backward
|
|
337
|
+
*/
|
|
338
|
+
NPY_BUSDAY_MODIFIEDFOLLOWING,
|
|
339
|
+
/*
|
|
340
|
+
* Go backward in time to the preceding business day, unless it
|
|
341
|
+
* crosses a month boundary, in which case go forward.
|
|
342
|
+
*/
|
|
343
|
+
NPY_BUSDAY_MODIFIEDPRECEDING,
|
|
344
|
+
/* Produce a NaT for non-business days. */
|
|
345
|
+
NPY_BUSDAY_NAT,
|
|
346
|
+
/* Raise an exception for non-business days. */
|
|
347
|
+
NPY_BUSDAY_RAISE
|
|
348
|
+
} NPY_BUSDAY_ROLL;
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
/************************************************************
|
|
352
|
+
* NumPy Auxiliary Data for inner loops, sort functions, etc.
|
|
353
|
+
************************************************************/
|
|
354
|
+
|
|
355
|
+
/*
|
|
356
|
+
* When creating an auxiliary data struct, this should always appear
|
|
357
|
+
* as the first member, like this:
|
|
358
|
+
*
|
|
359
|
+
* typedef struct {
|
|
360
|
+
* NpyAuxData base;
|
|
361
|
+
* double constant;
|
|
362
|
+
* } constant_multiplier_aux_data;
|
|
363
|
+
*/
|
|
364
|
+
typedef struct NpyAuxData_tag NpyAuxData;
|
|
365
|
+
|
|
366
|
+
/* Function pointers for freeing or cloning auxiliary data */
|
|
367
|
+
typedef void (NpyAuxData_FreeFunc) (NpyAuxData *);
|
|
368
|
+
typedef NpyAuxData *(NpyAuxData_CloneFunc) (NpyAuxData *);
|
|
369
|
+
|
|
370
|
+
struct NpyAuxData_tag {
|
|
371
|
+
NpyAuxData_FreeFunc *free;
|
|
372
|
+
NpyAuxData_CloneFunc *clone;
|
|
373
|
+
/* To allow for a bit of expansion without breaking the ABI */
|
|
374
|
+
void *reserved[2];
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/* Macros to use for freeing and cloning auxiliary data */
|
|
378
|
+
#define NPY_AUXDATA_FREE(auxdata) \
|
|
379
|
+
do { \
|
|
380
|
+
if ((auxdata) != NULL) { \
|
|
381
|
+
(auxdata)->free(auxdata); \
|
|
382
|
+
} \
|
|
383
|
+
} while(0)
|
|
384
|
+
#define NPY_AUXDATA_CLONE(auxdata) \
|
|
385
|
+
((auxdata)->clone(auxdata))
|
|
386
|
+
|
|
387
|
+
#define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr);
|
|
388
|
+
#define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr);
|
|
389
|
+
|
|
390
|
+
/*
|
|
391
|
+
* Macros to define how array, and dimension/strides data is
|
|
392
|
+
* allocated. These should be made private
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
#define NPY_USE_PYMEM 1
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
#if NPY_USE_PYMEM == 1
|
|
399
|
+
/* use the Raw versions which are safe to call with the GIL released */
|
|
400
|
+
#define PyArray_malloc PyMem_RawMalloc
|
|
401
|
+
#define PyArray_free PyMem_RawFree
|
|
402
|
+
#define PyArray_realloc PyMem_RawRealloc
|
|
403
|
+
#else
|
|
404
|
+
#define PyArray_malloc malloc
|
|
405
|
+
#define PyArray_free free
|
|
406
|
+
#define PyArray_realloc realloc
|
|
407
|
+
#endif
|
|
408
|
+
|
|
409
|
+
/* Dimensions and strides */
|
|
410
|
+
#define PyDimMem_NEW(size) \
|
|
411
|
+
((npy_intp *)PyArray_malloc(size*sizeof(npy_intp)))
|
|
412
|
+
|
|
413
|
+
#define PyDimMem_FREE(ptr) PyArray_free(ptr)
|
|
414
|
+
|
|
415
|
+
#define PyDimMem_RENEW(ptr,size) \
|
|
416
|
+
((npy_intp *)PyArray_realloc(ptr,size*sizeof(npy_intp)))
|
|
417
|
+
|
|
418
|
+
/* forward declaration */
|
|
419
|
+
struct _PyArray_Descr;
|
|
420
|
+
|
|
421
|
+
/* These must deal with unaligned and swapped data if necessary */
|
|
422
|
+
typedef PyObject * (PyArray_GetItemFunc) (void *, void *);
|
|
423
|
+
typedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);
|
|
424
|
+
|
|
425
|
+
typedef void (PyArray_CopySwapNFunc)(void *, npy_intp, void *, npy_intp,
|
|
426
|
+
npy_intp, int, void *);
|
|
427
|
+
|
|
428
|
+
typedef void (PyArray_CopySwapFunc)(void *, void *, int, void *);
|
|
429
|
+
typedef npy_bool (PyArray_NonzeroFunc)(void *, void *);
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
/*
|
|
433
|
+
* These assume aligned and notswapped data -- a buffer will be used
|
|
434
|
+
* before or contiguous data will be obtained
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
typedef int (PyArray_CompareFunc)(const void *, const void *, void *);
|
|
438
|
+
typedef int (PyArray_ArgFunc)(void*, npy_intp, npy_intp*, void *);
|
|
439
|
+
|
|
440
|
+
typedef void (PyArray_DotFunc)(void *, npy_intp, void *, npy_intp, void *,
|
|
441
|
+
npy_intp, void *);
|
|
442
|
+
|
|
443
|
+
typedef void (PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *,
|
|
444
|
+
void *);
|
|
445
|
+
|
|
446
|
+
/*
|
|
447
|
+
* XXX the ignore argument should be removed next time the API version
|
|
448
|
+
* is bumped. It used to be the separator.
|
|
449
|
+
*/
|
|
450
|
+
typedef int (PyArray_ScanFunc)(FILE *fp, void *dptr,
|
|
451
|
+
char *ignore, struct _PyArray_Descr *);
|
|
452
|
+
typedef int (PyArray_FromStrFunc)(char *s, void *dptr, char **endptr,
|
|
453
|
+
struct _PyArray_Descr *);
|
|
454
|
+
|
|
455
|
+
typedef int (PyArray_FillFunc)(void *, npy_intp, void *);
|
|
456
|
+
|
|
457
|
+
typedef int (PyArray_SortFunc)(void *, npy_intp, void *);
|
|
458
|
+
typedef int (PyArray_ArgSortFunc)(void *, npy_intp *, npy_intp, void *);
|
|
459
|
+
|
|
460
|
+
typedef int (PyArray_FillWithScalarFunc)(void *, npy_intp, void *, void *);
|
|
461
|
+
|
|
462
|
+
typedef int (PyArray_ScalarKindFunc)(void *);
|
|
463
|
+
|
|
464
|
+
typedef struct {
|
|
465
|
+
npy_intp *ptr;
|
|
466
|
+
int len;
|
|
467
|
+
} PyArray_Dims;
|
|
468
|
+
|
|
469
|
+
typedef struct {
|
|
470
|
+
/*
|
|
471
|
+
* Functions to cast to most other standard types
|
|
472
|
+
* Can have some NULL entries. The types
|
|
473
|
+
* DATETIME, TIMEDELTA, and HALF go into the castdict
|
|
474
|
+
* even though they are built-in.
|
|
475
|
+
*/
|
|
476
|
+
PyArray_VectorUnaryFunc *cast[NPY_NTYPES_ABI_COMPATIBLE];
|
|
477
|
+
|
|
478
|
+
/* The next four functions *cannot* be NULL */
|
|
479
|
+
|
|
480
|
+
/*
|
|
481
|
+
* Functions to get and set items with standard Python types
|
|
482
|
+
* -- not array scalars
|
|
483
|
+
*/
|
|
484
|
+
PyArray_GetItemFunc *getitem;
|
|
485
|
+
PyArray_SetItemFunc *setitem;
|
|
486
|
+
|
|
487
|
+
/*
|
|
488
|
+
* Copy and/or swap data. Memory areas may not overlap
|
|
489
|
+
* Use memmove first if they might
|
|
490
|
+
*/
|
|
491
|
+
PyArray_CopySwapNFunc *copyswapn;
|
|
492
|
+
PyArray_CopySwapFunc *copyswap;
|
|
493
|
+
|
|
494
|
+
/*
|
|
495
|
+
* Function to compare items
|
|
496
|
+
* Can be NULL
|
|
497
|
+
*/
|
|
498
|
+
PyArray_CompareFunc *compare;
|
|
499
|
+
|
|
500
|
+
/*
|
|
501
|
+
* Function to select largest
|
|
502
|
+
* Can be NULL
|
|
503
|
+
*/
|
|
504
|
+
PyArray_ArgFunc *argmax;
|
|
505
|
+
|
|
506
|
+
/*
|
|
507
|
+
* Function to compute dot product
|
|
508
|
+
* Can be NULL
|
|
509
|
+
*/
|
|
510
|
+
PyArray_DotFunc *dotfunc;
|
|
511
|
+
|
|
512
|
+
/*
|
|
513
|
+
* Function to scan an ASCII file and
|
|
514
|
+
* place a single value plus possible separator
|
|
515
|
+
* Can be NULL
|
|
516
|
+
*/
|
|
517
|
+
PyArray_ScanFunc *scanfunc;
|
|
518
|
+
|
|
519
|
+
/*
|
|
520
|
+
* Function to read a single value from a string
|
|
521
|
+
* and adjust the pointer; Can be NULL
|
|
522
|
+
*/
|
|
523
|
+
PyArray_FromStrFunc *fromstr;
|
|
524
|
+
|
|
525
|
+
/*
|
|
526
|
+
* Function to determine if data is zero or not
|
|
527
|
+
* If NULL a default version is
|
|
528
|
+
* used at Registration time.
|
|
529
|
+
*/
|
|
530
|
+
PyArray_NonzeroFunc *nonzero;
|
|
531
|
+
|
|
532
|
+
/*
|
|
533
|
+
* Used for arange. Should return 0 on success
|
|
534
|
+
* and -1 on failure.
|
|
535
|
+
* Can be NULL.
|
|
536
|
+
*/
|
|
537
|
+
PyArray_FillFunc *fill;
|
|
538
|
+
|
|
539
|
+
/*
|
|
540
|
+
* Function to fill arrays with scalar values
|
|
541
|
+
* Can be NULL
|
|
542
|
+
*/
|
|
543
|
+
PyArray_FillWithScalarFunc *fillwithscalar;
|
|
544
|
+
|
|
545
|
+
/*
|
|
546
|
+
* Sorting functions
|
|
547
|
+
* Can be NULL
|
|
548
|
+
*/
|
|
549
|
+
PyArray_SortFunc *sort[NPY_NSORTS];
|
|
550
|
+
PyArray_ArgSortFunc *argsort[NPY_NSORTS];
|
|
551
|
+
|
|
552
|
+
/*
|
|
553
|
+
* Dictionary of additional casting functions
|
|
554
|
+
* PyArray_VectorUnaryFuncs
|
|
555
|
+
* which can be populated to support casting
|
|
556
|
+
* to other registered types. Can be NULL
|
|
557
|
+
*/
|
|
558
|
+
PyObject *castdict;
|
|
559
|
+
|
|
560
|
+
/*
|
|
561
|
+
* Functions useful for generalizing
|
|
562
|
+
* the casting rules.
|
|
563
|
+
* Can be NULL;
|
|
564
|
+
*/
|
|
565
|
+
PyArray_ScalarKindFunc *scalarkind;
|
|
566
|
+
int **cancastscalarkindto;
|
|
567
|
+
int *cancastto;
|
|
568
|
+
|
|
569
|
+
void *_unused1;
|
|
570
|
+
void *_unused2;
|
|
571
|
+
void *_unused3;
|
|
572
|
+
|
|
573
|
+
/*
|
|
574
|
+
* Function to select smallest
|
|
575
|
+
* Can be NULL
|
|
576
|
+
*/
|
|
577
|
+
PyArray_ArgFunc *argmin;
|
|
578
|
+
|
|
579
|
+
} PyArray_ArrFuncs;
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
/* The item must be reference counted when it is inserted or extracted. */
|
|
583
|
+
#define NPY_ITEM_REFCOUNT 0x01
|
|
584
|
+
/* Same as needing REFCOUNT */
|
|
585
|
+
#define NPY_ITEM_HASOBJECT 0x01
|
|
586
|
+
/* Convert to list for pickling */
|
|
587
|
+
#define NPY_LIST_PICKLE 0x02
|
|
588
|
+
/* The item is a POINTER */
|
|
589
|
+
#define NPY_ITEM_IS_POINTER 0x04
|
|
590
|
+
/* memory needs to be initialized for this data-type */
|
|
591
|
+
#define NPY_NEEDS_INIT 0x08
|
|
592
|
+
/* operations need Python C-API so don't give-up thread. */
|
|
593
|
+
#define NPY_NEEDS_PYAPI 0x10
|
|
594
|
+
/* Use f.getitem when extracting elements of this data-type */
|
|
595
|
+
#define NPY_USE_GETITEM 0x20
|
|
596
|
+
/* Use f.setitem when setting creating 0-d array from this data-type.*/
|
|
597
|
+
#define NPY_USE_SETITEM 0x40
|
|
598
|
+
/* A sticky flag specifically for structured arrays */
|
|
599
|
+
#define NPY_ALIGNED_STRUCT 0x80
|
|
600
|
+
|
|
601
|
+
/*
|
|
602
|
+
*These are inherited for global data-type if any data-types in the
|
|
603
|
+
* field have them
|
|
604
|
+
*/
|
|
605
|
+
#define NPY_FROM_FIELDS (NPY_NEEDS_INIT | NPY_LIST_PICKLE | \
|
|
606
|
+
NPY_ITEM_REFCOUNT | NPY_NEEDS_PYAPI)
|
|
607
|
+
|
|
608
|
+
#define NPY_OBJECT_DTYPE_FLAGS (NPY_LIST_PICKLE | NPY_USE_GETITEM | \
|
|
609
|
+
NPY_ITEM_IS_POINTER | NPY_ITEM_REFCOUNT | \
|
|
610
|
+
NPY_NEEDS_INIT | NPY_NEEDS_PYAPI)
|
|
611
|
+
|
|
612
|
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
|
613
|
+
/*
|
|
614
|
+
* Public version of the Descriptor struct as of 2.x
|
|
615
|
+
*/
|
|
616
|
+
typedef struct _PyArray_Descr {
|
|
617
|
+
PyObject_HEAD
|
|
618
|
+
/*
|
|
619
|
+
* the type object representing an
|
|
620
|
+
* instance of this type -- should not
|
|
621
|
+
* be two type_numbers with the same type
|
|
622
|
+
* object.
|
|
623
|
+
*/
|
|
624
|
+
PyTypeObject *typeobj;
|
|
625
|
+
/* kind for this type */
|
|
626
|
+
char kind;
|
|
627
|
+
/* unique-character representing this type */
|
|
628
|
+
char type;
|
|
629
|
+
/*
|
|
630
|
+
* '>' (big), '<' (little), '|'
|
|
631
|
+
* (not-applicable), or '=' (native).
|
|
632
|
+
*/
|
|
633
|
+
char byteorder;
|
|
634
|
+
/* Former flags flags space (unused) to ensure type_num is stable. */
|
|
635
|
+
char _former_flags;
|
|
636
|
+
/* number representing this type */
|
|
637
|
+
int type_num;
|
|
638
|
+
/* Space for dtype instance specific flags. */
|
|
639
|
+
npy_uint64 flags;
|
|
640
|
+
/* element size (itemsize) for this type */
|
|
641
|
+
npy_intp elsize;
|
|
642
|
+
/* alignment needed for this type */
|
|
643
|
+
npy_intp alignment;
|
|
644
|
+
/* metadata dict or NULL */
|
|
645
|
+
PyObject *metadata;
|
|
646
|
+
/* Cached hash value (-1 if not yet computed). */
|
|
647
|
+
npy_hash_t hash;
|
|
648
|
+
/* Unused slot (must be initialized to NULL) for future use */
|
|
649
|
+
void *reserved_null[2];
|
|
650
|
+
} PyArray_Descr;
|
|
651
|
+
|
|
652
|
+
#else /* 1.x and 2.x compatible version (only shared fields): */
|
|
653
|
+
|
|
654
|
+
typedef struct _PyArray_Descr {
|
|
655
|
+
PyObject_HEAD
|
|
656
|
+
PyTypeObject *typeobj;
|
|
657
|
+
char kind;
|
|
658
|
+
char type;
|
|
659
|
+
char byteorder;
|
|
660
|
+
char _former_flags;
|
|
661
|
+
int type_num;
|
|
662
|
+
} PyArray_Descr;
|
|
663
|
+
|
|
664
|
+
/* To access modified fields, define the full 2.0 struct: */
|
|
665
|
+
typedef struct {
|
|
666
|
+
PyObject_HEAD
|
|
667
|
+
PyTypeObject *typeobj;
|
|
668
|
+
char kind;
|
|
669
|
+
char type;
|
|
670
|
+
char byteorder;
|
|
671
|
+
char _former_flags;
|
|
672
|
+
int type_num;
|
|
673
|
+
npy_uint64 flags;
|
|
674
|
+
npy_intp elsize;
|
|
675
|
+
npy_intp alignment;
|
|
676
|
+
PyObject *metadata;
|
|
677
|
+
npy_hash_t hash;
|
|
678
|
+
void *reserved_null[2];
|
|
679
|
+
} _PyArray_DescrNumPy2;
|
|
680
|
+
|
|
681
|
+
#endif /* 1.x and 2.x compatible version */
|
|
682
|
+
|
|
683
|
+
/*
|
|
684
|
+
* Semi-private struct with additional field of legacy descriptors (must
|
|
685
|
+
* check NPY_DT_is_legacy before casting/accessing). The struct is also not
|
|
686
|
+
* valid when running on 1.x (i.e. in public API use).
|
|
687
|
+
*/
|
|
688
|
+
typedef struct {
|
|
689
|
+
PyObject_HEAD
|
|
690
|
+
PyTypeObject *typeobj;
|
|
691
|
+
char kind;
|
|
692
|
+
char type;
|
|
693
|
+
char byteorder;
|
|
694
|
+
char _former_flags;
|
|
695
|
+
int type_num;
|
|
696
|
+
npy_uint64 flags;
|
|
697
|
+
npy_intp elsize;
|
|
698
|
+
npy_intp alignment;
|
|
699
|
+
PyObject *metadata;
|
|
700
|
+
npy_hash_t hash;
|
|
701
|
+
void *reserved_null[2];
|
|
702
|
+
struct _arr_descr *subarray;
|
|
703
|
+
PyObject *fields;
|
|
704
|
+
PyObject *names;
|
|
705
|
+
NpyAuxData *c_metadata;
|
|
706
|
+
} _PyArray_LegacyDescr;
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
/*
|
|
710
|
+
* Umodified PyArray_Descr struct identical to NumPy 1.x. This struct is
|
|
711
|
+
* used as a prototype for registering a new legacy DType.
|
|
712
|
+
* It is also used to access the fields in user code running on 1.x.
|
|
713
|
+
*/
|
|
714
|
+
typedef struct {
|
|
715
|
+
PyObject_HEAD
|
|
716
|
+
PyTypeObject *typeobj;
|
|
717
|
+
char kind;
|
|
718
|
+
char type;
|
|
719
|
+
char byteorder;
|
|
720
|
+
char flags;
|
|
721
|
+
int type_num;
|
|
722
|
+
int elsize;
|
|
723
|
+
int alignment;
|
|
724
|
+
struct _arr_descr *subarray;
|
|
725
|
+
PyObject *fields;
|
|
726
|
+
PyObject *names;
|
|
727
|
+
PyArray_ArrFuncs *f;
|
|
728
|
+
PyObject *metadata;
|
|
729
|
+
NpyAuxData *c_metadata;
|
|
730
|
+
npy_hash_t hash;
|
|
731
|
+
} PyArray_DescrProto;
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
typedef struct _arr_descr {
|
|
735
|
+
PyArray_Descr *base;
|
|
736
|
+
PyObject *shape; /* a tuple */
|
|
737
|
+
} PyArray_ArrayDescr;
|
|
738
|
+
|
|
739
|
+
/*
|
|
740
|
+
* Memory handler structure for array data.
|
|
741
|
+
*/
|
|
742
|
+
/* The declaration of free differs from PyMemAllocatorEx */
|
|
743
|
+
typedef struct {
|
|
744
|
+
void *ctx;
|
|
745
|
+
void* (*malloc) (void *ctx, size_t size);
|
|
746
|
+
void* (*calloc) (void *ctx, size_t nelem, size_t elsize);
|
|
747
|
+
void* (*realloc) (void *ctx, void *ptr, size_t new_size);
|
|
748
|
+
void (*free) (void *ctx, void *ptr, size_t size);
|
|
749
|
+
/*
|
|
750
|
+
* This is the end of the version=1 struct. Only add new fields after
|
|
751
|
+
* this line
|
|
752
|
+
*/
|
|
753
|
+
} PyDataMemAllocator;
|
|
754
|
+
|
|
755
|
+
typedef struct {
|
|
756
|
+
char name[127]; /* multiple of 64 to keep the struct aligned */
|
|
757
|
+
uint8_t version; /* currently 1 */
|
|
758
|
+
PyDataMemAllocator allocator;
|
|
759
|
+
} PyDataMem_Handler;
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
/*
|
|
763
|
+
* The main array object structure.
|
|
764
|
+
*
|
|
765
|
+
* It has been recommended to use the inline functions defined below
|
|
766
|
+
* (PyArray_DATA and friends) to access fields here for a number of
|
|
767
|
+
* releases. Direct access to the members themselves is deprecated.
|
|
768
|
+
* To ensure that your code does not use deprecated access,
|
|
769
|
+
* #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
|
770
|
+
* (or NPY_1_8_API_VERSION or higher as required).
|
|
771
|
+
*/
|
|
772
|
+
/* This struct will be moved to a private header in a future release */
|
|
773
|
+
typedef struct tagPyArrayObject_fields {
|
|
774
|
+
PyObject_HEAD
|
|
775
|
+
/* Pointer to the raw data buffer */
|
|
776
|
+
char *data;
|
|
777
|
+
/* The number of dimensions, also called 'ndim' */
|
|
778
|
+
int nd;
|
|
779
|
+
/* The size in each dimension, also called 'shape' */
|
|
780
|
+
npy_intp *dimensions;
|
|
781
|
+
/*
|
|
782
|
+
* Number of bytes to jump to get to the
|
|
783
|
+
* next element in each dimension
|
|
784
|
+
*/
|
|
785
|
+
npy_intp *strides;
|
|
786
|
+
/*
|
|
787
|
+
* This object is decref'd upon
|
|
788
|
+
* deletion of array. Except in the
|
|
789
|
+
* case of WRITEBACKIFCOPY which has
|
|
790
|
+
* special handling.
|
|
791
|
+
*
|
|
792
|
+
* For views it points to the original
|
|
793
|
+
* array, collapsed so no chains of
|
|
794
|
+
* views occur.
|
|
795
|
+
*
|
|
796
|
+
* For creation from buffer object it
|
|
797
|
+
* points to an object that should be
|
|
798
|
+
* decref'd on deletion
|
|
799
|
+
*
|
|
800
|
+
* For WRITEBACKIFCOPY flag this is an
|
|
801
|
+
* array to-be-updated upon calling
|
|
802
|
+
* PyArray_ResolveWritebackIfCopy
|
|
803
|
+
*/
|
|
804
|
+
PyObject *base;
|
|
805
|
+
/* Pointer to type structure */
|
|
806
|
+
PyArray_Descr *descr;
|
|
807
|
+
/* Flags describing array -- see below */
|
|
808
|
+
int flags;
|
|
809
|
+
/* For weak references */
|
|
810
|
+
PyObject *weakreflist;
|
|
811
|
+
#if NPY_FEATURE_VERSION >= NPY_1_20_API_VERSION
|
|
812
|
+
void *_buffer_info; /* private buffer info, tagged to allow warning */
|
|
813
|
+
#endif
|
|
814
|
+
/*
|
|
815
|
+
* For malloc/calloc/realloc/free per object
|
|
816
|
+
*/
|
|
817
|
+
#if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
|
|
818
|
+
PyObject *mem_handler;
|
|
819
|
+
#endif
|
|
820
|
+
} PyArrayObject_fields;
|
|
821
|
+
|
|
822
|
+
/*
|
|
823
|
+
* To hide the implementation details, we only expose
|
|
824
|
+
* the Python struct HEAD.
|
|
825
|
+
*/
|
|
826
|
+
#if !defined(NPY_NO_DEPRECATED_API) || \
|
|
827
|
+
(NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION)
|
|
828
|
+
/*
|
|
829
|
+
* Can't put this in npy_deprecated_api.h like the others.
|
|
830
|
+
* PyArrayObject field access is deprecated as of NumPy 1.7.
|
|
831
|
+
*/
|
|
832
|
+
typedef PyArrayObject_fields PyArrayObject;
|
|
833
|
+
#else
|
|
834
|
+
typedef struct tagPyArrayObject {
|
|
835
|
+
PyObject_HEAD
|
|
836
|
+
} PyArrayObject;
|
|
837
|
+
#endif
|
|
838
|
+
|
|
839
|
+
/*
|
|
840
|
+
* Removed 2020-Nov-25, NumPy 1.20
|
|
841
|
+
* #define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields))
|
|
842
|
+
*
|
|
843
|
+
* The above macro was removed as it gave a false sense of a stable ABI
|
|
844
|
+
* with respect to the structures size. If you require a runtime constant,
|
|
845
|
+
* you can use `PyArray_Type.tp_basicsize` instead. Otherwise, please
|
|
846
|
+
* see the PyArrayObject documentation or ask the NumPy developers for
|
|
847
|
+
* information on how to correctly replace the macro in a way that is
|
|
848
|
+
* compatible with multiple NumPy versions.
|
|
849
|
+
*/
|
|
850
|
+
|
|
851
|
+
/* Mirrors buffer object to ptr */
|
|
852
|
+
|
|
853
|
+
typedef struct {
|
|
854
|
+
PyObject_HEAD
|
|
855
|
+
PyObject *base;
|
|
856
|
+
void *ptr;
|
|
857
|
+
npy_intp len;
|
|
858
|
+
int flags;
|
|
859
|
+
} PyArray_Chunk;
|
|
860
|
+
|
|
861
|
+
typedef struct {
|
|
862
|
+
NPY_DATETIMEUNIT base;
|
|
863
|
+
int num;
|
|
864
|
+
} PyArray_DatetimeMetaData;
|
|
865
|
+
|
|
866
|
+
typedef struct {
|
|
867
|
+
NpyAuxData base;
|
|
868
|
+
PyArray_DatetimeMetaData meta;
|
|
869
|
+
} PyArray_DatetimeDTypeMetaData;
|
|
870
|
+
|
|
871
|
+
/*
|
|
872
|
+
* This structure contains an exploded view of a date-time value.
|
|
873
|
+
* NaT is represented by year == NPY_DATETIME_NAT.
|
|
874
|
+
*/
|
|
875
|
+
typedef struct {
|
|
876
|
+
npy_int64 year;
|
|
877
|
+
npy_int32 month, day, hour, min, sec, us, ps, as;
|
|
878
|
+
} npy_datetimestruct;
|
|
879
|
+
|
|
880
|
+
/* This structure contains an exploded view of a timedelta value */
|
|
881
|
+
typedef struct {
|
|
882
|
+
npy_int64 day;
|
|
883
|
+
npy_int32 sec, us, ps, as;
|
|
884
|
+
} npy_timedeltastruct;
|
|
885
|
+
|
|
886
|
+
typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
|
|
887
|
+
|
|
888
|
+
/*
|
|
889
|
+
* Means c-style contiguous (last index varies the fastest). The data
|
|
890
|
+
* elements right after each other.
|
|
891
|
+
*
|
|
892
|
+
* This flag may be requested in constructor functions.
|
|
893
|
+
* This flag may be tested for in PyArray_FLAGS(arr).
|
|
894
|
+
*/
|
|
895
|
+
#define NPY_ARRAY_C_CONTIGUOUS 0x0001
|
|
896
|
+
|
|
897
|
+
/*
|
|
898
|
+
* Set if array is a contiguous Fortran array: the first index varies
|
|
899
|
+
* the fastest in memory (strides array is reverse of C-contiguous
|
|
900
|
+
* array)
|
|
901
|
+
*
|
|
902
|
+
* This flag may be requested in constructor functions.
|
|
903
|
+
* This flag may be tested for in PyArray_FLAGS(arr).
|
|
904
|
+
*/
|
|
905
|
+
#define NPY_ARRAY_F_CONTIGUOUS 0x0002
|
|
906
|
+
|
|
907
|
+
/*
|
|
908
|
+
* Note: all 0-d arrays are C_CONTIGUOUS and F_CONTIGUOUS. If a
|
|
909
|
+
* 1-d array is C_CONTIGUOUS it is also F_CONTIGUOUS. Arrays with
|
|
910
|
+
* more then one dimension can be C_CONTIGUOUS and F_CONTIGUOUS
|
|
911
|
+
* at the same time if they have either zero or one element.
|
|
912
|
+
* A higher dimensional array always has the same contiguity flags as
|
|
913
|
+
* `array.squeeze()`; dimensions with `array.shape[dimension] == 1` are
|
|
914
|
+
* effectively ignored when checking for contiguity.
|
|
915
|
+
*/
|
|
916
|
+
|
|
917
|
+
/*
|
|
918
|
+
* If set, the array owns the data: it will be free'd when the array
|
|
919
|
+
* is deleted.
|
|
920
|
+
*
|
|
921
|
+
* This flag may be tested for in PyArray_FLAGS(arr).
|
|
922
|
+
*/
|
|
923
|
+
#define NPY_ARRAY_OWNDATA 0x0004
|
|
924
|
+
|
|
925
|
+
/*
|
|
926
|
+
* An array never has the next four set; they're only used as parameter
|
|
927
|
+
* flags to the various FromAny functions
|
|
928
|
+
*
|
|
929
|
+
* This flag may be requested in constructor functions.
|
|
930
|
+
*/
|
|
931
|
+
|
|
932
|
+
/* Cause a cast to occur regardless of whether or not it is safe. */
|
|
933
|
+
#define NPY_ARRAY_FORCECAST 0x0010
|
|
934
|
+
|
|
935
|
+
/*
|
|
936
|
+
* Always copy the array. Returned arrays are always CONTIGUOUS,
|
|
937
|
+
* ALIGNED, and WRITEABLE. See also: NPY_ARRAY_ENSURENOCOPY = 0x4000.
|
|
938
|
+
*
|
|
939
|
+
* This flag may be requested in constructor functions.
|
|
940
|
+
*/
|
|
941
|
+
#define NPY_ARRAY_ENSURECOPY 0x0020
|
|
942
|
+
|
|
943
|
+
/*
|
|
944
|
+
* Make sure the returned array is a base-class ndarray
|
|
945
|
+
*
|
|
946
|
+
* This flag may be requested in constructor functions.
|
|
947
|
+
*/
|
|
948
|
+
#define NPY_ARRAY_ENSUREARRAY 0x0040
|
|
949
|
+
|
|
950
|
+
/*
|
|
951
|
+
* Make sure that the strides are in units of the element size Needed
|
|
952
|
+
* for some operations with record-arrays.
|
|
953
|
+
*
|
|
954
|
+
* This flag may be requested in constructor functions.
|
|
955
|
+
*/
|
|
956
|
+
#define NPY_ARRAY_ELEMENTSTRIDES 0x0080
|
|
957
|
+
|
|
958
|
+
/*
|
|
959
|
+
* Array data is aligned on the appropriate memory address for the type
|
|
960
|
+
* stored according to how the compiler would align things (e.g., an
|
|
961
|
+
* array of integers (4 bytes each) starts on a memory address that's
|
|
962
|
+
* a multiple of 4)
|
|
963
|
+
*
|
|
964
|
+
* This flag may be requested in constructor functions.
|
|
965
|
+
* This flag may be tested for in PyArray_FLAGS(arr).
|
|
966
|
+
*/
|
|
967
|
+
#define NPY_ARRAY_ALIGNED 0x0100
|
|
968
|
+
|
|
969
|
+
/*
|
|
970
|
+
* Array data has the native endianness
|
|
971
|
+
*
|
|
972
|
+
* This flag may be requested in constructor functions.
|
|
973
|
+
*/
|
|
974
|
+
#define NPY_ARRAY_NOTSWAPPED 0x0200
|
|
975
|
+
|
|
976
|
+
/*
|
|
977
|
+
* Array data is writeable
|
|
978
|
+
*
|
|
979
|
+
* This flag may be requested in constructor functions.
|
|
980
|
+
* This flag may be tested for in PyArray_FLAGS(arr).
|
|
981
|
+
*/
|
|
982
|
+
#define NPY_ARRAY_WRITEABLE 0x0400
|
|
983
|
+
|
|
984
|
+
/*
|
|
985
|
+
* If this flag is set, then base contains a pointer to an array of
|
|
986
|
+
* the same size that should be updated with the current contents of
|
|
987
|
+
* this array when PyArray_ResolveWritebackIfCopy is called.
|
|
988
|
+
*
|
|
989
|
+
* This flag may be requested in constructor functions.
|
|
990
|
+
* This flag may be tested for in PyArray_FLAGS(arr).
|
|
991
|
+
*/
|
|
992
|
+
#define NPY_ARRAY_WRITEBACKIFCOPY 0x2000
|
|
993
|
+
|
|
994
|
+
/*
|
|
995
|
+
* No copy may be made while converting from an object/array (result is a view)
|
|
996
|
+
*
|
|
997
|
+
* This flag may be requested in constructor functions.
|
|
998
|
+
*/
|
|
999
|
+
#define NPY_ARRAY_ENSURENOCOPY 0x4000
|
|
1000
|
+
|
|
1001
|
+
/*
|
|
1002
|
+
* NOTE: there are also internal flags defined in multiarray/arrayobject.h,
|
|
1003
|
+
* which start at bit 31 and work down.
|
|
1004
|
+
*/
|
|
1005
|
+
|
|
1006
|
+
#define NPY_ARRAY_BEHAVED (NPY_ARRAY_ALIGNED | \
|
|
1007
|
+
NPY_ARRAY_WRITEABLE)
|
|
1008
|
+
#define NPY_ARRAY_BEHAVED_NS (NPY_ARRAY_ALIGNED | \
|
|
1009
|
+
NPY_ARRAY_WRITEABLE | \
|
|
1010
|
+
NPY_ARRAY_NOTSWAPPED)
|
|
1011
|
+
#define NPY_ARRAY_CARRAY (NPY_ARRAY_C_CONTIGUOUS | \
|
|
1012
|
+
NPY_ARRAY_BEHAVED)
|
|
1013
|
+
#define NPY_ARRAY_CARRAY_RO (NPY_ARRAY_C_CONTIGUOUS | \
|
|
1014
|
+
NPY_ARRAY_ALIGNED)
|
|
1015
|
+
#define NPY_ARRAY_FARRAY (NPY_ARRAY_F_CONTIGUOUS | \
|
|
1016
|
+
NPY_ARRAY_BEHAVED)
|
|
1017
|
+
#define NPY_ARRAY_FARRAY_RO (NPY_ARRAY_F_CONTIGUOUS | \
|
|
1018
|
+
NPY_ARRAY_ALIGNED)
|
|
1019
|
+
#define NPY_ARRAY_DEFAULT (NPY_ARRAY_CARRAY)
|
|
1020
|
+
#define NPY_ARRAY_IN_ARRAY (NPY_ARRAY_CARRAY_RO)
|
|
1021
|
+
#define NPY_ARRAY_OUT_ARRAY (NPY_ARRAY_CARRAY)
|
|
1022
|
+
#define NPY_ARRAY_INOUT_ARRAY (NPY_ARRAY_CARRAY)
|
|
1023
|
+
#define NPY_ARRAY_INOUT_ARRAY2 (NPY_ARRAY_CARRAY | \
|
|
1024
|
+
NPY_ARRAY_WRITEBACKIFCOPY)
|
|
1025
|
+
#define NPY_ARRAY_IN_FARRAY (NPY_ARRAY_FARRAY_RO)
|
|
1026
|
+
#define NPY_ARRAY_OUT_FARRAY (NPY_ARRAY_FARRAY)
|
|
1027
|
+
#define NPY_ARRAY_INOUT_FARRAY (NPY_ARRAY_FARRAY)
|
|
1028
|
+
#define NPY_ARRAY_INOUT_FARRAY2 (NPY_ARRAY_FARRAY | \
|
|
1029
|
+
NPY_ARRAY_WRITEBACKIFCOPY)
|
|
1030
|
+
|
|
1031
|
+
#define NPY_ARRAY_UPDATE_ALL (NPY_ARRAY_C_CONTIGUOUS | \
|
|
1032
|
+
NPY_ARRAY_F_CONTIGUOUS | \
|
|
1033
|
+
NPY_ARRAY_ALIGNED)
|
|
1034
|
+
|
|
1035
|
+
/* This flag is for the array interface, not PyArrayObject */
|
|
1036
|
+
#define NPY_ARR_HAS_DESCR 0x0800
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
/*
|
|
1042
|
+
* Size of internal buffers used for alignment Make BUFSIZE a multiple
|
|
1043
|
+
* of sizeof(npy_cdouble) -- usually 16 so that ufunc buffers are aligned
|
|
1044
|
+
*/
|
|
1045
|
+
#define NPY_MIN_BUFSIZE ((int)sizeof(npy_cdouble))
|
|
1046
|
+
#define NPY_MAX_BUFSIZE (((int)sizeof(npy_cdouble))*1000000)
|
|
1047
|
+
#define NPY_BUFSIZE 8192
|
|
1048
|
+
/* buffer stress test size: */
|
|
1049
|
+
/*#define NPY_BUFSIZE 17*/
|
|
1050
|
+
|
|
1051
|
+
/*
|
|
1052
|
+
* C API: consists of Macros and functions. The MACROS are defined
|
|
1053
|
+
* here.
|
|
1054
|
+
*/
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_C_CONTIGUOUS)
|
|
1058
|
+
#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS((m), NPY_ARRAY_WRITEABLE)
|
|
1059
|
+
#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS((m), NPY_ARRAY_ALIGNED)
|
|
1060
|
+
|
|
1061
|
+
#define PyArray_IS_C_CONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_C_CONTIGUOUS)
|
|
1062
|
+
#define PyArray_IS_F_CONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_F_CONTIGUOUS)
|
|
1063
|
+
|
|
1064
|
+
/* the variable is used in some places, so always define it */
|
|
1065
|
+
#define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL;
|
|
1066
|
+
#if NPY_ALLOW_THREADS
|
|
1067
|
+
#define NPY_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
|
|
1068
|
+
#define NPY_END_ALLOW_THREADS Py_END_ALLOW_THREADS
|
|
1069
|
+
#define NPY_BEGIN_THREADS do {_save = PyEval_SaveThread();} while (0);
|
|
1070
|
+
#define NPY_END_THREADS do { if (_save) \
|
|
1071
|
+
{ PyEval_RestoreThread(_save); _save = NULL;} } while (0);
|
|
1072
|
+
#define NPY_BEGIN_THREADS_THRESHOLDED(loop_size) do { if ((loop_size) > 500) \
|
|
1073
|
+
{ _save = PyEval_SaveThread();} } while (0);
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
#define NPY_ALLOW_C_API_DEF PyGILState_STATE __save__;
|
|
1077
|
+
#define NPY_ALLOW_C_API do {__save__ = PyGILState_Ensure();} while (0);
|
|
1078
|
+
#define NPY_DISABLE_C_API do {PyGILState_Release(__save__);} while (0);
|
|
1079
|
+
#else
|
|
1080
|
+
#define NPY_BEGIN_ALLOW_THREADS
|
|
1081
|
+
#define NPY_END_ALLOW_THREADS
|
|
1082
|
+
#define NPY_BEGIN_THREADS
|
|
1083
|
+
#define NPY_END_THREADS
|
|
1084
|
+
#define NPY_BEGIN_THREADS_THRESHOLDED(loop_size)
|
|
1085
|
+
#define NPY_BEGIN_THREADS_DESCR(dtype)
|
|
1086
|
+
#define NPY_END_THREADS_DESCR(dtype)
|
|
1087
|
+
#define NPY_ALLOW_C_API_DEF
|
|
1088
|
+
#define NPY_ALLOW_C_API
|
|
1089
|
+
#define NPY_DISABLE_C_API
|
|
1090
|
+
#endif
|
|
1091
|
+
|
|
1092
|
+
/**********************************
|
|
1093
|
+
* The nditer object, added in 1.6
|
|
1094
|
+
**********************************/
|
|
1095
|
+
|
|
1096
|
+
/* The actual structure of the iterator is an internal detail */
|
|
1097
|
+
typedef struct NpyIter_InternalOnly NpyIter;
|
|
1098
|
+
|
|
1099
|
+
/* Iterator function pointers that may be specialized */
|
|
1100
|
+
typedef int (NpyIter_IterNextFunc)(NpyIter *iter);
|
|
1101
|
+
typedef void (NpyIter_GetMultiIndexFunc)(NpyIter *iter,
|
|
1102
|
+
npy_intp *outcoords);
|
|
1103
|
+
|
|
1104
|
+
/*** Global flags that may be passed to the iterator constructors ***/
|
|
1105
|
+
|
|
1106
|
+
/* Track an index representing C order */
|
|
1107
|
+
#define NPY_ITER_C_INDEX 0x00000001
|
|
1108
|
+
/* Track an index representing Fortran order */
|
|
1109
|
+
#define NPY_ITER_F_INDEX 0x00000002
|
|
1110
|
+
/* Track a multi-index */
|
|
1111
|
+
#define NPY_ITER_MULTI_INDEX 0x00000004
|
|
1112
|
+
/* User code external to the iterator does the 1-dimensional innermost loop */
|
|
1113
|
+
#define NPY_ITER_EXTERNAL_LOOP 0x00000008
|
|
1114
|
+
/* Convert all the operands to a common data type */
|
|
1115
|
+
#define NPY_ITER_COMMON_DTYPE 0x00000010
|
|
1116
|
+
/* Operands may hold references, requiring API access during iteration */
|
|
1117
|
+
#define NPY_ITER_REFS_OK 0x00000020
|
|
1118
|
+
/* Zero-sized operands should be permitted, iteration checks IterSize for 0 */
|
|
1119
|
+
#define NPY_ITER_ZEROSIZE_OK 0x00000040
|
|
1120
|
+
/* Permits reductions (size-0 stride with dimension size > 1) */
|
|
1121
|
+
#define NPY_ITER_REDUCE_OK 0x00000080
|
|
1122
|
+
/* Enables sub-range iteration */
|
|
1123
|
+
#define NPY_ITER_RANGED 0x00000100
|
|
1124
|
+
/* Enables buffering */
|
|
1125
|
+
#define NPY_ITER_BUFFERED 0x00000200
|
|
1126
|
+
/* When buffering is enabled, grows the inner loop if possible */
|
|
1127
|
+
#define NPY_ITER_GROWINNER 0x00000400
|
|
1128
|
+
/* Delay allocation of buffers until first Reset* call */
|
|
1129
|
+
#define NPY_ITER_DELAY_BUFALLOC 0x00000800
|
|
1130
|
+
/* When NPY_KEEPORDER is specified, disable reversing negative-stride axes */
|
|
1131
|
+
#define NPY_ITER_DONT_NEGATE_STRIDES 0x00001000
|
|
1132
|
+
/*
|
|
1133
|
+
* If output operands overlap with other operands (based on heuristics that
|
|
1134
|
+
* has false positives but no false negatives), make temporary copies to
|
|
1135
|
+
* eliminate overlap.
|
|
1136
|
+
*/
|
|
1137
|
+
#define NPY_ITER_COPY_IF_OVERLAP 0x00002000
|
|
1138
|
+
|
|
1139
|
+
/*** Per-operand flags that may be passed to the iterator constructors ***/
|
|
1140
|
+
|
|
1141
|
+
/* The operand will be read from and written to */
|
|
1142
|
+
#define NPY_ITER_READWRITE 0x00010000
|
|
1143
|
+
/* The operand will only be read from */
|
|
1144
|
+
#define NPY_ITER_READONLY 0x00020000
|
|
1145
|
+
/* The operand will only be written to */
|
|
1146
|
+
#define NPY_ITER_WRITEONLY 0x00040000
|
|
1147
|
+
/* The operand's data must be in native byte order */
|
|
1148
|
+
#define NPY_ITER_NBO 0x00080000
|
|
1149
|
+
/* The operand's data must be aligned */
|
|
1150
|
+
#define NPY_ITER_ALIGNED 0x00100000
|
|
1151
|
+
/* The operand's data must be contiguous (within the inner loop) */
|
|
1152
|
+
#define NPY_ITER_CONTIG 0x00200000
|
|
1153
|
+
/* The operand may be copied to satisfy requirements */
|
|
1154
|
+
#define NPY_ITER_COPY 0x00400000
|
|
1155
|
+
/* The operand may be copied with WRITEBACKIFCOPY to satisfy requirements */
|
|
1156
|
+
#define NPY_ITER_UPDATEIFCOPY 0x00800000
|
|
1157
|
+
/* Allocate the operand if it is NULL */
|
|
1158
|
+
#define NPY_ITER_ALLOCATE 0x01000000
|
|
1159
|
+
/* If an operand is allocated, don't use any subtype */
|
|
1160
|
+
#define NPY_ITER_NO_SUBTYPE 0x02000000
|
|
1161
|
+
/* This is a virtual array slot, operand is NULL but temporary data is there */
|
|
1162
|
+
#define NPY_ITER_VIRTUAL 0x04000000
|
|
1163
|
+
/* Require that the dimension match the iterator dimensions exactly */
|
|
1164
|
+
#define NPY_ITER_NO_BROADCAST 0x08000000
|
|
1165
|
+
/* A mask is being used on this array, affects buffer -> array copy */
|
|
1166
|
+
#define NPY_ITER_WRITEMASKED 0x10000000
|
|
1167
|
+
/* This array is the mask for all WRITEMASKED operands */
|
|
1168
|
+
#define NPY_ITER_ARRAYMASK 0x20000000
|
|
1169
|
+
/* Assume iterator order data access for COPY_IF_OVERLAP */
|
|
1170
|
+
#define NPY_ITER_OVERLAP_ASSUME_ELEMENTWISE 0x40000000
|
|
1171
|
+
|
|
1172
|
+
#define NPY_ITER_GLOBAL_FLAGS 0x0000ffff
|
|
1173
|
+
#define NPY_ITER_PER_OP_FLAGS 0xffff0000
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
/*****************************
|
|
1177
|
+
* Basic iterator object
|
|
1178
|
+
*****************************/
|
|
1179
|
+
|
|
1180
|
+
/* FWD declaration */
|
|
1181
|
+
typedef struct PyArrayIterObject_tag PyArrayIterObject;
|
|
1182
|
+
|
|
1183
|
+
/*
|
|
1184
|
+
* type of the function which translates a set of coordinates to a
|
|
1185
|
+
* pointer to the data
|
|
1186
|
+
*/
|
|
1187
|
+
typedef char* (*npy_iter_get_dataptr_t)(
|
|
1188
|
+
PyArrayIterObject* iter, const npy_intp*);
|
|
1189
|
+
|
|
1190
|
+
struct PyArrayIterObject_tag {
|
|
1191
|
+
PyObject_HEAD
|
|
1192
|
+
int nd_m1; /* number of dimensions - 1 */
|
|
1193
|
+
npy_intp index, size;
|
|
1194
|
+
npy_intp coordinates[NPY_MAXDIMS_LEGACY_ITERS];/* N-dimensional loop */
|
|
1195
|
+
npy_intp dims_m1[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->dimensions - 1 */
|
|
1196
|
+
npy_intp strides[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->strides or fake */
|
|
1197
|
+
npy_intp backstrides[NPY_MAXDIMS_LEGACY_ITERS];/* how far to jump back */
|
|
1198
|
+
npy_intp factors[NPY_MAXDIMS_LEGACY_ITERS]; /* shape factors */
|
|
1199
|
+
PyArrayObject *ao;
|
|
1200
|
+
char *dataptr; /* pointer to current item*/
|
|
1201
|
+
npy_bool contiguous;
|
|
1202
|
+
|
|
1203
|
+
npy_intp bounds[NPY_MAXDIMS_LEGACY_ITERS][2];
|
|
1204
|
+
npy_intp limits[NPY_MAXDIMS_LEGACY_ITERS][2];
|
|
1205
|
+
npy_intp limits_sizes[NPY_MAXDIMS_LEGACY_ITERS];
|
|
1206
|
+
npy_iter_get_dataptr_t translate;
|
|
1207
|
+
} ;
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
/* Iterator API */
|
|
1211
|
+
#define PyArrayIter_Check(op) PyObject_TypeCheck((op), &PyArrayIter_Type)
|
|
1212
|
+
|
|
1213
|
+
#define _PyAIT(it) ((PyArrayIterObject *)(it))
|
|
1214
|
+
#define PyArray_ITER_RESET(it) do { \
|
|
1215
|
+
_PyAIT(it)->index = 0; \
|
|
1216
|
+
_PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao); \
|
|
1217
|
+
memset(_PyAIT(it)->coordinates, 0, \
|
|
1218
|
+
(_PyAIT(it)->nd_m1+1)*sizeof(npy_intp)); \
|
|
1219
|
+
} while (0)
|
|
1220
|
+
|
|
1221
|
+
#define _PyArray_ITER_NEXT1(it) do { \
|
|
1222
|
+
(it)->dataptr += _PyAIT(it)->strides[0]; \
|
|
1223
|
+
(it)->coordinates[0]++; \
|
|
1224
|
+
} while (0)
|
|
1225
|
+
|
|
1226
|
+
#define _PyArray_ITER_NEXT2(it) do { \
|
|
1227
|
+
if ((it)->coordinates[1] < (it)->dims_m1[1]) { \
|
|
1228
|
+
(it)->coordinates[1]++; \
|
|
1229
|
+
(it)->dataptr += (it)->strides[1]; \
|
|
1230
|
+
} \
|
|
1231
|
+
else { \
|
|
1232
|
+
(it)->coordinates[1] = 0; \
|
|
1233
|
+
(it)->coordinates[0]++; \
|
|
1234
|
+
(it)->dataptr += (it)->strides[0] - \
|
|
1235
|
+
(it)->backstrides[1]; \
|
|
1236
|
+
} \
|
|
1237
|
+
} while (0)
|
|
1238
|
+
|
|
1239
|
+
#define PyArray_ITER_NEXT(it) do { \
|
|
1240
|
+
_PyAIT(it)->index++; \
|
|
1241
|
+
if (_PyAIT(it)->nd_m1 == 0) { \
|
|
1242
|
+
_PyArray_ITER_NEXT1(_PyAIT(it)); \
|
|
1243
|
+
} \
|
|
1244
|
+
else if (_PyAIT(it)->contiguous) \
|
|
1245
|
+
_PyAIT(it)->dataptr += PyArray_ITEMSIZE(_PyAIT(it)->ao); \
|
|
1246
|
+
else if (_PyAIT(it)->nd_m1 == 1) { \
|
|
1247
|
+
_PyArray_ITER_NEXT2(_PyAIT(it)); \
|
|
1248
|
+
} \
|
|
1249
|
+
else { \
|
|
1250
|
+
int __npy_i; \
|
|
1251
|
+
for (__npy_i=_PyAIT(it)->nd_m1; __npy_i >= 0; __npy_i--) { \
|
|
1252
|
+
if (_PyAIT(it)->coordinates[__npy_i] < \
|
|
1253
|
+
_PyAIT(it)->dims_m1[__npy_i]) { \
|
|
1254
|
+
_PyAIT(it)->coordinates[__npy_i]++; \
|
|
1255
|
+
_PyAIT(it)->dataptr += \
|
|
1256
|
+
_PyAIT(it)->strides[__npy_i]; \
|
|
1257
|
+
break; \
|
|
1258
|
+
} \
|
|
1259
|
+
else { \
|
|
1260
|
+
_PyAIT(it)->coordinates[__npy_i] = 0; \
|
|
1261
|
+
_PyAIT(it)->dataptr -= \
|
|
1262
|
+
_PyAIT(it)->backstrides[__npy_i]; \
|
|
1263
|
+
} \
|
|
1264
|
+
} \
|
|
1265
|
+
} \
|
|
1266
|
+
} while (0)
|
|
1267
|
+
|
|
1268
|
+
#define PyArray_ITER_GOTO(it, destination) do { \
|
|
1269
|
+
int __npy_i; \
|
|
1270
|
+
_PyAIT(it)->index = 0; \
|
|
1271
|
+
_PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao); \
|
|
1272
|
+
for (__npy_i = _PyAIT(it)->nd_m1; __npy_i>=0; __npy_i--) { \
|
|
1273
|
+
if (destination[__npy_i] < 0) { \
|
|
1274
|
+
destination[__npy_i] += \
|
|
1275
|
+
_PyAIT(it)->dims_m1[__npy_i]+1; \
|
|
1276
|
+
} \
|
|
1277
|
+
_PyAIT(it)->dataptr += destination[__npy_i] * \
|
|
1278
|
+
_PyAIT(it)->strides[__npy_i]; \
|
|
1279
|
+
_PyAIT(it)->coordinates[__npy_i] = \
|
|
1280
|
+
destination[__npy_i]; \
|
|
1281
|
+
_PyAIT(it)->index += destination[__npy_i] * \
|
|
1282
|
+
( __npy_i==_PyAIT(it)->nd_m1 ? 1 : \
|
|
1283
|
+
_PyAIT(it)->dims_m1[__npy_i+1]+1) ; \
|
|
1284
|
+
} \
|
|
1285
|
+
} while (0)
|
|
1286
|
+
|
|
1287
|
+
#define PyArray_ITER_GOTO1D(it, ind) do { \
|
|
1288
|
+
int __npy_i; \
|
|
1289
|
+
npy_intp __npy_ind = (npy_intp)(ind); \
|
|
1290
|
+
if (__npy_ind < 0) __npy_ind += _PyAIT(it)->size; \
|
|
1291
|
+
_PyAIT(it)->index = __npy_ind; \
|
|
1292
|
+
if (_PyAIT(it)->nd_m1 == 0) { \
|
|
1293
|
+
_PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao) + \
|
|
1294
|
+
__npy_ind * _PyAIT(it)->strides[0]; \
|
|
1295
|
+
} \
|
|
1296
|
+
else if (_PyAIT(it)->contiguous) \
|
|
1297
|
+
_PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao) + \
|
|
1298
|
+
__npy_ind * PyArray_ITEMSIZE(_PyAIT(it)->ao); \
|
|
1299
|
+
else { \
|
|
1300
|
+
_PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao); \
|
|
1301
|
+
for (__npy_i = 0; __npy_i<=_PyAIT(it)->nd_m1; \
|
|
1302
|
+
__npy_i++) { \
|
|
1303
|
+
_PyAIT(it)->coordinates[__npy_i] = \
|
|
1304
|
+
(__npy_ind / _PyAIT(it)->factors[__npy_i]); \
|
|
1305
|
+
_PyAIT(it)->dataptr += \
|
|
1306
|
+
(__npy_ind / _PyAIT(it)->factors[__npy_i]) \
|
|
1307
|
+
* _PyAIT(it)->strides[__npy_i]; \
|
|
1308
|
+
__npy_ind %= _PyAIT(it)->factors[__npy_i]; \
|
|
1309
|
+
} \
|
|
1310
|
+
} \
|
|
1311
|
+
} while (0)
|
|
1312
|
+
|
|
1313
|
+
#define PyArray_ITER_DATA(it) ((void *)(_PyAIT(it)->dataptr))
|
|
1314
|
+
|
|
1315
|
+
#define PyArray_ITER_NOTDONE(it) (_PyAIT(it)->index < _PyAIT(it)->size)
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
/*
|
|
1319
|
+
* Any object passed to PyArray_Broadcast must be binary compatible
|
|
1320
|
+
* with this structure.
|
|
1321
|
+
*/
|
|
1322
|
+
|
|
1323
|
+
typedef struct {
|
|
1324
|
+
PyObject_HEAD
|
|
1325
|
+
int numiter; /* number of iters */
|
|
1326
|
+
npy_intp size; /* broadcasted size */
|
|
1327
|
+
npy_intp index; /* current index */
|
|
1328
|
+
int nd; /* number of dims */
|
|
1329
|
+
npy_intp dimensions[NPY_MAXDIMS_LEGACY_ITERS]; /* dimensions */
|
|
1330
|
+
/*
|
|
1331
|
+
* Space for the individual iterators, do not specify size publicly
|
|
1332
|
+
* to allow changing it more easily.
|
|
1333
|
+
* One reason is that Cython uses this for checks and only allows
|
|
1334
|
+
* growing structs (as of Cython 3.0.6). It also allows NPY_MAXARGS
|
|
1335
|
+
* to be runtime dependent.
|
|
1336
|
+
*/
|
|
1337
|
+
#if (defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
|
|
1338
|
+
PyArrayIterObject *iters[64];
|
|
1339
|
+
#elif defined(__cplusplus)
|
|
1340
|
+
/*
|
|
1341
|
+
* C++ doesn't strictly support flexible members and gives compilers
|
|
1342
|
+
* warnings (pedantic only), so we lie. We can't make it 64 because
|
|
1343
|
+
* then Cython is unhappy (larger struct at runtime is OK smaller not).
|
|
1344
|
+
*/
|
|
1345
|
+
PyArrayIterObject *iters[32];
|
|
1346
|
+
#else
|
|
1347
|
+
PyArrayIterObject *iters[];
|
|
1348
|
+
#endif
|
|
1349
|
+
} PyArrayMultiIterObject;
|
|
1350
|
+
|
|
1351
|
+
#define _PyMIT(m) ((PyArrayMultiIterObject *)(m))
|
|
1352
|
+
#define PyArray_MultiIter_RESET(multi) do { \
|
|
1353
|
+
int __npy_mi; \
|
|
1354
|
+
_PyMIT(multi)->index = 0; \
|
|
1355
|
+
for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
|
|
1356
|
+
PyArray_ITER_RESET(_PyMIT(multi)->iters[__npy_mi]); \
|
|
1357
|
+
} \
|
|
1358
|
+
} while (0)
|
|
1359
|
+
|
|
1360
|
+
#define PyArray_MultiIter_NEXT(multi) do { \
|
|
1361
|
+
int __npy_mi; \
|
|
1362
|
+
_PyMIT(multi)->index++; \
|
|
1363
|
+
for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
|
|
1364
|
+
PyArray_ITER_NEXT(_PyMIT(multi)->iters[__npy_mi]); \
|
|
1365
|
+
} \
|
|
1366
|
+
} while (0)
|
|
1367
|
+
|
|
1368
|
+
#define PyArray_MultiIter_GOTO(multi, dest) do { \
|
|
1369
|
+
int __npy_mi; \
|
|
1370
|
+
for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
|
|
1371
|
+
PyArray_ITER_GOTO(_PyMIT(multi)->iters[__npy_mi], dest); \
|
|
1372
|
+
} \
|
|
1373
|
+
_PyMIT(multi)->index = _PyMIT(multi)->iters[0]->index; \
|
|
1374
|
+
} while (0)
|
|
1375
|
+
|
|
1376
|
+
#define PyArray_MultiIter_GOTO1D(multi, ind) do { \
|
|
1377
|
+
int __npy_mi; \
|
|
1378
|
+
for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
|
|
1379
|
+
PyArray_ITER_GOTO1D(_PyMIT(multi)->iters[__npy_mi], ind); \
|
|
1380
|
+
} \
|
|
1381
|
+
_PyMIT(multi)->index = _PyMIT(multi)->iters[0]->index; \
|
|
1382
|
+
} while (0)
|
|
1383
|
+
|
|
1384
|
+
#define PyArray_MultiIter_DATA(multi, i) \
|
|
1385
|
+
((void *)(_PyMIT(multi)->iters[i]->dataptr))
|
|
1386
|
+
|
|
1387
|
+
#define PyArray_MultiIter_NEXTi(multi, i) \
|
|
1388
|
+
PyArray_ITER_NEXT(_PyMIT(multi)->iters[i])
|
|
1389
|
+
|
|
1390
|
+
#define PyArray_MultiIter_NOTDONE(multi) \
|
|
1391
|
+
(_PyMIT(multi)->index < _PyMIT(multi)->size)
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
static NPY_INLINE int
|
|
1395
|
+
PyArray_MultiIter_NUMITER(PyArrayMultiIterObject *multi)
|
|
1396
|
+
{
|
|
1397
|
+
return multi->numiter;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
static NPY_INLINE npy_intp
|
|
1402
|
+
PyArray_MultiIter_SIZE(PyArrayMultiIterObject *multi)
|
|
1403
|
+
{
|
|
1404
|
+
return multi->size;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
static NPY_INLINE npy_intp
|
|
1409
|
+
PyArray_MultiIter_INDEX(PyArrayMultiIterObject *multi)
|
|
1410
|
+
{
|
|
1411
|
+
return multi->index;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
static NPY_INLINE int
|
|
1416
|
+
PyArray_MultiIter_NDIM(PyArrayMultiIterObject *multi)
|
|
1417
|
+
{
|
|
1418
|
+
return multi->nd;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
static NPY_INLINE npy_intp *
|
|
1423
|
+
PyArray_MultiIter_DIMS(PyArrayMultiIterObject *multi)
|
|
1424
|
+
{
|
|
1425
|
+
return multi->dimensions;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
static NPY_INLINE void **
|
|
1430
|
+
PyArray_MultiIter_ITERS(PyArrayMultiIterObject *multi)
|
|
1431
|
+
{
|
|
1432
|
+
return (void**)multi->iters;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
enum {
|
|
1437
|
+
NPY_NEIGHBORHOOD_ITER_ZERO_PADDING,
|
|
1438
|
+
NPY_NEIGHBORHOOD_ITER_ONE_PADDING,
|
|
1439
|
+
NPY_NEIGHBORHOOD_ITER_CONSTANT_PADDING,
|
|
1440
|
+
NPY_NEIGHBORHOOD_ITER_CIRCULAR_PADDING,
|
|
1441
|
+
NPY_NEIGHBORHOOD_ITER_MIRROR_PADDING
|
|
1442
|
+
};
|
|
1443
|
+
|
|
1444
|
+
typedef struct {
|
|
1445
|
+
PyObject_HEAD
|
|
1446
|
+
|
|
1447
|
+
/*
|
|
1448
|
+
* PyArrayIterObject part: keep this in this exact order
|
|
1449
|
+
*/
|
|
1450
|
+
int nd_m1; /* number of dimensions - 1 */
|
|
1451
|
+
npy_intp index, size;
|
|
1452
|
+
npy_intp coordinates[NPY_MAXDIMS_LEGACY_ITERS];/* N-dimensional loop */
|
|
1453
|
+
npy_intp dims_m1[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->dimensions - 1 */
|
|
1454
|
+
npy_intp strides[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->strides or fake */
|
|
1455
|
+
npy_intp backstrides[NPY_MAXDIMS_LEGACY_ITERS];/* how far to jump back */
|
|
1456
|
+
npy_intp factors[NPY_MAXDIMS_LEGACY_ITERS]; /* shape factors */
|
|
1457
|
+
PyArrayObject *ao;
|
|
1458
|
+
char *dataptr; /* pointer to current item*/
|
|
1459
|
+
npy_bool contiguous;
|
|
1460
|
+
|
|
1461
|
+
npy_intp bounds[NPY_MAXDIMS_LEGACY_ITERS][2];
|
|
1462
|
+
npy_intp limits[NPY_MAXDIMS_LEGACY_ITERS][2];
|
|
1463
|
+
npy_intp limits_sizes[NPY_MAXDIMS_LEGACY_ITERS];
|
|
1464
|
+
npy_iter_get_dataptr_t translate;
|
|
1465
|
+
|
|
1466
|
+
/*
|
|
1467
|
+
* New members
|
|
1468
|
+
*/
|
|
1469
|
+
npy_intp nd;
|
|
1470
|
+
|
|
1471
|
+
/* Dimensions is the dimension of the array */
|
|
1472
|
+
npy_intp dimensions[NPY_MAXDIMS_LEGACY_ITERS];
|
|
1473
|
+
|
|
1474
|
+
/*
|
|
1475
|
+
* Neighborhood points coordinates are computed relatively to the
|
|
1476
|
+
* point pointed by _internal_iter
|
|
1477
|
+
*/
|
|
1478
|
+
PyArrayIterObject* _internal_iter;
|
|
1479
|
+
/*
|
|
1480
|
+
* To keep a reference to the representation of the constant value
|
|
1481
|
+
* for constant padding
|
|
1482
|
+
*/
|
|
1483
|
+
char* constant;
|
|
1484
|
+
|
|
1485
|
+
int mode;
|
|
1486
|
+
} PyArrayNeighborhoodIterObject;
|
|
1487
|
+
|
|
1488
|
+
/*
|
|
1489
|
+
* Neighborhood iterator API
|
|
1490
|
+
*/
|
|
1491
|
+
|
|
1492
|
+
/* General: those work for any mode */
|
|
1493
|
+
static inline int
|
|
1494
|
+
PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter);
|
|
1495
|
+
static inline int
|
|
1496
|
+
PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter);
|
|
1497
|
+
#if 0
|
|
1498
|
+
static inline int
|
|
1499
|
+
PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter);
|
|
1500
|
+
#endif
|
|
1501
|
+
|
|
1502
|
+
/*
|
|
1503
|
+
* Include inline implementations - functions defined there are not
|
|
1504
|
+
* considered public API
|
|
1505
|
+
*/
|
|
1506
|
+
#define NUMPY_CORE_INCLUDE_NUMPY__NEIGHBORHOOD_IMP_H_
|
|
1507
|
+
#include "_neighborhood_iterator_imp.h"
|
|
1508
|
+
#undef NUMPY_CORE_INCLUDE_NUMPY__NEIGHBORHOOD_IMP_H_
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
/* The default array type */
|
|
1513
|
+
#define NPY_DEFAULT_TYPE NPY_DOUBLE
|
|
1514
|
+
/* default integer type defined in npy_2_compat header */
|
|
1515
|
+
|
|
1516
|
+
/*
|
|
1517
|
+
* All sorts of useful ways to look into a PyArrayObject. It is recommended
|
|
1518
|
+
* to use PyArrayObject * objects instead of always casting from PyObject *,
|
|
1519
|
+
* for improved type checking.
|
|
1520
|
+
*
|
|
1521
|
+
* In many cases here the macro versions of the accessors are deprecated,
|
|
1522
|
+
* but can't be immediately changed to inline functions because the
|
|
1523
|
+
* preexisting macros accept PyObject * and do automatic casts. Inline
|
|
1524
|
+
* functions accepting PyArrayObject * provides for some compile-time
|
|
1525
|
+
* checking of correctness when working with these objects in C.
|
|
1526
|
+
*/
|
|
1527
|
+
|
|
1528
|
+
#define PyArray_ISONESEGMENT(m) (PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS) || \
|
|
1529
|
+
PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS))
|
|
1530
|
+
|
|
1531
|
+
#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) && \
|
|
1532
|
+
(!PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS)))
|
|
1533
|
+
|
|
1534
|
+
#define PyArray_FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) ? \
|
|
1535
|
+
NPY_ARRAY_F_CONTIGUOUS : 0))
|
|
1536
|
+
|
|
1537
|
+
static inline int
|
|
1538
|
+
PyArray_NDIM(const PyArrayObject *arr)
|
|
1539
|
+
{
|
|
1540
|
+
return ((PyArrayObject_fields *)arr)->nd;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
static inline void *
|
|
1544
|
+
PyArray_DATA(const PyArrayObject *arr)
|
|
1545
|
+
{
|
|
1546
|
+
return ((PyArrayObject_fields *)arr)->data;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
static inline char *
|
|
1550
|
+
PyArray_BYTES(const PyArrayObject *arr)
|
|
1551
|
+
{
|
|
1552
|
+
return ((PyArrayObject_fields *)arr)->data;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
static inline npy_intp *
|
|
1556
|
+
PyArray_DIMS(const PyArrayObject *arr)
|
|
1557
|
+
{
|
|
1558
|
+
return ((PyArrayObject_fields *)arr)->dimensions;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
static inline npy_intp *
|
|
1562
|
+
PyArray_STRIDES(const PyArrayObject *arr)
|
|
1563
|
+
{
|
|
1564
|
+
return ((PyArrayObject_fields *)arr)->strides;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
static inline npy_intp
|
|
1568
|
+
PyArray_DIM(const PyArrayObject *arr, int idim)
|
|
1569
|
+
{
|
|
1570
|
+
return ((PyArrayObject_fields *)arr)->dimensions[idim];
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
static inline npy_intp
|
|
1574
|
+
PyArray_STRIDE(const PyArrayObject *arr, int istride)
|
|
1575
|
+
{
|
|
1576
|
+
return ((PyArrayObject_fields *)arr)->strides[istride];
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
static inline NPY_RETURNS_BORROWED_REF PyObject *
|
|
1580
|
+
PyArray_BASE(const PyArrayObject *arr)
|
|
1581
|
+
{
|
|
1582
|
+
return ((PyArrayObject_fields *)arr)->base;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
static inline NPY_RETURNS_BORROWED_REF PyArray_Descr *
|
|
1586
|
+
PyArray_DESCR(const PyArrayObject *arr)
|
|
1587
|
+
{
|
|
1588
|
+
return ((PyArrayObject_fields *)arr)->descr;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
static inline int
|
|
1592
|
+
PyArray_FLAGS(const PyArrayObject *arr)
|
|
1593
|
+
{
|
|
1594
|
+
return ((PyArrayObject_fields *)arr)->flags;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
static inline int
|
|
1599
|
+
PyArray_TYPE(const PyArrayObject *arr)
|
|
1600
|
+
{
|
|
1601
|
+
return ((PyArrayObject_fields *)arr)->descr->type_num;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
static inline int
|
|
1605
|
+
PyArray_CHKFLAGS(const PyArrayObject *arr, int flags)
|
|
1606
|
+
{
|
|
1607
|
+
return (PyArray_FLAGS(arr) & flags) == flags;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
static inline PyArray_Descr *
|
|
1611
|
+
PyArray_DTYPE(const PyArrayObject *arr)
|
|
1612
|
+
{
|
|
1613
|
+
return ((PyArrayObject_fields *)arr)->descr;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
static inline npy_intp *
|
|
1617
|
+
PyArray_SHAPE(const PyArrayObject *arr)
|
|
1618
|
+
{
|
|
1619
|
+
return ((PyArrayObject_fields *)arr)->dimensions;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/*
|
|
1623
|
+
* Enables the specified array flags. Does no checking,
|
|
1624
|
+
* assumes you know what you're doing.
|
|
1625
|
+
*/
|
|
1626
|
+
static inline void
|
|
1627
|
+
PyArray_ENABLEFLAGS(PyArrayObject *arr, int flags)
|
|
1628
|
+
{
|
|
1629
|
+
((PyArrayObject_fields *)arr)->flags |= flags;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
/*
|
|
1633
|
+
* Clears the specified array flags. Does no checking,
|
|
1634
|
+
* assumes you know what you're doing.
|
|
1635
|
+
*/
|
|
1636
|
+
static inline void
|
|
1637
|
+
PyArray_CLEARFLAGS(PyArrayObject *arr, int flags)
|
|
1638
|
+
{
|
|
1639
|
+
((PyArrayObject_fields *)arr)->flags &= ~flags;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
#if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
|
|
1643
|
+
static inline NPY_RETURNS_BORROWED_REF PyObject *
|
|
1644
|
+
PyArray_HANDLER(PyArrayObject *arr)
|
|
1645
|
+
{
|
|
1646
|
+
return ((PyArrayObject_fields *)arr)->mem_handler;
|
|
1647
|
+
}
|
|
1648
|
+
#endif
|
|
1649
|
+
|
|
1650
|
+
#define PyTypeNum_ISBOOL(type) ((type) == NPY_BOOL)
|
|
1651
|
+
|
|
1652
|
+
#define PyTypeNum_ISUNSIGNED(type) (((type) == NPY_UBYTE) || \
|
|
1653
|
+
((type) == NPY_USHORT) || \
|
|
1654
|
+
((type) == NPY_UINT) || \
|
|
1655
|
+
((type) == NPY_ULONG) || \
|
|
1656
|
+
((type) == NPY_ULONGLONG))
|
|
1657
|
+
|
|
1658
|
+
#define PyTypeNum_ISSIGNED(type) (((type) == NPY_BYTE) || \
|
|
1659
|
+
((type) == NPY_SHORT) || \
|
|
1660
|
+
((type) == NPY_INT) || \
|
|
1661
|
+
((type) == NPY_LONG) || \
|
|
1662
|
+
((type) == NPY_LONGLONG))
|
|
1663
|
+
|
|
1664
|
+
#define PyTypeNum_ISINTEGER(type) (((type) >= NPY_BYTE) && \
|
|
1665
|
+
((type) <= NPY_ULONGLONG))
|
|
1666
|
+
|
|
1667
|
+
#define PyTypeNum_ISFLOAT(type) ((((type) >= NPY_FLOAT) && \
|
|
1668
|
+
((type) <= NPY_LONGDOUBLE)) || \
|
|
1669
|
+
((type) == NPY_HALF))
|
|
1670
|
+
|
|
1671
|
+
#define PyTypeNum_ISNUMBER(type) (((type) <= NPY_CLONGDOUBLE) || \
|
|
1672
|
+
((type) == NPY_HALF))
|
|
1673
|
+
|
|
1674
|
+
#define PyTypeNum_ISSTRING(type) (((type) == NPY_STRING) || \
|
|
1675
|
+
((type) == NPY_UNICODE))
|
|
1676
|
+
|
|
1677
|
+
#define PyTypeNum_ISCOMPLEX(type) (((type) >= NPY_CFLOAT) && \
|
|
1678
|
+
((type) <= NPY_CLONGDOUBLE))
|
|
1679
|
+
|
|
1680
|
+
#define PyTypeNum_ISFLEXIBLE(type) (((type) >=NPY_STRING) && \
|
|
1681
|
+
((type) <=NPY_VOID))
|
|
1682
|
+
|
|
1683
|
+
#define PyTypeNum_ISDATETIME(type) (((type) >=NPY_DATETIME) && \
|
|
1684
|
+
((type) <=NPY_TIMEDELTA))
|
|
1685
|
+
|
|
1686
|
+
#define PyTypeNum_ISUSERDEF(type) (((type) >= NPY_USERDEF) && \
|
|
1687
|
+
((type) < NPY_USERDEF+ \
|
|
1688
|
+
NPY_NUMUSERTYPES))
|
|
1689
|
+
|
|
1690
|
+
#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \
|
|
1691
|
+
PyTypeNum_ISUSERDEF(type))
|
|
1692
|
+
|
|
1693
|
+
#define PyTypeNum_ISOBJECT(type) ((type) == NPY_OBJECT)
|
|
1694
|
+
|
|
1695
|
+
|
|
1696
|
+
#define PyDataType_ISLEGACY(dtype) ((dtype)->type_num < NPY_VSTRING && ((dtype)->type_num >= 0))
|
|
1697
|
+
#define PyDataType_ISBOOL(obj) PyTypeNum_ISBOOL(((PyArray_Descr*)(obj))->type_num)
|
|
1698
|
+
#define PyDataType_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(((PyArray_Descr*)(obj))->type_num)
|
|
1699
|
+
#define PyDataType_ISSIGNED(obj) PyTypeNum_ISSIGNED(((PyArray_Descr*)(obj))->type_num)
|
|
1700
|
+
#define PyDataType_ISINTEGER(obj) PyTypeNum_ISINTEGER(((PyArray_Descr*)(obj))->type_num )
|
|
1701
|
+
#define PyDataType_ISFLOAT(obj) PyTypeNum_ISFLOAT(((PyArray_Descr*)(obj))->type_num)
|
|
1702
|
+
#define PyDataType_ISNUMBER(obj) PyTypeNum_ISNUMBER(((PyArray_Descr*)(obj))->type_num)
|
|
1703
|
+
#define PyDataType_ISSTRING(obj) PyTypeNum_ISSTRING(((PyArray_Descr*)(obj))->type_num)
|
|
1704
|
+
#define PyDataType_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(((PyArray_Descr*)(obj))->type_num)
|
|
1705
|
+
#define PyDataType_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(((PyArray_Descr*)(obj))->type_num)
|
|
1706
|
+
#define PyDataType_ISDATETIME(obj) PyTypeNum_ISDATETIME(((PyArray_Descr*)(obj))->type_num)
|
|
1707
|
+
#define PyDataType_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(((PyArray_Descr*)(obj))->type_num)
|
|
1708
|
+
#define PyDataType_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(((PyArray_Descr*)(obj))->type_num)
|
|
1709
|
+
#define PyDataType_ISOBJECT(obj) PyTypeNum_ISOBJECT(((PyArray_Descr*)(obj))->type_num)
|
|
1710
|
+
#define PyDataType_MAKEUNSIZED(dtype) ((dtype)->elsize = 0)
|
|
1711
|
+
/*
|
|
1712
|
+
* PyDataType_* FLAGS, FLACHK, REFCHK, HASFIELDS, HASSUBARRAY, UNSIZED,
|
|
1713
|
+
* SUBARRAY, NAMES, FIELDS, C_METADATA, and METADATA require version specific
|
|
1714
|
+
* lookup and are defined in npy_2_compat.h.
|
|
1715
|
+
*/
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))
|
|
1719
|
+
#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))
|
|
1720
|
+
#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))
|
|
1721
|
+
#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))
|
|
1722
|
+
#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))
|
|
1723
|
+
#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))
|
|
1724
|
+
#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))
|
|
1725
|
+
#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))
|
|
1726
|
+
#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
|
|
1727
|
+
#define PyArray_ISDATETIME(obj) PyTypeNum_ISDATETIME(PyArray_TYPE(obj))
|
|
1728
|
+
#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))
|
|
1729
|
+
#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))
|
|
1730
|
+
#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))
|
|
1731
|
+
#define PyArray_HASFIELDS(obj) PyDataType_HASFIELDS(PyArray_DESCR(obj))
|
|
1732
|
+
|
|
1733
|
+
/*
|
|
1734
|
+
* FIXME: This should check for a flag on the data-type that
|
|
1735
|
+
* states whether or not it is variable length. Because the
|
|
1736
|
+
* ISFLEXIBLE check is hard-coded to the built-in data-types.
|
|
1737
|
+
*/
|
|
1738
|
+
#define PyArray_ISVARIABLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
|
|
1739
|
+
|
|
1740
|
+
#define PyArray_SAFEALIGNEDCOPY(obj) (PyArray_ISALIGNED(obj) && !PyArray_ISVARIABLE(obj))
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
#define NPY_LITTLE '<'
|
|
1744
|
+
#define NPY_BIG '>'
|
|
1745
|
+
#define NPY_NATIVE '='
|
|
1746
|
+
#define NPY_SWAP 's'
|
|
1747
|
+
#define NPY_IGNORE '|'
|
|
1748
|
+
|
|
1749
|
+
#if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
|
|
1750
|
+
#define NPY_NATBYTE NPY_BIG
|
|
1751
|
+
#define NPY_OPPBYTE NPY_LITTLE
|
|
1752
|
+
#else
|
|
1753
|
+
#define NPY_NATBYTE NPY_LITTLE
|
|
1754
|
+
#define NPY_OPPBYTE NPY_BIG
|
|
1755
|
+
#endif
|
|
1756
|
+
|
|
1757
|
+
#define PyArray_ISNBO(arg) ((arg) != NPY_OPPBYTE)
|
|
1758
|
+
#define PyArray_IsNativeByteOrder PyArray_ISNBO
|
|
1759
|
+
#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)
|
|
1760
|
+
#define PyArray_ISBYTESWAPPED(m) (!PyArray_ISNOTSWAPPED(m))
|
|
1761
|
+
|
|
1762
|
+
#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) && \
|
|
1763
|
+
PyArray_ISNOTSWAPPED(m))
|
|
1764
|
+
|
|
1765
|
+
#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, NPY_ARRAY_CARRAY)
|
|
1766
|
+
#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, NPY_ARRAY_CARRAY_RO)
|
|
1767
|
+
#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, NPY_ARRAY_FARRAY)
|
|
1768
|
+
#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, NPY_ARRAY_FARRAY_RO)
|
|
1769
|
+
#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, NPY_ARRAY_BEHAVED)
|
|
1770
|
+
#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, NPY_ARRAY_ALIGNED)
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
#define PyDataType_ISNOTSWAPPED(d) PyArray_ISNBO(((PyArray_Descr *)(d))->byteorder)
|
|
1774
|
+
#define PyDataType_ISBYTESWAPPED(d) (!PyDataType_ISNOTSWAPPED(d))
|
|
1775
|
+
|
|
1776
|
+
/************************************************************
|
|
1777
|
+
* A struct used by PyArray_CreateSortedStridePerm, new in 1.7.
|
|
1778
|
+
************************************************************/
|
|
1779
|
+
|
|
1780
|
+
typedef struct {
|
|
1781
|
+
npy_intp perm, stride;
|
|
1782
|
+
} npy_stride_sort_item;
|
|
1783
|
+
|
|
1784
|
+
/************************************************************
|
|
1785
|
+
* This is the form of the struct that's stored in the
|
|
1786
|
+
* PyCapsule returned by an array's __array_struct__ attribute. See
|
|
1787
|
+
* https://docs.scipy.org/doc/numpy/reference/arrays.interface.html for the full
|
|
1788
|
+
* documentation.
|
|
1789
|
+
************************************************************/
|
|
1790
|
+
typedef struct {
|
|
1791
|
+
int two; /*
|
|
1792
|
+
* contains the integer 2 as a sanity
|
|
1793
|
+
* check
|
|
1794
|
+
*/
|
|
1795
|
+
|
|
1796
|
+
int nd; /* number of dimensions */
|
|
1797
|
+
|
|
1798
|
+
char typekind; /*
|
|
1799
|
+
* kind in array --- character code of
|
|
1800
|
+
* typestr
|
|
1801
|
+
*/
|
|
1802
|
+
|
|
1803
|
+
int itemsize; /* size of each element */
|
|
1804
|
+
|
|
1805
|
+
int flags; /*
|
|
1806
|
+
* how should be data interpreted. Valid
|
|
1807
|
+
* flags are CONTIGUOUS (1), F_CONTIGUOUS (2),
|
|
1808
|
+
* ALIGNED (0x100), NOTSWAPPED (0x200), and
|
|
1809
|
+
* WRITEABLE (0x400). ARR_HAS_DESCR (0x800)
|
|
1810
|
+
* states that arrdescr field is present in
|
|
1811
|
+
* structure
|
|
1812
|
+
*/
|
|
1813
|
+
|
|
1814
|
+
npy_intp *shape; /*
|
|
1815
|
+
* A length-nd array of shape
|
|
1816
|
+
* information
|
|
1817
|
+
*/
|
|
1818
|
+
|
|
1819
|
+
npy_intp *strides; /* A length-nd array of stride information */
|
|
1820
|
+
|
|
1821
|
+
void *data; /* A pointer to the first element of the array */
|
|
1822
|
+
|
|
1823
|
+
PyObject *descr; /*
|
|
1824
|
+
* A list of fields or NULL (ignored if flags
|
|
1825
|
+
* does not have ARR_HAS_DESCR flag set)
|
|
1826
|
+
*/
|
|
1827
|
+
} PyArrayInterface;
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
/****************************************
|
|
1831
|
+
* NpyString
|
|
1832
|
+
*
|
|
1833
|
+
* Types used by the NpyString API.
|
|
1834
|
+
****************************************/
|
|
1835
|
+
|
|
1836
|
+
/*
|
|
1837
|
+
* A "packed" encoded string. The string data must be accessed by first unpacking the string.
|
|
1838
|
+
*/
|
|
1839
|
+
typedef struct npy_packed_static_string npy_packed_static_string;
|
|
1840
|
+
|
|
1841
|
+
/*
|
|
1842
|
+
* An unpacked read-only view onto the data in a packed string
|
|
1843
|
+
*/
|
|
1844
|
+
typedef struct npy_unpacked_static_string {
|
|
1845
|
+
size_t size;
|
|
1846
|
+
const char *buf;
|
|
1847
|
+
} npy_static_string;
|
|
1848
|
+
|
|
1849
|
+
/*
|
|
1850
|
+
* Handles heap allocations for static strings.
|
|
1851
|
+
*/
|
|
1852
|
+
typedef struct npy_string_allocator npy_string_allocator;
|
|
1853
|
+
|
|
1854
|
+
typedef struct {
|
|
1855
|
+
PyArray_Descr base;
|
|
1856
|
+
// The object representing a null value
|
|
1857
|
+
PyObject *na_object;
|
|
1858
|
+
// Flag indicating whether or not to coerce arbitrary objects to strings
|
|
1859
|
+
char coerce;
|
|
1860
|
+
// Flag indicating the na object is NaN-like
|
|
1861
|
+
char has_nan_na;
|
|
1862
|
+
// Flag indicating the na object is a string
|
|
1863
|
+
char has_string_na;
|
|
1864
|
+
// If nonzero, indicates that this instance is owned by an array already
|
|
1865
|
+
char array_owned;
|
|
1866
|
+
// The string data to use when a default string is needed
|
|
1867
|
+
npy_static_string default_string;
|
|
1868
|
+
// The name of the missing data object, if any
|
|
1869
|
+
npy_static_string na_name;
|
|
1870
|
+
// the allocator should only be directly accessed after
|
|
1871
|
+
// acquiring the allocator_lock and the lock should
|
|
1872
|
+
// be released immediately after the allocator is
|
|
1873
|
+
// no longer needed
|
|
1874
|
+
npy_string_allocator *allocator;
|
|
1875
|
+
} PyArray_StringDTypeObject;
|
|
1876
|
+
|
|
1877
|
+
/*
|
|
1878
|
+
* PyArray_DTypeMeta related definitions.
|
|
1879
|
+
*
|
|
1880
|
+
* As of now, this API is preliminary and will be extended as necessary.
|
|
1881
|
+
*/
|
|
1882
|
+
#if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
|
|
1883
|
+
/*
|
|
1884
|
+
* The Structures defined in this block are currently considered
|
|
1885
|
+
* private API and may change without warning!
|
|
1886
|
+
* Part of this (at least the size) is expected to be public API without
|
|
1887
|
+
* further modifications.
|
|
1888
|
+
*/
|
|
1889
|
+
/* TODO: Make this definition public in the API, as soon as its settled */
|
|
1890
|
+
NPY_NO_EXPORT extern PyTypeObject PyArrayDTypeMeta_Type;
|
|
1891
|
+
|
|
1892
|
+
/*
|
|
1893
|
+
* While NumPy DTypes would not need to be heap types the plan is to
|
|
1894
|
+
* make DTypes available in Python at which point they will be heap types.
|
|
1895
|
+
* Since we also wish to add fields to the DType class, this looks like
|
|
1896
|
+
* a typical instance definition, but with PyHeapTypeObject instead of
|
|
1897
|
+
* only the PyObject_HEAD.
|
|
1898
|
+
* This must only be exposed very extremely careful consideration, since
|
|
1899
|
+
* it is a fairly complex construct which may be better to allow
|
|
1900
|
+
* refactoring of.
|
|
1901
|
+
*/
|
|
1902
|
+
typedef struct {
|
|
1903
|
+
PyHeapTypeObject super;
|
|
1904
|
+
|
|
1905
|
+
/*
|
|
1906
|
+
* Most DTypes will have a singleton default instance, for the
|
|
1907
|
+
* parametric legacy DTypes (bytes, string, void, datetime) this
|
|
1908
|
+
* may be a pointer to the *prototype* instance?
|
|
1909
|
+
*/
|
|
1910
|
+
PyArray_Descr *singleton;
|
|
1911
|
+
/* Copy of the legacy DTypes type number, usually invalid. */
|
|
1912
|
+
int type_num;
|
|
1913
|
+
|
|
1914
|
+
/* The type object of the scalar instances (may be NULL?) */
|
|
1915
|
+
PyTypeObject *scalar_type;
|
|
1916
|
+
/*
|
|
1917
|
+
* DType flags to signal legacy, parametric, or
|
|
1918
|
+
* abstract. But plenty of space for additional information/flags.
|
|
1919
|
+
*/
|
|
1920
|
+
npy_uint64 flags;
|
|
1921
|
+
|
|
1922
|
+
/*
|
|
1923
|
+
* Use indirection in order to allow a fixed size for this struct.
|
|
1924
|
+
* A stable ABI size makes creating a static DType less painful
|
|
1925
|
+
* while also ensuring flexibility for all opaque API (with one
|
|
1926
|
+
* indirection due the pointer lookup).
|
|
1927
|
+
*/
|
|
1928
|
+
void *dt_slots;
|
|
1929
|
+
void *reserved[3];
|
|
1930
|
+
} PyArray_DTypeMeta;
|
|
1931
|
+
|
|
1932
|
+
#endif /* NPY_INTERNAL_BUILD */
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
/*
|
|
1936
|
+
* Use the keyword NPY_DEPRECATED_INCLUDES to ensure that the header files
|
|
1937
|
+
* npy_*_*_deprecated_api.h are only included from here and nowhere else.
|
|
1938
|
+
*/
|
|
1939
|
+
#ifdef NPY_DEPRECATED_INCLUDES
|
|
1940
|
+
#error "Do not use the reserved keyword NPY_DEPRECATED_INCLUDES."
|
|
1941
|
+
#endif
|
|
1942
|
+
#define NPY_DEPRECATED_INCLUDES
|
|
1943
|
+
/*
|
|
1944
|
+
* There is no file npy_1_8_deprecated_api.h since there are no additional
|
|
1945
|
+
* deprecated API features in NumPy 1.8.
|
|
1946
|
+
*
|
|
1947
|
+
* Note to maintainers: insert code like the following in future NumPy
|
|
1948
|
+
* versions.
|
|
1949
|
+
*
|
|
1950
|
+
* #if !defined(NPY_NO_DEPRECATED_API) || \
|
|
1951
|
+
* (NPY_NO_DEPRECATED_API < NPY_1_9_API_VERSION)
|
|
1952
|
+
* #include "npy_1_9_deprecated_api.h"
|
|
1953
|
+
* #endif
|
|
1954
|
+
* Then in the npy_1_9_deprecated_api.h header add something like this
|
|
1955
|
+
* --------------------
|
|
1956
|
+
* #ifndef NPY_DEPRECATED_INCLUDES
|
|
1957
|
+
* #error "Should never include npy_*_*_deprecated_api directly."
|
|
1958
|
+
* #endif
|
|
1959
|
+
* #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_
|
|
1960
|
+
* #define NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_
|
|
1961
|
+
*
|
|
1962
|
+
* #ifndef NPY_NO_DEPRECATED_API
|
|
1963
|
+
* #if defined(_WIN32)
|
|
1964
|
+
* #define _WARN___STR2__(x) #x
|
|
1965
|
+
* #define _WARN___STR1__(x) _WARN___STR2__(x)
|
|
1966
|
+
* #define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: "
|
|
1967
|
+
* #pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it with " \
|
|
1968
|
+
* "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION")
|
|
1969
|
+
* #else
|
|
1970
|
+
* #warning "Using deprecated NumPy API, disable it with " \
|
|
1971
|
+
* "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
|
|
1972
|
+
* #endif
|
|
1973
|
+
* #endif
|
|
1974
|
+
* --------------------
|
|
1975
|
+
*/
|
|
1976
|
+
#undef NPY_DEPRECATED_INCLUDES
|
|
1977
|
+
|
|
1978
|
+
#ifdef __cplusplus
|
|
1979
|
+
}
|
|
1980
|
+
#endif
|
|
1981
|
+
|
|
1982
|
+
#endif /* NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_ */
|