|
1 | 1 | from collections.abc import Callable |
2 | 2 | from threading import Lock |
3 | | -from typing import Any, Literal, cast |
| 3 | +from typing import Any, Literal |
4 | 4 |
|
5 | | -from numpy.typing import NDArray |
6 | | - |
7 | | -from gpgi._typing import FloatT |
| 5 | +from gpgi._typing import DH, F, FArray |
8 | 6 |
|
9 | 7 | BoundaryRecipeT = Callable[ |
10 | 8 | [ |
11 | | - NDArray[FloatT], |
12 | | - NDArray[FloatT], |
13 | | - NDArray[FloatT], |
14 | | - NDArray[FloatT], |
15 | | - NDArray[FloatT], |
16 | | - NDArray[FloatT], |
17 | | - NDArray[FloatT], |
18 | | - NDArray[FloatT], |
| 9 | + FArray[DH, F], |
| 10 | + FArray[DH, F], |
| 11 | + FArray[DH, F], |
| 12 | + FArray[DH, F], |
| 13 | + FArray[DH, F], |
| 14 | + FArray[DH, F], |
| 15 | + FArray[DH, F], |
| 16 | + FArray[DH, F], |
19 | 17 | Literal["left", "right"], |
20 | 18 | dict[str, Any], |
21 | 19 | ], |
22 | | - NDArray[FloatT], |
| 20 | + FArray[DH, F], |
23 | 21 | ] |
24 | 22 |
|
25 | 23 |
|
@@ -125,64 +123,64 @@ def __contains__(self, key: str) -> bool: |
125 | 123 |
|
126 | 124 | # basic recipes |
127 | 125 | def open_boundary( |
128 | | - same_side_active_layer: NDArray[FloatT], |
129 | | - same_side_ghost_layer: NDArray[FloatT], |
130 | | - opposite_side_active_layer: NDArray[FloatT], |
131 | | - opposite_side_ghost_layer: NDArray[FloatT], |
132 | | - weight_same_side_active_layer: NDArray[FloatT], |
133 | | - weight_same_side_ghost_layer: NDArray[FloatT], |
134 | | - weight_opposite_side_active_layer: NDArray[FloatT], |
135 | | - weight_opposite_side_ghost_layer: NDArray[FloatT], |
| 126 | + same_side_active_layer: FArray[DH, F], |
| 127 | + same_side_ghost_layer: FArray[DH, F], |
| 128 | + opposite_side_active_layer: FArray[DH, F], |
| 129 | + opposite_side_ghost_layer: FArray[DH, F], |
| 130 | + weight_same_side_active_layer: FArray[DH, F], |
| 131 | + weight_same_side_ghost_layer: FArray[DH, F], |
| 132 | + weight_opposite_side_active_layer: FArray[DH, F], |
| 133 | + weight_opposite_side_ghost_layer: FArray[DH, F], |
136 | 134 | side: Literal["left", "right"], |
137 | 135 | metadata: dict[str, Any], |
138 | | -) -> NDArray[FloatT]: |
| 136 | +) -> FArray[DH, F]: |
139 | 137 | # return the active layer unchanged |
140 | 138 | return same_side_active_layer |
141 | 139 |
|
142 | 140 |
|
143 | 141 | def wall_boundary( |
144 | | - same_side_active_layer: NDArray[FloatT], |
145 | | - same_side_ghost_layer: NDArray[FloatT], |
146 | | - opposite_side_active_layer: NDArray[FloatT], |
147 | | - opposite_side_ghost_layer: NDArray[FloatT], |
148 | | - weight_same_side_active_layer: NDArray[FloatT], |
149 | | - weight_same_side_ghost_layer: NDArray[FloatT], |
150 | | - weight_opposite_side_active_layer: NDArray[FloatT], |
151 | | - weight_opposite_side_ghost_layer: NDArray[FloatT], |
| 142 | + same_side_active_layer: FArray[DH, F], |
| 143 | + same_side_ghost_layer: FArray[DH, F], |
| 144 | + opposite_side_active_layer: FArray[DH, F], |
| 145 | + opposite_side_ghost_layer: FArray[DH, F], |
| 146 | + weight_same_side_active_layer: FArray[DH, F], |
| 147 | + weight_same_side_ghost_layer: FArray[DH, F], |
| 148 | + weight_opposite_side_active_layer: FArray[DH, F], |
| 149 | + weight_opposite_side_ghost_layer: FArray[DH, F], |
152 | 150 | side: Literal["left", "right"], |
153 | 151 | metadata: dict[str, Any], |
154 | | -) -> NDArray[FloatT]: |
155 | | - return cast("NDArray[FloatT]", same_side_active_layer + same_side_ghost_layer) |
| 152 | +) -> FArray[DH, F]: |
| 153 | + return same_side_active_layer + same_side_ghost_layer # pyright: ignore[reportReturnType] |
156 | 154 |
|
157 | 155 |
|
158 | 156 | def antisymmetric_boundary( |
159 | | - same_side_active_layer: NDArray[FloatT], |
160 | | - same_side_ghost_layer: NDArray[FloatT], |
161 | | - opposite_side_active_layer: NDArray[FloatT], |
162 | | - opposite_side_ghost_layer: NDArray[FloatT], |
163 | | - weight_same_side_active_layer: NDArray[FloatT], |
164 | | - weight_same_side_ghost_layer: NDArray[FloatT], |
165 | | - weight_opposite_side_active_layer: NDArray[FloatT], |
166 | | - weight_opposite_side_ghost_layer: NDArray[FloatT], |
| 157 | + same_side_active_layer: FArray[DH, F], |
| 158 | + same_side_ghost_layer: FArray[DH, F], |
| 159 | + opposite_side_active_layer: FArray[DH, F], |
| 160 | + opposite_side_ghost_layer: FArray[DH, F], |
| 161 | + weight_same_side_active_layer: FArray[DH, F], |
| 162 | + weight_same_side_ghost_layer: FArray[DH, F], |
| 163 | + weight_opposite_side_active_layer: FArray[DH, F], |
| 164 | + weight_opposite_side_ghost_layer: FArray[DH, F], |
167 | 165 | side: Literal["left", "right"], |
168 | 166 | metadata: dict[str, Any], |
169 | | -) -> NDArray[FloatT]: |
170 | | - return cast("NDArray[FloatT]", same_side_active_layer - same_side_ghost_layer) |
| 167 | +) -> FArray[DH, F]: |
| 168 | + return same_side_active_layer - same_side_ghost_layer # pyright: ignore[reportReturnType] |
171 | 169 |
|
172 | 170 |
|
173 | 171 | def periodic_boundary( |
174 | | - same_side_active_layer: NDArray[FloatT], |
175 | | - same_side_ghost_layer: NDArray[FloatT], |
176 | | - opposite_side_active_layer: NDArray[FloatT], |
177 | | - opposite_side_ghost_layer: NDArray[FloatT], |
178 | | - weight_same_side_active_layer: NDArray[FloatT], |
179 | | - weight_same_side_ghost_layer: NDArray[FloatT], |
180 | | - weight_opposite_side_active_layer: NDArray[FloatT], |
181 | | - weight_opposite_side_ghost_layer: NDArray[FloatT], |
| 172 | + same_side_active_layer: FArray[DH, F], |
| 173 | + same_side_ghost_layer: FArray[DH, F], |
| 174 | + opposite_side_active_layer: FArray[DH, F], |
| 175 | + opposite_side_ghost_layer: FArray[DH, F], |
| 176 | + weight_same_side_active_layer: FArray[DH, F], |
| 177 | + weight_same_side_ghost_layer: FArray[DH, F], |
| 178 | + weight_opposite_side_active_layer: FArray[DH, F], |
| 179 | + weight_opposite_side_ghost_layer: FArray[DH, F], |
182 | 180 | side: Literal["left", "right"], |
183 | 181 | metadata: dict[str, Any], |
184 | | -) -> NDArray[FloatT]: |
185 | | - return cast("NDArray[FloatT]", same_side_active_layer + opposite_side_ghost_layer) |
| 182 | +) -> FArray[DH, F]: |
| 183 | + return same_side_active_layer + opposite_side_ghost_layer # pyright: ignore[reportReturnType] |
186 | 184 |
|
187 | 185 |
|
188 | 186 | _base_registry: dict[str, BoundaryRecipeT] = { |
|
0 commit comments