numpy 2.4.1__cp314-cp314t-win_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 +955 -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.cp314t-win_arm64.lib +0 -0
- numpy/_core/_multiarray_tests.cp314t-win_arm64.pyd +0 -0
- numpy/_core/_multiarray_umath.cp314t-win_arm64.lib +0 -0
- numpy/_core/_multiarray_umath.cp314t-win_arm64.pyd +0 -0
- numpy/_core/_operand_flag_tests.cp314t-win_arm64.lib +0 -0
- numpy/_core/_operand_flag_tests.cp314t-win_arm64.pyd +0 -0
- numpy/_core/_rational_tests.cp314t-win_arm64.lib +0 -0
- numpy/_core/_rational_tests.cp314t-win_arm64.pyd +0 -0
- numpy/_core/_simd.cp314t-win_arm64.lib +0 -0
- numpy/_core/_simd.cp314t-win_arm64.pyd +0 -0
- numpy/_core/_simd.pyi +35 -0
- numpy/_core/_string_helpers.py +100 -0
- numpy/_core/_string_helpers.pyi +12 -0
- numpy/_core/_struct_ufunc_tests.cp314t-win_arm64.lib +0 -0
- numpy/_core/_struct_ufunc_tests.cp314t-win_arm64.pyd +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.cp314t-win_arm64.lib +0 -0
- numpy/_core/_umath_tests.cp314t-win_arm64.pyd +0 -0
- numpy/_core/_umath_tests.pyi +47 -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/npy-pkg-config/mlib.ini +12 -0
- numpy/_core/lib/npy-pkg-config/npymath.ini +20 -0
- numpy/_core/lib/npymath.lib +0 -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/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.cp314t-win_arm64.lib +0 -0
- numpy/fft/_pocketfft_umath.cp314t-win_arm64.pyd +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.cp314t-win_arm64.lib +0 -0
- numpy/linalg/_umath_linalg.cp314t-win_arm64.pyd +0 -0
- numpy/linalg/_umath_linalg.pyi +60 -0
- numpy/linalg/lapack_lite.cp314t-win_arm64.lib +0 -0
- numpy/linalg/lapack_lite.cp314t-win_arm64.pyd +0 -0
- numpy/linalg/lapack_lite.pyi +143 -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.cp314t-win_arm64.lib +0 -0
- numpy/random/_bounded_integers.cp314t-win_arm64.pyd +0 -0
- numpy/random/_bounded_integers.pxd +38 -0
- numpy/random/_bounded_integers.pyi +1 -0
- numpy/random/_common.cp314t-win_arm64.lib +0 -0
- numpy/random/_common.cp314t-win_arm64.pyd +0 -0
- numpy/random/_common.pxd +110 -0
- numpy/random/_common.pyi +16 -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.cp314t-win_arm64.lib +0 -0
- numpy/random/_generator.cp314t-win_arm64.pyd +0 -0
- numpy/random/_generator.pyi +862 -0
- numpy/random/_mt19937.cp314t-win_arm64.lib +0 -0
- numpy/random/_mt19937.cp314t-win_arm64.pyd +0 -0
- numpy/random/_mt19937.pyi +27 -0
- numpy/random/_pcg64.cp314t-win_arm64.lib +0 -0
- numpy/random/_pcg64.cp314t-win_arm64.pyd +0 -0
- numpy/random/_pcg64.pyi +41 -0
- numpy/random/_philox.cp314t-win_arm64.lib +0 -0
- numpy/random/_philox.cp314t-win_arm64.pyd +0 -0
- numpy/random/_philox.pyi +36 -0
- numpy/random/_pickle.py +88 -0
- numpy/random/_pickle.pyi +43 -0
- numpy/random/_sfc64.cp314t-win_arm64.lib +0 -0
- numpy/random/_sfc64.cp314t-win_arm64.pyd +0 -0
- numpy/random/_sfc64.pyi +25 -0
- numpy/random/bit_generator.cp314t-win_arm64.lib +0 -0
- numpy/random/bit_generator.cp314t-win_arm64.pyd +0 -0
- numpy/random/bit_generator.pxd +40 -0
- numpy/random/bit_generator.pyi +123 -0
- numpy/random/c_distributions.pxd +119 -0
- numpy/random/lib/npyrandom.lib +0 -0
- numpy/random/mtrand.cp314t-win_arm64.lib +0 -0
- numpy/random/mtrand.cp314t-win_arm64.pyd +0 -0
- numpy/random/mtrand.pyi +759 -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/DELVEWHEEL +2 -0
- numpy-2.4.1.dist-info/METADATA +139 -0
- numpy-2.4.1.dist-info/RECORD +932 -0
- numpy-2.4.1.dist-info/WHEEL +4 -0
- numpy-2.4.1.dist-info/entry_points.txt +13 -0
- numpy-2.4.1.dist-info/licenses/LICENSE.txt +914 -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
- numpy.libs/msvcp140-5f1c5dd31916990d94181e07bc3afb32.dll +0 -0
- numpy.libs/scipy_openblas-7b69cbfd2599e6035f1310f2a72d59a6.dll +0 -0
|
@@ -0,0 +1,1191 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for the various polynomial Classes.
|
|
3
|
+
|
|
4
|
+
The ABCPolyBase class provides the methods needed to implement the common API
|
|
5
|
+
for the various polynomial classes. It operates as a mixin, but uses the
|
|
6
|
+
abc module from the stdlib, hence it is only available for Python >= 2.6.
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
import abc
|
|
10
|
+
import numbers
|
|
11
|
+
import os
|
|
12
|
+
from collections.abc import Callable
|
|
13
|
+
|
|
14
|
+
import numpy as np
|
|
15
|
+
|
|
16
|
+
from . import polyutils as pu
|
|
17
|
+
|
|
18
|
+
__all__ = ['ABCPolyBase']
|
|
19
|
+
|
|
20
|
+
class ABCPolyBase(abc.ABC):
|
|
21
|
+
"""An abstract base class for immutable series classes.
|
|
22
|
+
|
|
23
|
+
ABCPolyBase provides the standard Python numerical methods
|
|
24
|
+
'+', '-', '*', '//', '%', 'divmod', '**', and '()' along with the
|
|
25
|
+
methods listed below.
|
|
26
|
+
|
|
27
|
+
Parameters
|
|
28
|
+
----------
|
|
29
|
+
coef : array_like
|
|
30
|
+
Series coefficients in order of increasing degree, i.e.,
|
|
31
|
+
``(1, 2, 3)`` gives ``1*P_0(x) + 2*P_1(x) + 3*P_2(x)``, where
|
|
32
|
+
``P_i`` is the basis polynomials of degree ``i``.
|
|
33
|
+
domain : (2,) array_like, optional
|
|
34
|
+
Domain to use. The interval ``[domain[0], domain[1]]`` is mapped
|
|
35
|
+
to the interval ``[window[0], window[1]]`` by shifting and scaling.
|
|
36
|
+
The default value is the derived class domain.
|
|
37
|
+
window : (2,) array_like, optional
|
|
38
|
+
Window, see domain for its use. The default value is the
|
|
39
|
+
derived class window.
|
|
40
|
+
symbol : str, optional
|
|
41
|
+
Symbol used to represent the independent variable in string
|
|
42
|
+
representations of the polynomial expression, e.g. for printing.
|
|
43
|
+
The symbol must be a valid Python identifier. Default value is 'x'.
|
|
44
|
+
|
|
45
|
+
.. versionadded:: 1.24
|
|
46
|
+
|
|
47
|
+
Attributes
|
|
48
|
+
----------
|
|
49
|
+
coef : (N,) ndarray
|
|
50
|
+
Series coefficients in order of increasing degree.
|
|
51
|
+
domain : (2,) ndarray
|
|
52
|
+
Domain that is mapped to window.
|
|
53
|
+
window : (2,) ndarray
|
|
54
|
+
Window that domain is mapped to.
|
|
55
|
+
symbol : str
|
|
56
|
+
Symbol representing the independent variable.
|
|
57
|
+
|
|
58
|
+
Class Attributes
|
|
59
|
+
----------------
|
|
60
|
+
maxpower : int
|
|
61
|
+
Maximum power allowed, i.e., the largest number ``n`` such that
|
|
62
|
+
``p(x)**n`` is allowed. This is to limit runaway polynomial size.
|
|
63
|
+
domain : (2,) ndarray
|
|
64
|
+
Default domain of the class.
|
|
65
|
+
window : (2,) ndarray
|
|
66
|
+
Default window of the class.
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
# Not hashable
|
|
71
|
+
__hash__ = None
|
|
72
|
+
|
|
73
|
+
# Opt out of numpy ufuncs and Python ops with ndarray subclasses.
|
|
74
|
+
__array_ufunc__ = None
|
|
75
|
+
|
|
76
|
+
# Limit runaway size. T_n^m has degree n*m
|
|
77
|
+
maxpower = 100
|
|
78
|
+
|
|
79
|
+
# Unicode character mappings for improved __str__
|
|
80
|
+
_superscript_mapping = str.maketrans({
|
|
81
|
+
"0": "⁰",
|
|
82
|
+
"1": "¹",
|
|
83
|
+
"2": "²",
|
|
84
|
+
"3": "³",
|
|
85
|
+
"4": "⁴",
|
|
86
|
+
"5": "⁵",
|
|
87
|
+
"6": "⁶",
|
|
88
|
+
"7": "⁷",
|
|
89
|
+
"8": "⁸",
|
|
90
|
+
"9": "⁹"
|
|
91
|
+
})
|
|
92
|
+
_subscript_mapping = str.maketrans({
|
|
93
|
+
"0": "₀",
|
|
94
|
+
"1": "₁",
|
|
95
|
+
"2": "₂",
|
|
96
|
+
"3": "₃",
|
|
97
|
+
"4": "₄",
|
|
98
|
+
"5": "₅",
|
|
99
|
+
"6": "₆",
|
|
100
|
+
"7": "₇",
|
|
101
|
+
"8": "₈",
|
|
102
|
+
"9": "₉"
|
|
103
|
+
})
|
|
104
|
+
# Some fonts don't support full unicode character ranges necessary for
|
|
105
|
+
# the full set of superscripts and subscripts, including common/default
|
|
106
|
+
# fonts in Windows shells/terminals. Therefore, default to ascii-only
|
|
107
|
+
# printing on windows.
|
|
108
|
+
_use_unicode = not os.name == 'nt'
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def symbol(self):
|
|
112
|
+
return self._symbol
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
@abc.abstractmethod
|
|
116
|
+
def domain(self):
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
@abc.abstractmethod
|
|
121
|
+
def window(self):
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
@abc.abstractmethod
|
|
126
|
+
def basis_name(self):
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
@staticmethod
|
|
130
|
+
@abc.abstractmethod
|
|
131
|
+
def _add(c1, c2):
|
|
132
|
+
pass
|
|
133
|
+
|
|
134
|
+
@staticmethod
|
|
135
|
+
@abc.abstractmethod
|
|
136
|
+
def _sub(c1, c2):
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
@staticmethod
|
|
140
|
+
@abc.abstractmethod
|
|
141
|
+
def _mul(c1, c2):
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
@staticmethod
|
|
145
|
+
@abc.abstractmethod
|
|
146
|
+
def _div(c1, c2):
|
|
147
|
+
pass
|
|
148
|
+
|
|
149
|
+
@staticmethod
|
|
150
|
+
@abc.abstractmethod
|
|
151
|
+
def _pow(c, pow, maxpower=None):
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
@staticmethod
|
|
155
|
+
@abc.abstractmethod
|
|
156
|
+
def _val(x, c):
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
@staticmethod
|
|
160
|
+
@abc.abstractmethod
|
|
161
|
+
def _int(c, m, k, lbnd, scl):
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
@staticmethod
|
|
165
|
+
@abc.abstractmethod
|
|
166
|
+
def _der(c, m, scl):
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
@staticmethod
|
|
170
|
+
@abc.abstractmethod
|
|
171
|
+
def _fit(x, y, deg, rcond, full):
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
@staticmethod
|
|
175
|
+
@abc.abstractmethod
|
|
176
|
+
def _line(off, scl):
|
|
177
|
+
pass
|
|
178
|
+
|
|
179
|
+
@staticmethod
|
|
180
|
+
@abc.abstractmethod
|
|
181
|
+
def _roots(c):
|
|
182
|
+
pass
|
|
183
|
+
|
|
184
|
+
@staticmethod
|
|
185
|
+
@abc.abstractmethod
|
|
186
|
+
def _fromroots(r):
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
def has_samecoef(self, other):
|
|
190
|
+
"""Check if coefficients match.
|
|
191
|
+
|
|
192
|
+
Parameters
|
|
193
|
+
----------
|
|
194
|
+
other : class instance
|
|
195
|
+
The other class must have the ``coef`` attribute.
|
|
196
|
+
|
|
197
|
+
Returns
|
|
198
|
+
-------
|
|
199
|
+
bool : boolean
|
|
200
|
+
True if the coefficients are the same, False otherwise.
|
|
201
|
+
|
|
202
|
+
"""
|
|
203
|
+
return (
|
|
204
|
+
len(self.coef) == len(other.coef)
|
|
205
|
+
and np.all(self.coef == other.coef)
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
def has_samedomain(self, other):
|
|
209
|
+
"""Check if domains match.
|
|
210
|
+
|
|
211
|
+
Parameters
|
|
212
|
+
----------
|
|
213
|
+
other : class instance
|
|
214
|
+
The other class must have the ``domain`` attribute.
|
|
215
|
+
|
|
216
|
+
Returns
|
|
217
|
+
-------
|
|
218
|
+
bool : boolean
|
|
219
|
+
True if the domains are the same, False otherwise.
|
|
220
|
+
|
|
221
|
+
"""
|
|
222
|
+
return np.all(self.domain == other.domain)
|
|
223
|
+
|
|
224
|
+
def has_samewindow(self, other):
|
|
225
|
+
"""Check if windows match.
|
|
226
|
+
|
|
227
|
+
Parameters
|
|
228
|
+
----------
|
|
229
|
+
other : class instance
|
|
230
|
+
The other class must have the ``window`` attribute.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
bool : boolean
|
|
235
|
+
True if the windows are the same, False otherwise.
|
|
236
|
+
|
|
237
|
+
"""
|
|
238
|
+
return np.all(self.window == other.window)
|
|
239
|
+
|
|
240
|
+
def has_sametype(self, other):
|
|
241
|
+
"""Check if types match.
|
|
242
|
+
|
|
243
|
+
Parameters
|
|
244
|
+
----------
|
|
245
|
+
other : object
|
|
246
|
+
Class instance.
|
|
247
|
+
|
|
248
|
+
Returns
|
|
249
|
+
-------
|
|
250
|
+
bool : boolean
|
|
251
|
+
True if other is same class as self
|
|
252
|
+
|
|
253
|
+
"""
|
|
254
|
+
return isinstance(other, self.__class__)
|
|
255
|
+
|
|
256
|
+
def _get_coefficients(self, other):
|
|
257
|
+
"""Interpret other as polynomial coefficients.
|
|
258
|
+
|
|
259
|
+
The `other` argument is checked to see if it is of the same
|
|
260
|
+
class as self with identical domain and window. If so,
|
|
261
|
+
return its coefficients, otherwise return `other`.
|
|
262
|
+
|
|
263
|
+
Parameters
|
|
264
|
+
----------
|
|
265
|
+
other : anything
|
|
266
|
+
Object to be checked.
|
|
267
|
+
|
|
268
|
+
Returns
|
|
269
|
+
-------
|
|
270
|
+
coef
|
|
271
|
+
The coefficients of`other` if it is a compatible instance,
|
|
272
|
+
of ABCPolyBase, otherwise `other`.
|
|
273
|
+
|
|
274
|
+
Raises
|
|
275
|
+
------
|
|
276
|
+
TypeError
|
|
277
|
+
When `other` is an incompatible instance of ABCPolyBase.
|
|
278
|
+
|
|
279
|
+
"""
|
|
280
|
+
if isinstance(other, ABCPolyBase):
|
|
281
|
+
if not isinstance(other, self.__class__):
|
|
282
|
+
raise TypeError("Polynomial types differ")
|
|
283
|
+
elif not np.all(self.domain == other.domain):
|
|
284
|
+
raise TypeError("Domains differ")
|
|
285
|
+
elif not np.all(self.window == other.window):
|
|
286
|
+
raise TypeError("Windows differ")
|
|
287
|
+
elif self.symbol != other.symbol:
|
|
288
|
+
raise ValueError("Polynomial symbols differ")
|
|
289
|
+
return other.coef
|
|
290
|
+
return other
|
|
291
|
+
|
|
292
|
+
def __init__(self, coef, domain=None, window=None, symbol='x'):
|
|
293
|
+
[coef] = pu.as_series([coef], trim=False)
|
|
294
|
+
self.coef = coef
|
|
295
|
+
|
|
296
|
+
if domain is not None:
|
|
297
|
+
[domain] = pu.as_series([domain], trim=False)
|
|
298
|
+
if len(domain) != 2:
|
|
299
|
+
raise ValueError("Domain has wrong number of elements.")
|
|
300
|
+
self.domain = domain
|
|
301
|
+
|
|
302
|
+
if window is not None:
|
|
303
|
+
[window] = pu.as_series([window], trim=False)
|
|
304
|
+
if len(window) != 2:
|
|
305
|
+
raise ValueError("Window has wrong number of elements.")
|
|
306
|
+
self.window = window
|
|
307
|
+
|
|
308
|
+
# Validation for symbol
|
|
309
|
+
try:
|
|
310
|
+
if not symbol.isidentifier():
|
|
311
|
+
raise ValueError(
|
|
312
|
+
"Symbol string must be a valid Python identifier"
|
|
313
|
+
)
|
|
314
|
+
# If a user passes in something other than a string, the above
|
|
315
|
+
# results in an AttributeError. Catch this and raise a more
|
|
316
|
+
# informative exception
|
|
317
|
+
except AttributeError:
|
|
318
|
+
raise TypeError("Symbol must be a non-empty string")
|
|
319
|
+
|
|
320
|
+
self._symbol = symbol
|
|
321
|
+
|
|
322
|
+
def __repr__(self):
|
|
323
|
+
coef = repr(self.coef)[6:-1]
|
|
324
|
+
domain = repr(self.domain)[6:-1]
|
|
325
|
+
window = repr(self.window)[6:-1]
|
|
326
|
+
name = self.__class__.__name__
|
|
327
|
+
return (f"{name}({coef}, domain={domain}, window={window}, "
|
|
328
|
+
f"symbol='{self.symbol}')")
|
|
329
|
+
|
|
330
|
+
def __format__(self, fmt_str):
|
|
331
|
+
if fmt_str == '':
|
|
332
|
+
return self.__str__()
|
|
333
|
+
if fmt_str not in ('ascii', 'unicode'):
|
|
334
|
+
raise ValueError(
|
|
335
|
+
f"Unsupported format string '{fmt_str}' passed to "
|
|
336
|
+
f"{self.__class__}.__format__. Valid options are "
|
|
337
|
+
f"'ascii' and 'unicode'"
|
|
338
|
+
)
|
|
339
|
+
if fmt_str == 'ascii':
|
|
340
|
+
return self._generate_string(self._str_term_ascii)
|
|
341
|
+
return self._generate_string(self._str_term_unicode)
|
|
342
|
+
|
|
343
|
+
def __str__(self):
|
|
344
|
+
if self._use_unicode:
|
|
345
|
+
return self._generate_string(self._str_term_unicode)
|
|
346
|
+
return self._generate_string(self._str_term_ascii)
|
|
347
|
+
|
|
348
|
+
def _generate_string(self, term_method):
|
|
349
|
+
"""
|
|
350
|
+
Generate the full string representation of the polynomial, using
|
|
351
|
+
``term_method`` to generate each polynomial term.
|
|
352
|
+
"""
|
|
353
|
+
# Get configuration for line breaks
|
|
354
|
+
linewidth = np.get_printoptions().get('linewidth', 75)
|
|
355
|
+
if linewidth < 1:
|
|
356
|
+
linewidth = 1
|
|
357
|
+
out = pu.format_float(self.coef[0])
|
|
358
|
+
|
|
359
|
+
off, scale = self.mapparms()
|
|
360
|
+
|
|
361
|
+
scaled_symbol, needs_parens = self._format_term(pu.format_float,
|
|
362
|
+
off, scale)
|
|
363
|
+
if needs_parens:
|
|
364
|
+
scaled_symbol = '(' + scaled_symbol + ')'
|
|
365
|
+
|
|
366
|
+
for i, coef in enumerate(self.coef[1:]):
|
|
367
|
+
out += " "
|
|
368
|
+
power = str(i + 1)
|
|
369
|
+
# Polynomial coefficient
|
|
370
|
+
# The coefficient array can be an object array with elements that
|
|
371
|
+
# will raise a TypeError with >= 0 (e.g. strings or Python
|
|
372
|
+
# complex). In this case, represent the coefficient as-is.
|
|
373
|
+
try:
|
|
374
|
+
if coef >= 0:
|
|
375
|
+
next_term = "+ " + pu.format_float(coef, parens=True)
|
|
376
|
+
else:
|
|
377
|
+
next_term = "- " + pu.format_float(-coef, parens=True)
|
|
378
|
+
except TypeError:
|
|
379
|
+
next_term = f"+ {coef}"
|
|
380
|
+
# Polynomial term
|
|
381
|
+
next_term += term_method(power, scaled_symbol)
|
|
382
|
+
# Length of the current line with next term added
|
|
383
|
+
line_len = len(out.split('\n')[-1]) + len(next_term)
|
|
384
|
+
# If not the last term in the polynomial, it will be two
|
|
385
|
+
# characters longer due to the +/- with the next term
|
|
386
|
+
if i < len(self.coef[1:]) - 1:
|
|
387
|
+
line_len += 2
|
|
388
|
+
# Handle linebreaking
|
|
389
|
+
if line_len >= linewidth:
|
|
390
|
+
next_term = next_term.replace(" ", "\n", 1)
|
|
391
|
+
out += next_term
|
|
392
|
+
return out
|
|
393
|
+
|
|
394
|
+
@classmethod
|
|
395
|
+
def _str_term_unicode(cls, i, arg_str):
|
|
396
|
+
"""
|
|
397
|
+
String representation of single polynomial term using unicode
|
|
398
|
+
characters for superscripts and subscripts.
|
|
399
|
+
"""
|
|
400
|
+
if cls.basis_name is None:
|
|
401
|
+
raise NotImplementedError(
|
|
402
|
+
"Subclasses must define either a basis_name, or override "
|
|
403
|
+
"_str_term_unicode(cls, i, arg_str)"
|
|
404
|
+
)
|
|
405
|
+
return (f"·{cls.basis_name}{i.translate(cls._subscript_mapping)}"
|
|
406
|
+
f"({arg_str})")
|
|
407
|
+
|
|
408
|
+
@classmethod
|
|
409
|
+
def _str_term_ascii(cls, i, arg_str):
|
|
410
|
+
"""
|
|
411
|
+
String representation of a single polynomial term using ** and _ to
|
|
412
|
+
represent superscripts and subscripts, respectively.
|
|
413
|
+
"""
|
|
414
|
+
if cls.basis_name is None:
|
|
415
|
+
raise NotImplementedError(
|
|
416
|
+
"Subclasses must define either a basis_name, or override "
|
|
417
|
+
"_str_term_ascii(cls, i, arg_str)"
|
|
418
|
+
)
|
|
419
|
+
return f" {cls.basis_name}_{i}({arg_str})"
|
|
420
|
+
|
|
421
|
+
@classmethod
|
|
422
|
+
def _repr_latex_term(cls, i, arg_str, needs_parens):
|
|
423
|
+
if cls.basis_name is None:
|
|
424
|
+
raise NotImplementedError(
|
|
425
|
+
"Subclasses must define either a basis name, or override "
|
|
426
|
+
"_repr_latex_term(i, arg_str, needs_parens)")
|
|
427
|
+
# since we always add parens, we don't care if the expression needs them
|
|
428
|
+
return f"{{{cls.basis_name}}}_{{{i}}}({arg_str})"
|
|
429
|
+
|
|
430
|
+
@staticmethod
|
|
431
|
+
def _repr_latex_scalar(x, parens=False):
|
|
432
|
+
# TODO: we're stuck with disabling math formatting until we handle
|
|
433
|
+
# exponents in this function
|
|
434
|
+
return fr'\text{{{pu.format_float(x, parens=parens)}}}'
|
|
435
|
+
|
|
436
|
+
def _format_term(self, scalar_format: Callable, off: float, scale: float):
|
|
437
|
+
""" Format a single term in the expansion """
|
|
438
|
+
if off == 0 and scale == 1:
|
|
439
|
+
term = self.symbol
|
|
440
|
+
needs_parens = False
|
|
441
|
+
elif scale == 1:
|
|
442
|
+
term = f"{scalar_format(off)} + {self.symbol}"
|
|
443
|
+
needs_parens = True
|
|
444
|
+
elif off == 0:
|
|
445
|
+
term = f"{scalar_format(scale)}{self.symbol}"
|
|
446
|
+
needs_parens = True
|
|
447
|
+
else:
|
|
448
|
+
term = (
|
|
449
|
+
f"{scalar_format(off)} + "
|
|
450
|
+
f"{scalar_format(scale)}{self.symbol}"
|
|
451
|
+
)
|
|
452
|
+
needs_parens = True
|
|
453
|
+
return term, needs_parens
|
|
454
|
+
|
|
455
|
+
def _repr_latex_(self):
|
|
456
|
+
# get the scaled argument string to the basis functions
|
|
457
|
+
off, scale = self.mapparms()
|
|
458
|
+
term, needs_parens = self._format_term(self._repr_latex_scalar,
|
|
459
|
+
off, scale)
|
|
460
|
+
|
|
461
|
+
mute = r"\color{{LightGray}}{{{}}}".format
|
|
462
|
+
|
|
463
|
+
parts = []
|
|
464
|
+
for i, c in enumerate(self.coef):
|
|
465
|
+
# prevent duplication of + and - signs
|
|
466
|
+
if i == 0:
|
|
467
|
+
coef_str = f"{self._repr_latex_scalar(c)}"
|
|
468
|
+
elif not isinstance(c, numbers.Real):
|
|
469
|
+
coef_str = f" + ({self._repr_latex_scalar(c)})"
|
|
470
|
+
elif c >= 0:
|
|
471
|
+
coef_str = f" + {self._repr_latex_scalar(c, parens=True)}"
|
|
472
|
+
else:
|
|
473
|
+
coef_str = f" - {self._repr_latex_scalar(-c, parens=True)}"
|
|
474
|
+
|
|
475
|
+
# produce the string for the term
|
|
476
|
+
term_str = self._repr_latex_term(i, term, needs_parens)
|
|
477
|
+
if term_str == '1':
|
|
478
|
+
part = coef_str
|
|
479
|
+
else:
|
|
480
|
+
part = rf"{coef_str}\,{term_str}"
|
|
481
|
+
|
|
482
|
+
if c == 0:
|
|
483
|
+
part = mute(part)
|
|
484
|
+
|
|
485
|
+
parts.append(part)
|
|
486
|
+
|
|
487
|
+
if parts:
|
|
488
|
+
body = ''.join(parts)
|
|
489
|
+
else:
|
|
490
|
+
# in case somehow there are no coefficients at all
|
|
491
|
+
body = '0'
|
|
492
|
+
|
|
493
|
+
return rf"${self.symbol} \mapsto {body}$"
|
|
494
|
+
|
|
495
|
+
# Pickle and copy
|
|
496
|
+
|
|
497
|
+
def __getstate__(self):
|
|
498
|
+
ret = self.__dict__.copy()
|
|
499
|
+
ret['coef'] = self.coef.copy()
|
|
500
|
+
ret['domain'] = self.domain.copy()
|
|
501
|
+
ret['window'] = self.window.copy()
|
|
502
|
+
ret['symbol'] = self.symbol
|
|
503
|
+
return ret
|
|
504
|
+
|
|
505
|
+
def __setstate__(self, dict):
|
|
506
|
+
self.__dict__ = dict
|
|
507
|
+
|
|
508
|
+
# Call
|
|
509
|
+
|
|
510
|
+
def __call__(self, arg):
|
|
511
|
+
arg = pu.mapdomain(arg, self.domain, self.window)
|
|
512
|
+
return self._val(arg, self.coef)
|
|
513
|
+
|
|
514
|
+
def __iter__(self):
|
|
515
|
+
return iter(self.coef)
|
|
516
|
+
|
|
517
|
+
def __len__(self):
|
|
518
|
+
return len(self.coef)
|
|
519
|
+
|
|
520
|
+
# Numeric properties.
|
|
521
|
+
|
|
522
|
+
def __neg__(self):
|
|
523
|
+
return self.__class__(
|
|
524
|
+
-self.coef, self.domain, self.window, self.symbol
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
def __pos__(self):
|
|
528
|
+
return self
|
|
529
|
+
|
|
530
|
+
def __add__(self, other):
|
|
531
|
+
othercoef = self._get_coefficients(other)
|
|
532
|
+
try:
|
|
533
|
+
coef = self._add(self.coef, othercoef)
|
|
534
|
+
except Exception:
|
|
535
|
+
return NotImplemented
|
|
536
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
537
|
+
|
|
538
|
+
def __sub__(self, other):
|
|
539
|
+
othercoef = self._get_coefficients(other)
|
|
540
|
+
try:
|
|
541
|
+
coef = self._sub(self.coef, othercoef)
|
|
542
|
+
except Exception:
|
|
543
|
+
return NotImplemented
|
|
544
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
545
|
+
|
|
546
|
+
def __mul__(self, other):
|
|
547
|
+
othercoef = self._get_coefficients(other)
|
|
548
|
+
try:
|
|
549
|
+
coef = self._mul(self.coef, othercoef)
|
|
550
|
+
except Exception:
|
|
551
|
+
return NotImplemented
|
|
552
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
553
|
+
|
|
554
|
+
def __truediv__(self, other):
|
|
555
|
+
# there is no true divide if the rhs is not a Number, although it
|
|
556
|
+
# could return the first n elements of an infinite series.
|
|
557
|
+
# It is hard to see where n would come from, though.
|
|
558
|
+
if not isinstance(other, numbers.Number) or isinstance(other, bool):
|
|
559
|
+
raise TypeError(
|
|
560
|
+
f"unsupported types for true division: "
|
|
561
|
+
f"'{type(self)}', '{type(other)}'"
|
|
562
|
+
)
|
|
563
|
+
return self.__floordiv__(other)
|
|
564
|
+
|
|
565
|
+
def __floordiv__(self, other):
|
|
566
|
+
res = self.__divmod__(other)
|
|
567
|
+
if res is NotImplemented:
|
|
568
|
+
return res
|
|
569
|
+
return res[0]
|
|
570
|
+
|
|
571
|
+
def __mod__(self, other):
|
|
572
|
+
res = self.__divmod__(other)
|
|
573
|
+
if res is NotImplemented:
|
|
574
|
+
return res
|
|
575
|
+
return res[1]
|
|
576
|
+
|
|
577
|
+
def __divmod__(self, other):
|
|
578
|
+
othercoef = self._get_coefficients(other)
|
|
579
|
+
try:
|
|
580
|
+
quo, rem = self._div(self.coef, othercoef)
|
|
581
|
+
except ZeroDivisionError:
|
|
582
|
+
raise
|
|
583
|
+
except Exception:
|
|
584
|
+
return NotImplemented
|
|
585
|
+
quo = self.__class__(quo, self.domain, self.window, self.symbol)
|
|
586
|
+
rem = self.__class__(rem, self.domain, self.window, self.symbol)
|
|
587
|
+
return quo, rem
|
|
588
|
+
|
|
589
|
+
def __pow__(self, other):
|
|
590
|
+
coef = self._pow(self.coef, other, maxpower=self.maxpower)
|
|
591
|
+
res = self.__class__(coef, self.domain, self.window, self.symbol)
|
|
592
|
+
return res
|
|
593
|
+
|
|
594
|
+
def __radd__(self, other):
|
|
595
|
+
try:
|
|
596
|
+
coef = self._add(other, self.coef)
|
|
597
|
+
except Exception:
|
|
598
|
+
return NotImplemented
|
|
599
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
600
|
+
|
|
601
|
+
def __rsub__(self, other):
|
|
602
|
+
try:
|
|
603
|
+
coef = self._sub(other, self.coef)
|
|
604
|
+
except Exception:
|
|
605
|
+
return NotImplemented
|
|
606
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
607
|
+
|
|
608
|
+
def __rmul__(self, other):
|
|
609
|
+
try:
|
|
610
|
+
coef = self._mul(other, self.coef)
|
|
611
|
+
except Exception:
|
|
612
|
+
return NotImplemented
|
|
613
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
614
|
+
|
|
615
|
+
def __rtruediv__(self, other):
|
|
616
|
+
# An instance of ABCPolyBase is not considered a
|
|
617
|
+
# Number.
|
|
618
|
+
return NotImplemented
|
|
619
|
+
|
|
620
|
+
def __rfloordiv__(self, other):
|
|
621
|
+
res = self.__rdivmod__(other)
|
|
622
|
+
if res is NotImplemented:
|
|
623
|
+
return res
|
|
624
|
+
return res[0]
|
|
625
|
+
|
|
626
|
+
def __rmod__(self, other):
|
|
627
|
+
res = self.__rdivmod__(other)
|
|
628
|
+
if res is NotImplemented:
|
|
629
|
+
return res
|
|
630
|
+
return res[1]
|
|
631
|
+
|
|
632
|
+
def __rdivmod__(self, other):
|
|
633
|
+
try:
|
|
634
|
+
quo, rem = self._div(other, self.coef)
|
|
635
|
+
except ZeroDivisionError:
|
|
636
|
+
raise
|
|
637
|
+
except Exception:
|
|
638
|
+
return NotImplemented
|
|
639
|
+
quo = self.__class__(quo, self.domain, self.window, self.symbol)
|
|
640
|
+
rem = self.__class__(rem, self.domain, self.window, self.symbol)
|
|
641
|
+
return quo, rem
|
|
642
|
+
|
|
643
|
+
def __eq__(self, other):
|
|
644
|
+
res = (isinstance(other, self.__class__) and
|
|
645
|
+
np.all(self.domain == other.domain) and
|
|
646
|
+
np.all(self.window == other.window) and
|
|
647
|
+
(self.coef.shape == other.coef.shape) and
|
|
648
|
+
np.all(self.coef == other.coef) and
|
|
649
|
+
(self.symbol == other.symbol))
|
|
650
|
+
return res
|
|
651
|
+
|
|
652
|
+
def __ne__(self, other):
|
|
653
|
+
return not self.__eq__(other)
|
|
654
|
+
|
|
655
|
+
#
|
|
656
|
+
# Extra methods.
|
|
657
|
+
#
|
|
658
|
+
|
|
659
|
+
def copy(self):
|
|
660
|
+
"""Return a copy.
|
|
661
|
+
|
|
662
|
+
Returns
|
|
663
|
+
-------
|
|
664
|
+
new_series : series
|
|
665
|
+
Copy of self.
|
|
666
|
+
|
|
667
|
+
"""
|
|
668
|
+
return self.__class__(self.coef, self.domain, self.window, self.symbol)
|
|
669
|
+
|
|
670
|
+
def degree(self):
|
|
671
|
+
"""The degree of the series.
|
|
672
|
+
|
|
673
|
+
Returns
|
|
674
|
+
-------
|
|
675
|
+
degree : int
|
|
676
|
+
Degree of the series, one less than the number of coefficients.
|
|
677
|
+
|
|
678
|
+
Examples
|
|
679
|
+
--------
|
|
680
|
+
|
|
681
|
+
Create a polynomial object for ``1 + 7*x + 4*x**2``:
|
|
682
|
+
|
|
683
|
+
>>> np.polynomial.set_default_printstyle("unicode")
|
|
684
|
+
>>> poly = np.polynomial.Polynomial([1, 7, 4])
|
|
685
|
+
>>> print(poly)
|
|
686
|
+
1.0 + 7.0·x + 4.0·x²
|
|
687
|
+
>>> poly.degree()
|
|
688
|
+
2
|
|
689
|
+
|
|
690
|
+
Note that this method does not check for non-zero coefficients.
|
|
691
|
+
You must trim the polynomial to remove any trailing zeroes:
|
|
692
|
+
|
|
693
|
+
>>> poly = np.polynomial.Polynomial([1, 7, 0])
|
|
694
|
+
>>> print(poly)
|
|
695
|
+
1.0 + 7.0·x + 0.0·x²
|
|
696
|
+
>>> poly.degree()
|
|
697
|
+
2
|
|
698
|
+
>>> poly.trim().degree()
|
|
699
|
+
1
|
|
700
|
+
|
|
701
|
+
"""
|
|
702
|
+
return len(self) - 1
|
|
703
|
+
|
|
704
|
+
def cutdeg(self, deg):
|
|
705
|
+
"""Truncate series to the given degree.
|
|
706
|
+
|
|
707
|
+
Reduce the degree of the series to `deg` by discarding the
|
|
708
|
+
high order terms. If `deg` is greater than the current degree a
|
|
709
|
+
copy of the current series is returned. This can be useful in least
|
|
710
|
+
squares where the coefficients of the high degree terms may be very
|
|
711
|
+
small.
|
|
712
|
+
|
|
713
|
+
Parameters
|
|
714
|
+
----------
|
|
715
|
+
deg : non-negative int
|
|
716
|
+
The series is reduced to degree `deg` by discarding the high
|
|
717
|
+
order terms. The value of `deg` must be a non-negative integer.
|
|
718
|
+
|
|
719
|
+
Returns
|
|
720
|
+
-------
|
|
721
|
+
new_series : series
|
|
722
|
+
New instance of series with reduced degree.
|
|
723
|
+
|
|
724
|
+
"""
|
|
725
|
+
return self.truncate(deg + 1)
|
|
726
|
+
|
|
727
|
+
def trim(self, tol=0):
|
|
728
|
+
"""Remove trailing coefficients
|
|
729
|
+
|
|
730
|
+
Remove trailing coefficients until a coefficient is reached whose
|
|
731
|
+
absolute value greater than `tol` or the beginning of the series is
|
|
732
|
+
reached. If all the coefficients would be removed the series is set
|
|
733
|
+
to ``[0]``. A new series instance is returned with the new
|
|
734
|
+
coefficients. The current instance remains unchanged.
|
|
735
|
+
|
|
736
|
+
Parameters
|
|
737
|
+
----------
|
|
738
|
+
tol : non-negative number.
|
|
739
|
+
All trailing coefficients less than `tol` will be removed.
|
|
740
|
+
|
|
741
|
+
Returns
|
|
742
|
+
-------
|
|
743
|
+
new_series : series
|
|
744
|
+
New instance of series with trimmed coefficients.
|
|
745
|
+
|
|
746
|
+
"""
|
|
747
|
+
coef = pu.trimcoef(self.coef, tol)
|
|
748
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
749
|
+
|
|
750
|
+
def truncate(self, size):
|
|
751
|
+
"""Truncate series to length `size`.
|
|
752
|
+
|
|
753
|
+
Reduce the series to length `size` by discarding the high
|
|
754
|
+
degree terms. The value of `size` must be a positive integer. This
|
|
755
|
+
can be useful in least squares where the coefficients of the
|
|
756
|
+
high degree terms may be very small.
|
|
757
|
+
|
|
758
|
+
Parameters
|
|
759
|
+
----------
|
|
760
|
+
size : positive int
|
|
761
|
+
The series is reduced to length `size` by discarding the high
|
|
762
|
+
degree terms. The value of `size` must be a positive integer.
|
|
763
|
+
|
|
764
|
+
Returns
|
|
765
|
+
-------
|
|
766
|
+
new_series : series
|
|
767
|
+
New instance of series with truncated coefficients.
|
|
768
|
+
|
|
769
|
+
"""
|
|
770
|
+
isize = int(size)
|
|
771
|
+
if isize != size or isize < 1:
|
|
772
|
+
raise ValueError("size must be a positive integer")
|
|
773
|
+
if isize >= len(self.coef):
|
|
774
|
+
coef = self.coef
|
|
775
|
+
else:
|
|
776
|
+
coef = self.coef[:isize]
|
|
777
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
778
|
+
|
|
779
|
+
def convert(self, domain=None, kind=None, window=None):
|
|
780
|
+
"""Convert series to a different kind and/or domain and/or window.
|
|
781
|
+
|
|
782
|
+
Parameters
|
|
783
|
+
----------
|
|
784
|
+
domain : array_like, optional
|
|
785
|
+
The domain of the converted series. If the value is None,
|
|
786
|
+
the default domain of `kind` is used.
|
|
787
|
+
kind : class, optional
|
|
788
|
+
The polynomial series type class to which the current instance
|
|
789
|
+
should be converted. If kind is None, then the class of the
|
|
790
|
+
current instance is used.
|
|
791
|
+
window : array_like, optional
|
|
792
|
+
The window of the converted series. If the value is None,
|
|
793
|
+
the default window of `kind` is used.
|
|
794
|
+
|
|
795
|
+
Returns
|
|
796
|
+
-------
|
|
797
|
+
new_series : series
|
|
798
|
+
The returned class can be of different type than the current
|
|
799
|
+
instance and/or have a different domain and/or different
|
|
800
|
+
window.
|
|
801
|
+
|
|
802
|
+
Notes
|
|
803
|
+
-----
|
|
804
|
+
Conversion between domains and class types can result in
|
|
805
|
+
numerically ill defined series.
|
|
806
|
+
|
|
807
|
+
"""
|
|
808
|
+
if kind is None:
|
|
809
|
+
kind = self.__class__
|
|
810
|
+
if domain is None:
|
|
811
|
+
domain = kind.domain
|
|
812
|
+
if window is None:
|
|
813
|
+
window = kind.window
|
|
814
|
+
return self(kind.identity(domain, window=window, symbol=self.symbol))
|
|
815
|
+
|
|
816
|
+
def mapparms(self):
|
|
817
|
+
"""Return the mapping parameters.
|
|
818
|
+
|
|
819
|
+
The returned values define a linear map ``off + scl*x`` that is
|
|
820
|
+
applied to the input arguments before the series is evaluated. The
|
|
821
|
+
map depends on the ``domain`` and ``window``; if the current
|
|
822
|
+
``domain`` is equal to the ``window`` the resulting map is the
|
|
823
|
+
identity. If the coefficients of the series instance are to be
|
|
824
|
+
used by themselves outside this class, then the linear function
|
|
825
|
+
must be substituted for the ``x`` in the standard representation of
|
|
826
|
+
the base polynomials.
|
|
827
|
+
|
|
828
|
+
Returns
|
|
829
|
+
-------
|
|
830
|
+
off, scl : float or complex
|
|
831
|
+
The mapping function is defined by ``off + scl*x``.
|
|
832
|
+
|
|
833
|
+
Notes
|
|
834
|
+
-----
|
|
835
|
+
If the current domain is the interval ``[l1, r1]`` and the window
|
|
836
|
+
is ``[l2, r2]``, then the linear mapping function ``L`` is
|
|
837
|
+
defined by the equations::
|
|
838
|
+
|
|
839
|
+
L(l1) = l2
|
|
840
|
+
L(r1) = r2
|
|
841
|
+
|
|
842
|
+
"""
|
|
843
|
+
return pu.mapparms(self.domain, self.window)
|
|
844
|
+
|
|
845
|
+
def integ(self, m=1, k=[], lbnd=None):
|
|
846
|
+
"""Integrate.
|
|
847
|
+
|
|
848
|
+
Return a series instance that is the definite integral of the
|
|
849
|
+
current series.
|
|
850
|
+
|
|
851
|
+
Parameters
|
|
852
|
+
----------
|
|
853
|
+
m : non-negative int
|
|
854
|
+
The number of integrations to perform.
|
|
855
|
+
k : array_like
|
|
856
|
+
Integration constants. The first constant is applied to the
|
|
857
|
+
first integration, the second to the second, and so on. The
|
|
858
|
+
list of values must less than or equal to `m` in length and any
|
|
859
|
+
missing values are set to zero.
|
|
860
|
+
lbnd : Scalar
|
|
861
|
+
The lower bound of the definite integral.
|
|
862
|
+
|
|
863
|
+
Returns
|
|
864
|
+
-------
|
|
865
|
+
new_series : series
|
|
866
|
+
A new series representing the integral. The domain is the same
|
|
867
|
+
as the domain of the integrated series.
|
|
868
|
+
|
|
869
|
+
"""
|
|
870
|
+
off, scl = self.mapparms()
|
|
871
|
+
if lbnd is None:
|
|
872
|
+
lbnd = 0
|
|
873
|
+
else:
|
|
874
|
+
lbnd = off + scl * lbnd
|
|
875
|
+
coef = self._int(self.coef, m, k, lbnd, 1. / scl)
|
|
876
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
877
|
+
|
|
878
|
+
def deriv(self, m=1):
|
|
879
|
+
"""Differentiate.
|
|
880
|
+
|
|
881
|
+
Return a series instance of that is the derivative of the current
|
|
882
|
+
series.
|
|
883
|
+
|
|
884
|
+
Parameters
|
|
885
|
+
----------
|
|
886
|
+
m : non-negative int
|
|
887
|
+
Find the derivative of order `m`.
|
|
888
|
+
|
|
889
|
+
Returns
|
|
890
|
+
-------
|
|
891
|
+
new_series : series
|
|
892
|
+
A new series representing the derivative. The domain is the same
|
|
893
|
+
as the domain of the differentiated series.
|
|
894
|
+
|
|
895
|
+
"""
|
|
896
|
+
off, scl = self.mapparms()
|
|
897
|
+
coef = self._der(self.coef, m, scl)
|
|
898
|
+
return self.__class__(coef, self.domain, self.window, self.symbol)
|
|
899
|
+
|
|
900
|
+
def roots(self):
|
|
901
|
+
"""Return the roots of the series polynomial.
|
|
902
|
+
|
|
903
|
+
Compute the roots for the series. Note that the accuracy of the
|
|
904
|
+
roots decreases the further outside the `domain` they lie.
|
|
905
|
+
|
|
906
|
+
Returns
|
|
907
|
+
-------
|
|
908
|
+
roots : ndarray
|
|
909
|
+
Array containing the roots of the series.
|
|
910
|
+
|
|
911
|
+
"""
|
|
912
|
+
roots = self._roots(self.coef)
|
|
913
|
+
return pu.mapdomain(roots, self.window, self.domain)
|
|
914
|
+
|
|
915
|
+
def linspace(self, n=100, domain=None):
|
|
916
|
+
"""Return x, y values at equally spaced points in domain.
|
|
917
|
+
|
|
918
|
+
Returns the x, y values at `n` linearly spaced points across the
|
|
919
|
+
domain. Here y is the value of the polynomial at the points x. By
|
|
920
|
+
default the domain is the same as that of the series instance.
|
|
921
|
+
This method is intended mostly as a plotting aid.
|
|
922
|
+
|
|
923
|
+
Parameters
|
|
924
|
+
----------
|
|
925
|
+
n : int, optional
|
|
926
|
+
Number of point pairs to return. The default value is 100.
|
|
927
|
+
domain : {None, array_like}, optional
|
|
928
|
+
If not None, the specified domain is used instead of that of
|
|
929
|
+
the calling instance. It should be of the form ``[beg,end]``.
|
|
930
|
+
The default is None which case the class domain is used.
|
|
931
|
+
|
|
932
|
+
Returns
|
|
933
|
+
-------
|
|
934
|
+
x, y : ndarray
|
|
935
|
+
x is equal to linspace(self.domain[0], self.domain[1], n) and
|
|
936
|
+
y is the series evaluated at element of x.
|
|
937
|
+
|
|
938
|
+
"""
|
|
939
|
+
if domain is None:
|
|
940
|
+
domain = self.domain
|
|
941
|
+
x = np.linspace(domain[0], domain[1], n)
|
|
942
|
+
y = self(x)
|
|
943
|
+
return x, y
|
|
944
|
+
|
|
945
|
+
@classmethod
|
|
946
|
+
def fit(cls, x, y, deg, domain=None, rcond=None, full=False, w=None,
|
|
947
|
+
window=None, symbol='x'):
|
|
948
|
+
"""Least squares fit to data.
|
|
949
|
+
|
|
950
|
+
Return a series instance that is the least squares fit to the data
|
|
951
|
+
`y` sampled at `x`. The domain of the returned instance can be
|
|
952
|
+
specified and this will often result in a superior fit with less
|
|
953
|
+
chance of ill conditioning.
|
|
954
|
+
|
|
955
|
+
Parameters
|
|
956
|
+
----------
|
|
957
|
+
x : array_like, shape (M,)
|
|
958
|
+
x-coordinates of the M sample points ``(x[i], y[i])``.
|
|
959
|
+
y : array_like, shape (M,)
|
|
960
|
+
y-coordinates of the M sample points ``(x[i], y[i])``.
|
|
961
|
+
deg : int or 1-D array_like
|
|
962
|
+
Degree(s) of the fitting polynomials. If `deg` is a single integer
|
|
963
|
+
all terms up to and including the `deg`'th term are included in the
|
|
964
|
+
fit. For NumPy versions >= 1.11.0 a list of integers specifying the
|
|
965
|
+
degrees of the terms to include may be used instead.
|
|
966
|
+
domain : {None, [beg, end], []}, optional
|
|
967
|
+
Domain to use for the returned series. If ``None``,
|
|
968
|
+
then a minimal domain that covers the points `x` is chosen. If
|
|
969
|
+
``[]`` the class domain is used. The default value was the
|
|
970
|
+
class domain in NumPy 1.4 and ``None`` in later versions.
|
|
971
|
+
The ``[]`` option was added in numpy 1.5.0.
|
|
972
|
+
rcond : float, optional
|
|
973
|
+
Relative condition number of the fit. Singular values smaller
|
|
974
|
+
than this relative to the largest singular value will be
|
|
975
|
+
ignored. The default value is ``len(x)*eps``, where eps is the
|
|
976
|
+
relative precision of the float type, about 2e-16 in most
|
|
977
|
+
cases.
|
|
978
|
+
full : bool, optional
|
|
979
|
+
Switch determining nature of return value. When it is False
|
|
980
|
+
(the default) just the coefficients are returned, when True
|
|
981
|
+
diagnostic information from the singular value decomposition is
|
|
982
|
+
also returned.
|
|
983
|
+
w : array_like, shape (M,), optional
|
|
984
|
+
Weights. If not None, the weight ``w[i]`` applies to the unsquared
|
|
985
|
+
residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are
|
|
986
|
+
chosen so that the errors of the products ``w[i]*y[i]`` all have
|
|
987
|
+
the same variance. When using inverse-variance weighting, use
|
|
988
|
+
``w[i] = 1/sigma(y[i])``. The default value is None.
|
|
989
|
+
window : {[beg, end]}, optional
|
|
990
|
+
Window to use for the returned series. The default
|
|
991
|
+
value is the default class domain
|
|
992
|
+
symbol : str, optional
|
|
993
|
+
Symbol representing the independent variable. Default is 'x'.
|
|
994
|
+
|
|
995
|
+
Returns
|
|
996
|
+
-------
|
|
997
|
+
new_series : series
|
|
998
|
+
A series that represents the least squares fit to the data and
|
|
999
|
+
has the domain and window specified in the call. If the
|
|
1000
|
+
coefficients for the unscaled and unshifted basis polynomials are
|
|
1001
|
+
of interest, do ``new_series.convert().coef``.
|
|
1002
|
+
|
|
1003
|
+
[resid, rank, sv, rcond] : list
|
|
1004
|
+
These values are only returned if ``full == True``
|
|
1005
|
+
|
|
1006
|
+
- resid -- sum of squared residuals of the least squares fit
|
|
1007
|
+
- rank -- the numerical rank of the scaled Vandermonde matrix
|
|
1008
|
+
- sv -- singular values of the scaled Vandermonde matrix
|
|
1009
|
+
- rcond -- value of `rcond`.
|
|
1010
|
+
|
|
1011
|
+
For more details, see `linalg.lstsq`.
|
|
1012
|
+
|
|
1013
|
+
"""
|
|
1014
|
+
if domain is None:
|
|
1015
|
+
domain = pu.getdomain(x)
|
|
1016
|
+
if domain[0] == domain[1]:
|
|
1017
|
+
domain[0] -= 1
|
|
1018
|
+
domain[1] += 1
|
|
1019
|
+
elif isinstance(domain, list) and len(domain) == 0:
|
|
1020
|
+
domain = cls.domain
|
|
1021
|
+
|
|
1022
|
+
if window is None:
|
|
1023
|
+
window = cls.window
|
|
1024
|
+
|
|
1025
|
+
xnew = pu.mapdomain(x, domain, window)
|
|
1026
|
+
res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full)
|
|
1027
|
+
if full:
|
|
1028
|
+
[coef, status] = res
|
|
1029
|
+
return (
|
|
1030
|
+
cls(coef, domain=domain, window=window, symbol=symbol), status
|
|
1031
|
+
)
|
|
1032
|
+
else:
|
|
1033
|
+
coef = res
|
|
1034
|
+
return cls(coef, domain=domain, window=window, symbol=symbol)
|
|
1035
|
+
|
|
1036
|
+
@classmethod
|
|
1037
|
+
def fromroots(cls, roots, domain=[], window=None, symbol='x'):
|
|
1038
|
+
"""Return series instance that has the specified roots.
|
|
1039
|
+
|
|
1040
|
+
Returns a series representing the product
|
|
1041
|
+
``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a
|
|
1042
|
+
list of roots.
|
|
1043
|
+
|
|
1044
|
+
Parameters
|
|
1045
|
+
----------
|
|
1046
|
+
roots : array_like
|
|
1047
|
+
List of roots.
|
|
1048
|
+
domain : {[], None, array_like}, optional
|
|
1049
|
+
Domain for the resulting series. If None the domain is the
|
|
1050
|
+
interval from the smallest root to the largest. If [] the
|
|
1051
|
+
domain is the class domain. The default is [].
|
|
1052
|
+
window : {None, array_like}, optional
|
|
1053
|
+
Window for the returned series. If None the class window is
|
|
1054
|
+
used. The default is None.
|
|
1055
|
+
symbol : str, optional
|
|
1056
|
+
Symbol representing the independent variable. Default is 'x'.
|
|
1057
|
+
|
|
1058
|
+
Returns
|
|
1059
|
+
-------
|
|
1060
|
+
new_series : series
|
|
1061
|
+
Series with the specified roots.
|
|
1062
|
+
|
|
1063
|
+
"""
|
|
1064
|
+
[roots] = pu.as_series([roots], trim=False)
|
|
1065
|
+
if domain is None:
|
|
1066
|
+
domain = pu.getdomain(roots)
|
|
1067
|
+
elif isinstance(domain, list) and len(domain) == 0:
|
|
1068
|
+
domain = cls.domain
|
|
1069
|
+
|
|
1070
|
+
if window is None:
|
|
1071
|
+
window = cls.window
|
|
1072
|
+
|
|
1073
|
+
deg = len(roots)
|
|
1074
|
+
off, scl = pu.mapparms(domain, window)
|
|
1075
|
+
rnew = off + scl * roots
|
|
1076
|
+
coef = cls._fromroots(rnew) / scl**deg
|
|
1077
|
+
return cls(coef, domain=domain, window=window, symbol=symbol)
|
|
1078
|
+
|
|
1079
|
+
@classmethod
|
|
1080
|
+
def identity(cls, domain=None, window=None, symbol='x'):
|
|
1081
|
+
"""Identity function.
|
|
1082
|
+
|
|
1083
|
+
If ``p`` is the returned series, then ``p(x) == x`` for all
|
|
1084
|
+
values of x.
|
|
1085
|
+
|
|
1086
|
+
Parameters
|
|
1087
|
+
----------
|
|
1088
|
+
domain : {None, array_like}, optional
|
|
1089
|
+
If given, the array must be of the form ``[beg, end]``, where
|
|
1090
|
+
``beg`` and ``end`` are the endpoints of the domain. If None is
|
|
1091
|
+
given then the class domain is used. The default is None.
|
|
1092
|
+
window : {None, array_like}, optional
|
|
1093
|
+
If given, the resulting array must be if the form
|
|
1094
|
+
``[beg, end]``, where ``beg`` and ``end`` are the endpoints of
|
|
1095
|
+
the window. If None is given then the class window is used. The
|
|
1096
|
+
default is None.
|
|
1097
|
+
symbol : str, optional
|
|
1098
|
+
Symbol representing the independent variable. Default is 'x'.
|
|
1099
|
+
|
|
1100
|
+
Returns
|
|
1101
|
+
-------
|
|
1102
|
+
new_series : series
|
|
1103
|
+
Series of representing the identity.
|
|
1104
|
+
|
|
1105
|
+
"""
|
|
1106
|
+
if domain is None:
|
|
1107
|
+
domain = cls.domain
|
|
1108
|
+
if window is None:
|
|
1109
|
+
window = cls.window
|
|
1110
|
+
off, scl = pu.mapparms(window, domain)
|
|
1111
|
+
coef = cls._line(off, scl)
|
|
1112
|
+
return cls(coef, domain, window, symbol)
|
|
1113
|
+
|
|
1114
|
+
@classmethod
|
|
1115
|
+
def basis(cls, deg, domain=None, window=None, symbol='x'):
|
|
1116
|
+
"""Series basis polynomial of degree `deg`.
|
|
1117
|
+
|
|
1118
|
+
Returns the series representing the basis polynomial of degree `deg`.
|
|
1119
|
+
|
|
1120
|
+
Parameters
|
|
1121
|
+
----------
|
|
1122
|
+
deg : int
|
|
1123
|
+
Degree of the basis polynomial for the series. Must be >= 0.
|
|
1124
|
+
domain : {None, array_like}, optional
|
|
1125
|
+
If given, the array must be of the form ``[beg, end]``, where
|
|
1126
|
+
``beg`` and ``end`` are the endpoints of the domain. If None is
|
|
1127
|
+
given then the class domain is used. The default is None.
|
|
1128
|
+
window : {None, array_like}, optional
|
|
1129
|
+
If given, the resulting array must be if the form
|
|
1130
|
+
``[beg, end]``, where ``beg`` and ``end`` are the endpoints of
|
|
1131
|
+
the window. If None is given then the class window is used. The
|
|
1132
|
+
default is None.
|
|
1133
|
+
symbol : str, optional
|
|
1134
|
+
Symbol representing the independent variable. Default is 'x'.
|
|
1135
|
+
|
|
1136
|
+
Returns
|
|
1137
|
+
-------
|
|
1138
|
+
new_series : series
|
|
1139
|
+
A series with the coefficient of the `deg` term set to one and
|
|
1140
|
+
all others zero.
|
|
1141
|
+
|
|
1142
|
+
"""
|
|
1143
|
+
if domain is None:
|
|
1144
|
+
domain = cls.domain
|
|
1145
|
+
if window is None:
|
|
1146
|
+
window = cls.window
|
|
1147
|
+
ideg = int(deg)
|
|
1148
|
+
|
|
1149
|
+
if ideg != deg or ideg < 0:
|
|
1150
|
+
raise ValueError("deg must be non-negative integer")
|
|
1151
|
+
return cls([0] * ideg + [1], domain, window, symbol)
|
|
1152
|
+
|
|
1153
|
+
@classmethod
|
|
1154
|
+
def cast(cls, series, domain=None, window=None):
|
|
1155
|
+
"""Convert series to series of this class.
|
|
1156
|
+
|
|
1157
|
+
The `series` is expected to be an instance of some polynomial
|
|
1158
|
+
series of one of the types supported by by the numpy.polynomial
|
|
1159
|
+
module, but could be some other class that supports the convert
|
|
1160
|
+
method.
|
|
1161
|
+
|
|
1162
|
+
Parameters
|
|
1163
|
+
----------
|
|
1164
|
+
series : series
|
|
1165
|
+
The series instance to be converted.
|
|
1166
|
+
domain : {None, array_like}, optional
|
|
1167
|
+
If given, the array must be of the form ``[beg, end]``, where
|
|
1168
|
+
``beg`` and ``end`` are the endpoints of the domain. If None is
|
|
1169
|
+
given then the class domain is used. The default is None.
|
|
1170
|
+
window : {None, array_like}, optional
|
|
1171
|
+
If given, the resulting array must be if the form
|
|
1172
|
+
``[beg, end]``, where ``beg`` and ``end`` are the endpoints of
|
|
1173
|
+
the window. If None is given then the class window is used. The
|
|
1174
|
+
default is None.
|
|
1175
|
+
|
|
1176
|
+
Returns
|
|
1177
|
+
-------
|
|
1178
|
+
new_series : series
|
|
1179
|
+
A series of the same kind as the calling class and equal to
|
|
1180
|
+
`series` when evaluated.
|
|
1181
|
+
|
|
1182
|
+
See Also
|
|
1183
|
+
--------
|
|
1184
|
+
convert : similar instance method
|
|
1185
|
+
|
|
1186
|
+
"""
|
|
1187
|
+
if domain is None:
|
|
1188
|
+
domain = cls.domain
|
|
1189
|
+
if window is None:
|
|
1190
|
+
window = cls.window
|
|
1191
|
+
return series.convert(domain, cls, window)
|