diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/__init__.pyi | 2 | ||||
| -rw-r--r-- | numpy/_pytesttester.pyi | 18 | ||||
| -rw-r--r-- | numpy/core/_add_newdocs.py | 28 | ||||
| -rw-r--r-- | numpy/distutils/misc_util.py | 82 | ||||
| -rw-r--r-- | numpy/f2py/__init__.pyi | 3 | ||||
| -rw-r--r-- | numpy/fft/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/lib/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/lib/npyio.py | 6 | ||||
| -rw-r--r-- | numpy/linalg/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/ma/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/matrixlib/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/polynomial/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/random/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/testing/__init__.pyi | 4 | ||||
| -rw-r--r-- | numpy/typing/__init__.py | 1 | ||||
| -rw-r--r-- | numpy/typing/tests/data/reveal/modules.py | 2 |
16 files changed, 103 insertions, 71 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 95666d7ec..5cef4639b 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -9,6 +9,7 @@ from abc import abstractmethod from types import TracebackType, MappingProxyType from contextlib import ContextDecorator +from numpy._pytesttester import PytestTester from numpy.core.multiarray import flagsobj from numpy.core._internal import _ctypes from numpy.core.getlimits import MachArLike @@ -626,6 +627,7 @@ __all__: List[str] __path__: List[str] __version__: str __git_version__: str +test: PytestTester # TODO: Move placeholders to their respective module once # their annotations are properly implemented diff --git a/numpy/_pytesttester.pyi b/numpy/_pytesttester.pyi new file mode 100644 index 000000000..693f4128a --- /dev/null +++ b/numpy/_pytesttester.pyi @@ -0,0 +1,18 @@ +from typing import List, Iterable +from typing_extensions import Literal as L + +__all__: List[str] + +class PytestTester: + module_name: str + def __init__(self, module_name: str) -> None: ... + def __call__( + self, + label: L["fast", "full"] = ..., + verbose: int = ..., + extra_argv: None | Iterable[str] = ..., + doctests: L[False] = ..., + coverage: bool = ..., + durations: int = ..., + tests: None | Iterable[str] = ..., + ) -> bool: ... diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 4dab9006d..759a91d27 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -3227,33 +3227,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal', """)) -add_newdoc('numpy.core.multiarray', 'ndarray', ('dot', - """ - a.dot(b, out=None) - - Dot product of two arrays. - - Refer to `numpy.dot` for full documentation. - - See Also - -------- - numpy.dot : equivalent function - - Examples - -------- - >>> a = np.eye(2) - >>> b = np.ones((2, 2)) * 2 - >>> a.dot(b) - array([[2., 2.], - [2., 2.]]) - - This array method can be conveniently chained: - - >>> a.dot(b).dot(b) - array([[8., 8.], - [8., 8.]]) - - """)) +add_newdoc('numpy.core.multiarray', 'ndarray', ('dot')) add_newdoc('numpy.core.multiarray', 'ndarray', ('dump', diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index dcf7cdb92..9c65ff43e 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -2376,47 +2376,47 @@ def generate_config_py(target): Notes ----- - Classes specifying the information to be printed are defined - in the `numpy.distutils.system_info` module. - - Information may include: - - * ``language``: language used to write the libraries (mostly - C or f77) - * ``libraries``: names of libraries found in the system - * ``library_dirs``: directories containing the libraries - * ``include_dirs``: directories containing library header files - * ``src_dirs``: directories containing library source files - * ``define_macros``: preprocessor macros used by - ``distutils.setup`` - * ``baseline``: minimum CPU features required - * ``found``: dispatched features supported in the system - * ``not found``: dispatched features that are not supported - in the system - - NumPy BLAS/LAPACK Installation Notes - ------------------------------------ - Installing a numpy wheel (``pip install numpy`` or force it - via ``pip install numpy --only-binary :numpy: numpy``) includes - an OpenBLAS implementation of the BLAS and LAPACK linear algebra - APIs. In this case, ``library_dirs`` reports the original build - time configuration as compiled with gcc/gfortran; at run time - the OpenBLAS library is in - ``site-packages/numpy.libs/`` (linux), or - ``site-packages/numpy/.dylibs/`` (macOS), or - ``site-packages/numpy/.libs/`` (windows). - - Installing numpy from source - (``pip install numpy --no-binary numpy``) searches for BLAS and - LAPACK dynamic link libraries at build time as influenced by - environment variables NPY_BLAS_LIBS, NPY_CBLAS_LIBS, and - NPY_LAPACK_LIBS; or NPY_BLAS_ORDER and NPY_LAPACK_ORDER; - or the optional file ``~/.numpy-site.cfg``. - NumPy remembers those locations and expects to load the same - libraries at run-time. - In NumPy 1.21+ on macOS, 'accelerate' (Apple's Accelerate BLAS - library) is in the default build-time search order after - 'openblas'. + 1. Classes specifying the information to be printed are defined + in the `numpy.distutils.system_info` module. + + Information may include: + + * ``language``: language used to write the libraries (mostly + C or f77) + * ``libraries``: names of libraries found in the system + * ``library_dirs``: directories containing the libraries + * ``include_dirs``: directories containing library header files + * ``src_dirs``: directories containing library source files + * ``define_macros``: preprocessor macros used by + ``distutils.setup`` + * ``baseline``: minimum CPU features required + * ``found``: dispatched features supported in the system + * ``not found``: dispatched features that are not supported + in the system + + 2. NumPy BLAS/LAPACK Installation Notes + + Installing a numpy wheel (``pip install numpy`` or force it + via ``pip install numpy --only-binary :numpy: numpy``) includes + an OpenBLAS implementation of the BLAS and LAPACK linear algebra + APIs. In this case, ``library_dirs`` reports the original build + time configuration as compiled with gcc/gfortran; at run time + the OpenBLAS library is in + ``site-packages/numpy.libs/`` (linux), or + ``site-packages/numpy/.dylibs/`` (macOS), or + ``site-packages/numpy/.libs/`` (windows). + + Installing numpy from source + (``pip install numpy --no-binary numpy``) searches for BLAS and + LAPACK dynamic link libraries at build time as influenced by + environment variables NPY_BLAS_LIBS, NPY_CBLAS_LIBS, and + NPY_LAPACK_LIBS; or NPY_BLAS_ORDER and NPY_LAPACK_ORDER; + or the optional file ``~/.numpy-site.cfg``. + NumPy remembers those locations and expects to load the same + libraries at run-time. + In NumPy 1.21+ on macOS, 'accelerate' (Apple's Accelerate BLAS + library) is in the default build-time search order after + 'openblas'. Examples -------- diff --git a/numpy/f2py/__init__.pyi b/numpy/f2py/__init__.pyi index b612ce15d..7d8e092ea 100644 --- a/numpy/f2py/__init__.pyi +++ b/numpy/f2py/__init__.pyi @@ -3,6 +3,8 @@ import subprocess from typing import Any, List, Iterable, Dict, overload from typing_extensions import TypedDict, Literal as L +from numpy._pytesttester import PytestTester + class _F2PyDictBase(TypedDict): csrc: List[str] h: List[str] @@ -13,6 +15,7 @@ class _F2PyDict(_F2PyDictBase, total=False): __all__: List[str] __path__: List[str] +test: PytestTester def run_main(comline_list: Iterable[str]) -> Dict[str, _F2PyDict]: ... diff --git a/numpy/fft/__init__.pyi b/numpy/fft/__init__.pyi index 3c191a35f..648b0bf79 100644 --- a/numpy/fft/__init__.pyi +++ b/numpy/fft/__init__.pyi @@ -1,6 +1,10 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + __all__: List[str] +__path__: List[str] +test: PytestTester def fft(a, n=..., axis=..., norm=...): ... def ifft(a, n=..., axis=..., norm=...): ... diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi index bb5224247..25640ec07 100644 --- a/numpy/lib/__init__.pyi +++ b/numpy/lib/__init__.pyi @@ -1,6 +1,8 @@ import math as math from typing import Any, List +from numpy._pytesttester import PytestTester + from numpy import ( ndenumerate as ndenumerate, ndindex as ndindex, @@ -237,6 +239,8 @@ from numpy.core.multiarray import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester __version__ = version emath = scimath diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index c4d625bd3..d12482cb7 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -581,9 +581,9 @@ def savez(file, *args, **kwds): its list of arrays (with the ``.files`` attribute), and for the arrays themselves. - When saving dictionaries, the dictionary keys become filenames - inside the ZIP archive. Therefore, keys should be valid filenames. - E.g., avoid keys that begin with ``/`` or contain ``.``. + Keys passed in `kwds` are used as filenames inside the ZIP archive. + Therefore, keys should be valid filenames; e.g., avoid keys that begin with + ``/`` or contain ``.``. When naming variables with keyword arguments, it is not possible to name a variable ``file``, as this would cause the ``file`` argument to be defined diff --git a/numpy/linalg/__init__.pyi b/numpy/linalg/__init__.pyi index 00db05079..7237d865d 100644 --- a/numpy/linalg/__init__.pyi +++ b/numpy/linalg/__init__.pyi @@ -1,6 +1,10 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + __all__: List[str] +__path__: List[str] +test: PytestTester class LinAlgError(Exception): ... diff --git a/numpy/ma/__init__.pyi b/numpy/ma/__init__.pyi index a9a833e52..26d44b508 100644 --- a/numpy/ma/__init__.pyi +++ b/numpy/ma/__init__.pyi @@ -1,5 +1,7 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + from numpy.ma import extras as extras from numpy.ma.core import ( @@ -230,3 +232,5 @@ from numpy.ma.extras import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester diff --git a/numpy/matrixlib/__init__.pyi b/numpy/matrixlib/__init__.pyi index e4b5c19a2..26453f000 100644 --- a/numpy/matrixlib/__init__.pyi +++ b/numpy/matrixlib/__init__.pyi @@ -1,10 +1,14 @@ from typing import Any, List +from numpy._pytesttester import PytestTester + from numpy import ( matrix as matrix, ) __all__: List[str] +__path__: List[str] +test: PytestTester def bmat(obj, ldict=..., gdict=...): ... def asmatrix(data, dtype=...): ... diff --git a/numpy/polynomial/__init__.pyi b/numpy/polynomial/__init__.pyi index bebedb3a6..e0cfedd7a 100644 --- a/numpy/polynomial/__init__.pyi +++ b/numpy/polynomial/__init__.pyi @@ -1,5 +1,7 @@ from typing import List +from numpy._pytesttester import PytestTester + from numpy.polynomial import ( chebyshev as chebyshev, hermite as hermite, @@ -16,5 +18,7 @@ from numpy.polynomial.legendre import Legendre as Legendre from numpy.polynomial.polynomial import Polynomial as Polynomial __all__: List[str] +__path__: List[str] +test: PytestTester def set_default_printstyle(style): ... diff --git a/numpy/random/__init__.pyi b/numpy/random/__init__.pyi index 48b620c48..bf6147697 100644 --- a/numpy/random/__init__.pyi +++ b/numpy/random/__init__.pyi @@ -1,5 +1,7 @@ from typing import List +from numpy._pytesttester import PytestTester + from numpy.random._generator import Generator as Generator from numpy.random._generator import default_rng as default_rng from numpy.random._mt19937 import MT19937 as MT19937 @@ -66,3 +68,5 @@ from numpy.random.mtrand import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester diff --git a/numpy/testing/__init__.pyi b/numpy/testing/__init__.pyi index 9eaba3deb..def0f9f58 100644 --- a/numpy/testing/__init__.pyi +++ b/numpy/testing/__init__.pyi @@ -1,5 +1,7 @@ from typing import List +from numpy._pytesttester import PytestTester + from unittest import ( TestCase as TestCase, ) @@ -47,6 +49,8 @@ from numpy.testing._private.utils import ( ) __all__: List[str] +__path__: List[str] +test: PytestTester def run_module_suite( file_to_run: None | str = ..., diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py index 05efe61df..d731f00ef 100644 --- a/numpy/typing/__init__.py +++ b/numpy/typing/__init__.py @@ -172,6 +172,7 @@ else: # Declare to mypy that `__all__` is a list of strings without assigning # an explicit value __all__: List[str] + __path__: List[str] @final # Dissallow the creation of arbitrary `NBitBase` subclasses diff --git a/numpy/typing/tests/data/reveal/modules.py b/numpy/typing/tests/data/reveal/modules.py index b045585b2..7e695433e 100644 --- a/numpy/typing/tests/data/reveal/modules.py +++ b/numpy/typing/tests/data/reveal/modules.py @@ -32,6 +32,8 @@ reveal_type(np.polynomial.polynomial) # E: ModuleType reveal_type(np.__path__) # E: list[builtins.str] reveal_type(np.__version__) # E: str reveal_type(np.__git_version__) # E: str +reveal_type(np.test) # E: numpy._pytesttester.PytestTester +reveal_type(np.test.module_name) # E: str reveal_type(np.__all__) # E: list[builtins.str] reveal_type(np.char.__all__) # E: list[builtins.str] |
