| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/numpy/typing/tests/data/reveal/ |
Upload File : |
from __future__ import annotations
from typing import TypeVar
import numpy as np
import numpy.typing as npt
T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)
def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[T1 | T2]:
return a + b
i8: np.int64
i4: np.int32
f8: np.float64
f4: np.float32
reveal_type(add(f8, i8)) # E: {float64}
reveal_type(add(f4, i8)) # E: {float64}
reveal_type(add(f8, i4)) # E: {float64}
reveal_type(add(f4, i4)) # E: {float32}