|
| 1 | +from typing import TypeVar |
| 2 | + |
1 | 3 | from numpy import dtype, ndarray |
2 | 4 | from numpy import float32 as f32 |
3 | 5 | from numpy import float64 as f64 |
4 | 6 |
|
5 | 7 | from rlic._boundaries import BoundaryStr |
6 | 8 | from rlic._typing import Pair, UVMode |
7 | 9 |
|
| 10 | +I = TypeVar("I", bound=int) |
| 11 | +J = TypeVar("J", bound=int) |
| 12 | +F = TypeVar("F", f32, f64) |
| 13 | + |
| 14 | +IJArray = ndarray[tuple[I, J], dtype[F]] |
| 15 | + |
8 | 16 | def convolve_f32( |
9 | | - texture: ndarray[tuple[int, int], dtype[f32]], |
| 17 | + texture: IJArray[I, J, f32], |
10 | 18 | uv: tuple[ |
11 | | - ndarray[tuple[int, int], dtype[f32]], |
12 | | - ndarray[tuple[int, int], dtype[f32]], |
| 19 | + IJArray[I, J, f32], |
| 20 | + IJArray[I, J, f32], |
13 | 21 | UVMode, |
14 | 22 | ], |
15 | 23 | kernel: ndarray[tuple[int], dtype[f32]], |
16 | 24 | boundaries: Pair[Pair[BoundaryStr]], |
17 | 25 | iterations: int = 1, |
18 | | -) -> ndarray[tuple[int, int], dtype[f32]]: ... |
| 26 | +) -> IJArray[I, J, f32]: ... |
19 | 27 | def convolve_f64( |
20 | | - texture: ndarray[tuple[int, int], dtype[f64]], |
| 28 | + texture: IJArray[I, J, f64], |
21 | 29 | uv: tuple[ |
22 | | - ndarray[tuple[int, int], dtype[f64]], |
23 | | - ndarray[tuple[int, int], dtype[f64]], |
| 30 | + IJArray[I, J, f64], |
| 31 | + IJArray[I, J, f64], |
24 | 32 | UVMode, |
25 | 33 | ], |
26 | 34 | kernel: ndarray[tuple[int], dtype[f64]], |
27 | 35 | boundaries: Pair[Pair[BoundaryStr]], |
28 | 36 | iterations: int = 1, |
29 | | -) -> ndarray[tuple[int, int], dtype[f64]]: ... |
| 37 | +) -> IJArray[I, J, f64]: ... |
30 | 38 | def equalize_histogram_f32( |
31 | | - image: ndarray[tuple[int, int], dtype[f32]], |
| 39 | + image: IJArray[I, J, f32], |
32 | 40 | nbins: int, |
33 | | -) -> ndarray[tuple[int, int], dtype[f32]]: ... |
| 41 | +) -> IJArray[I, J, f32]: ... |
34 | 42 | def equalize_histogram_f64( |
35 | | - image: ndarray[tuple[int, int], dtype[f64]], |
| 43 | + image: IJArray[I, J, f64], |
36 | 44 | nbins: int, |
37 | | -) -> ndarray[tuple[int, int], dtype[f64]]: ... |
| 45 | +) -> IJArray[I, J, f64]: ... |
38 | 46 | def equalize_histogram_sliding_tile_f32( |
39 | | - image: ndarray[tuple[int, int], dtype[f32]], |
| 47 | + image: IJArray[I, J, f32], |
40 | 48 | nbins: int, |
41 | 49 | tile_shape: Pair[int], |
42 | | -) -> ndarray[tuple[int, int], dtype[f32]]: ... |
| 50 | +) -> IJArray[I, J, f32]: ... |
43 | 51 | def equalize_histogram_sliding_tile_f64( |
44 | | - image: ndarray[tuple[int, int], dtype[f64]], |
| 52 | + image: IJArray[I, J, f64], |
45 | 53 | nbins: int, |
46 | 54 | tile_shape: Pair[int], |
47 | | -) -> ndarray[tuple[int, int], dtype[f64]]: ... |
| 55 | +) -> IJArray[I, J, f64]: ... |
48 | 56 | def equalize_histogram_tile_interpolation_f32( |
49 | | - image: ndarray[tuple[int, int], dtype[f32]], |
| 57 | + image: IJArray[I, J, f32], |
50 | 58 | nbins: int, |
51 | 59 | tile_shape: Pair[int], |
52 | | -) -> ndarray[tuple[int, int], dtype[f32]]: ... |
| 60 | +) -> IJArray[I, J, f32]: ... |
53 | 61 | def equalize_histogram_tile_interpolation_f64( |
54 | | - image: ndarray[tuple[int, int], dtype[f64]], |
| 62 | + image: IJArray[I, J, f64], |
55 | 63 | nbins: int, |
56 | 64 | tile_shape: Pair[int], |
57 | | -) -> ndarray[tuple[int, int], dtype[f64]]: ... |
| 65 | +) -> IJArray[I, J, f64]: ... |
0 commit comments