summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-03-15 14:56:31 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-03-15 15:16:14 +0100
commit564a71c29fae0b09eb8a44a96600a1f9a5b00a16 (patch)
tree0e4c8d1c7db72635d8ffe7f0b838e8855a7afe7c /numpy
parent5db3366c4e879b8f779a0ae4048c7637854f1588 (diff)
downloadnumpy-564a71c29fae0b09eb8a44a96600a1f9a5b00a16.tar.gz
MAINT: Re-export a number of sub-modules
Ensures that type checkers will allow the likes of: >>> import numpy as np >>> out = np.lib.stride_tricks.sliding_window_view(...)
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/__init__.pyi7
-rw-r--r--numpy/ma/__init__.pyi2
-rw-r--r--numpy/polynomial/__init__.pyi10
-rw-r--r--numpy/typing/tests/data/fail/modules.py5
-rw-r--r--numpy/typing/tests/data/pass/modules.py13
-rw-r--r--numpy/typing/tests/data/reveal/modules.py13
6 files changed, 50 insertions, 0 deletions
diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi
index ec528d220..02ed56c8b 100644
--- a/numpy/lib/__init__.pyi
+++ b/numpy/lib/__init__.pyi
@@ -5,6 +5,13 @@ from numpy import (
ndindex as ndindex,
)
+from numpy.lib import (
+ format as format,
+ mixins as mixins,
+ scimath as scimath,
+ stride_tricks as stride_stricks,
+)
+
from numpy.lib.arrayterator import (
Arrayterator as Arrayterator,
)
diff --git a/numpy/ma/__init__.pyi b/numpy/ma/__init__.pyi
index 66dfe40de..16e026272 100644
--- a/numpy/ma/__init__.pyi
+++ b/numpy/ma/__init__.pyi
@@ -1,5 +1,7 @@
from typing import Any, List
+from numpy.ma import extras as extras
+
__all__: List[str]
core: Any
diff --git a/numpy/polynomial/__init__.pyi b/numpy/polynomial/__init__.pyi
index 817ba22ac..5f4d11e90 100644
--- a/numpy/polynomial/__init__.pyi
+++ b/numpy/polynomial/__init__.pyi
@@ -1,5 +1,15 @@
from typing import Any
+from numpy.polynomial import (
+ chebyshev as chebyshev,
+ hermite as hermite,
+ hermite_e as hermite_e,
+ laguerre as laguerre,
+ legendre as legendre,
+ polynomial as polynomial,
+ polyutils as polyutils,
+)
+
Polynomial: Any
Chebyshev: Any
Legendre: Any
diff --git a/numpy/typing/tests/data/fail/modules.py b/numpy/typing/tests/data/fail/modules.py
index b80fd9ede..7b9309329 100644
--- a/numpy/typing/tests/data/fail/modules.py
+++ b/numpy/typing/tests/data/fail/modules.py
@@ -9,6 +9,11 @@ np.sys # E: Module has no attribute
np.os # E: Module has no attribute
np.math # E: Module has no attribute
+# Public sub-modules that are not imported to their parent module by default;
+# e.g. one must first execute `import numpy.lib.recfunctions`
+np.lib.recfunctions # E: Module has no attribute
+np.ma.mrecords # E: Module has no attribute
+
np.__NUMPY_SETUP__ # E: Module has no attribute
np.__deprecated_attrs__ # E: Module has no attribute
np.__expired_functions__ # E: Module has no attribute
diff --git a/numpy/typing/tests/data/pass/modules.py b/numpy/typing/tests/data/pass/modules.py
index 2fdb69eb3..5ca9691ac 100644
--- a/numpy/typing/tests/data/pass/modules.py
+++ b/numpy/typing/tests/data/pass/modules.py
@@ -15,6 +15,19 @@ np.rec
np.testing
np.version
+np.lib.format
+np.lib.mixins
+np.lib.scimath
+np.lib.stride_tricks
+np.ma.extras
+np.polynomial.chebyshev
+np.polynomial.hermite
+np.polynomial.hermite_e
+np.polynomial.laguerre
+np.polynomial.legendre
+np.polynomial.polynomial
+np.polynomial.polyutils
+
np.__path__
np.__version__
np.__git_version__
diff --git a/numpy/typing/tests/data/reveal/modules.py b/numpy/typing/tests/data/reveal/modules.py
index 75513f2b0..4852d60b7 100644
--- a/numpy/typing/tests/data/reveal/modules.py
+++ b/numpy/typing/tests/data/reveal/modules.py
@@ -17,6 +17,19 @@ reveal_type(np.rec) # E: ModuleType
reveal_type(np.testing) # E: ModuleType
reveal_type(np.version) # E: ModuleType
+reveal_type(np.lib.format) # E: ModuleType
+reveal_type(np.lib.mixins) # E: ModuleType
+reveal_type(np.lib.scimath) # E: ModuleType
+reveal_type(np.lib.stride_tricks) # E: ModuleType
+reveal_type(np.ma.extras) # E: ModuleType
+reveal_type(np.polynomial.chebyshev) # E: ModuleType
+reveal_type(np.polynomial.hermite) # E: ModuleType
+reveal_type(np.polynomial.hermite_e) # E: ModuleType
+reveal_type(np.polynomial.laguerre) # E: ModuleType
+reveal_type(np.polynomial.legendre) # E: ModuleType
+reveal_type(np.polynomial.polynomial) # E: ModuleType
+reveal_type(np.polynomial.polyutils) # E: ModuleType
+
# TODO: Remove when annotations have been added to `np.testing.assert_equal`
reveal_type(np.testing.assert_equal) # E: Any