blob: 286c8a81dacf3351dc6e128437e39a86b4e146bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from typing import Any, NamedTuple, cast
import numpy as np
# Subtype of tuple[int, int]
class XYGrid(NamedTuple):
x_axis: int
y_axis: int
# Test variance of _ShapeT_co
def accepts_2d(a: np.ndarray[tuple[int, int], Any]) -> None:
return None
accepts_2d(np.empty(XYGrid(2, 2)))
accepts_2d(np.zeros(XYGrid(2, 2), dtype=int))
accepts_2d(np.ones(XYGrid(2, 2), dtype=int))
accepts_2d(np.full(XYGrid(2, 2), fill_value=5, dtype=int))
|