diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2020-09-07 10:54:30 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-07 10:54:30 -0600 |
| commit | d15254d487fa432b3f14aa32c9e9552835f76248 (patch) | |
| tree | 201edda33a0f6b6a03263b11e58f309c9fcd303e /numpy/tests | |
| parent | 9c9df9c649361fb651f4b2174e779b3036464ab4 (diff) | |
| parent | 423004b6d39d04028ed0b3397a4dd14681451eae (diff) | |
| download | numpy-d15254d487fa432b3f14aa32c9e9552835f76248.tar.gz | |
Merge pull request #17144 from BvB93/function-base-core
ENH: Add annotations to 3 functions in `np.core.function_base`
Diffstat (limited to 'numpy/tests')
| -rw-r--r-- | numpy/tests/typing/fail/linspace.py | 13 | ||||
| -rw-r--r-- | numpy/tests/typing/pass/linspace.py | 22 | ||||
| -rw-r--r-- | numpy/tests/typing/reveal/linspace.py | 6 |
3 files changed, 41 insertions, 0 deletions
diff --git a/numpy/tests/typing/fail/linspace.py b/numpy/tests/typing/fail/linspace.py new file mode 100644 index 000000000..a9769c5d6 --- /dev/null +++ b/numpy/tests/typing/fail/linspace.py @@ -0,0 +1,13 @@ +import numpy as np + +np.linspace(None, 'bob') # E: No overload variant +np.linspace(0, 2, num=10.0) # E: No overload variant +np.linspace(0, 2, endpoint='True') # E: No overload variant +np.linspace(0, 2, retstep=b'False') # E: No overload variant +np.linspace(0, 2, dtype=0) # E: No overload variant +np.linspace(0, 2, axis=None) # E: No overload variant + +np.logspace(None, 'bob') # E: Argument 1 +np.logspace(0, 2, base=None) # E: Argument "base" + +np.geomspace(None, 'bob') # E: Argument 1 diff --git a/numpy/tests/typing/pass/linspace.py b/numpy/tests/typing/pass/linspace.py new file mode 100644 index 000000000..8c6d0d56b --- /dev/null +++ b/numpy/tests/typing/pass/linspace.py @@ -0,0 +1,22 @@ +import numpy as np + +class Index: + def __index__(self) -> int: + return 0 + +np.linspace(0, 2) +np.linspace(0.5, [0, 1, 2]) +np.linspace([0, 1, 2], 3) +np.linspace(0j, 2) +np.linspace(0, 2, num=10) +np.linspace(0, 2, endpoint=True) +np.linspace(0, 2, retstep=True) +np.linspace(0j, 2j, retstep=True) +np.linspace(0, 2, dtype=bool) +np.linspace([0, 1], [2, 3], axis=Index()) + +np.logspace(0, 2, base=2) +np.logspace(0, 2, base=2) +np.logspace(0, 2, base=[1j, 2j], num=2) + +np.geomspace(1, 2) diff --git a/numpy/tests/typing/reveal/linspace.py b/numpy/tests/typing/reveal/linspace.py new file mode 100644 index 000000000..cfbbdf390 --- /dev/null +++ b/numpy/tests/typing/reveal/linspace.py @@ -0,0 +1,6 @@ +import numpy as np + +reveal_type(np.linspace(0, 10)) # E: numpy.ndarray +reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[numpy.ndarray, numpy.inexact] +reveal_type(np.logspace(0, 10)) # E: numpy.ndarray +reveal_type(np.geomspace(1, 10)) # E: numpy.ndarray |
