diff options
author | Bas van Beek <b.f.van.beek@vu.nl> | 2020-10-16 16:38:52 +0200 |
---|---|---|
committer | Bas van Beek <b.f.van.beek@vu.nl> | 2020-10-17 18:05:13 +0200 |
commit | 3082bd7e6b23d6076cc6da8b526862019610202c (patch) | |
tree | f89abc72b18585c615578c917beaad8ab896d9c2 | |
parent | 95a391c53cd227fe48c33e03ff1d95f342ae31f5 (diff) | |
download | numpy-3082bd7e6b23d6076cc6da8b526862019610202c.tar.gz |
TST: Added a test for the example in the `NBitBase` docstring
-rw-r--r-- | numpy/typing/tests/data/reveal/nbit_base_example.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/typing/tests/data/reveal/nbit_base_example.py b/numpy/typing/tests/data/reveal/nbit_base_example.py new file mode 100644 index 000000000..0c4c53f9b --- /dev/null +++ b/numpy/typing/tests/data/reveal/nbit_base_example.py @@ -0,0 +1,18 @@ +from typing import TypeVar, Union +import numpy as np +import numpy.typing as npt + +T = TypeVar("T", bound=npt.NBitBase) + +def add(a: np.floating[T], b: np.integer[T]) -> np.floating[T]: + return a + b + +i8: np.int64 +i4: np.int32 +f8: np.float64 +f4: np.float32 + +reveal_type(add(f8, i8)) # E: numpy.floating[numpy.typing._64Bit] +reveal_type(add(f4, i8)) # E: numpy.floating[numpy.typing._64Bit] +reveal_type(add(f8, i4)) # E: numpy.floating[numpy.typing._64Bit] +reveal_type(add(f4, i4)) # E: numpy.floating[numpy.typing._32Bit] |