Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
nbit_base_example.pyi21 linesDownload Raw Back to reveal
1from typing import TypeVar, assert_type
2
3import numpy as np
4import numpy.typing as npt
5from numpy._typing import _32Bit, _64Bit
6
7T1 = TypeVar("T1", bound=npt.NBitBase)  # type: ignore[deprecated]  # pyright: ignore[reportDeprecated]
8T2 = TypeVar("T2", bound=npt.NBitBase)  # type: ignore[deprecated]  # pyright: ignore[reportDeprecated]
9
10def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[T1 | T2]: ...
11
12i8: np.int64
13i4: np.int32
14f8: np.float64
15f4: np.float32
16
17assert_type(add(f8, i8), np.floating[_64Bit])
18assert_type(add(f4, i8), np.floating[_32Bit | _64Bit])
19assert_type(add(f8, i4), np.floating[_32Bit | _64Bit])
20assert_type(add(f4, i4), np.floating[_32Bit])
21 
codekingpro/portable-devtools · Team Ai