Skip to content

Commit fe6352b

Browse files
committed
Fix NumPy related type hints.
These are still too strict but now they're no longer broken.
1 parent 4e343cb commit fe6352b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

tcod/path.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def get_path(self, x: int, y: int) -> List[Tuple[int, int]]:
302302

303303
def maxarray(
304304
shape: Tuple[int, ...], dtype: Any = np.int32, order: str = "C"
305-
) -> np.array:
305+
) -> np.ndarray:
306306
"""Return a new array filled with the maximum finite value for `dtype`.
307307
308308
`shape` is of the new array. Same as other NumPy array initializers.
@@ -321,7 +321,7 @@ def maxarray(
321321
return np.full(shape, np.iinfo(dtype).max, dtype, order)
322322

323323

324-
def _export_dict(array: np.array) -> Dict[str, Any]:
324+
def _export_dict(array: np.ndarray) -> Dict[str, Any]:
325325
"""Convert a NumPy array into a format compatible with CFFI."""
326326
if array.dtype.type not in _INT_TYPES:
327327
raise TypeError(
@@ -337,7 +337,7 @@ def _export_dict(array: np.array) -> Dict[str, Any]:
337337
}
338338

339339

340-
def _export(array: np.array) -> Any:
340+
def _export(array: np.ndarray) -> Any:
341341
"""Convert a NumPy array into a ctype object."""
342342
return ffi.new("struct NArray*", _export_dict(array))
343343

@@ -365,8 +365,8 @@ def _compile_cost_edges(edge_map: Any) -> Tuple[Any, int]:
365365

366366

367367
def dijkstra2d(
368-
distance: np.array,
369-
cost: np.array,
368+
distance: np.ndarray,
369+
cost: np.ndarray,
370370
cardinal: Optional[int] = None,
371371
diagonal: Optional[int] = None,
372372
*,
@@ -516,13 +516,13 @@ def _compile_bool_edges(edge_map: Any) -> Tuple[Any, int]:
516516

517517

518518
def hillclimb2d(
519-
distance: np.array,
519+
distance: np.ndarray,
520520
start: Tuple[int, int],
521521
cardinal: Optional[bool] = None,
522522
diagonal: Optional[bool] = None,
523523
*,
524524
edge_map: Any = None
525-
) -> np.array:
525+
) -> np.ndarray:
526526
"""Return a path on a grid from `start` to the lowest point.
527527
528528
`distance` should be a fully computed distance array. This kind of array

tcod/sdl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class _TempSurface:
1616
"""Holds a temporary surface derived from a NumPy array."""
1717

18-
def __init__(self, pixels: np.array) -> None:
18+
def __init__(self, pixels: np.ndarray) -> None:
1919
self._array = np.ascontiguousarray(pixels, dtype=np.uint8)
2020
if len(self._array) != 3:
2121
raise TypeError(
@@ -33,7 +33,7 @@ def __init__(self, pixels: np.array) -> None:
3333
self._array.shape[1], # Width.
3434
self._array.shape[0], # Height.
3535
self._array.shape[2] * 8, # Bit depth.
36-
self._array.stride[1], # Pitch.
36+
self._array.strides[1], # Pitch.
3737
0x000000FF,
3838
0x0000FF00,
3939
0x00FF0000,
@@ -59,7 +59,7 @@ def __init__(self, sdl_window_p: Any) -> None:
5959
def __eq__(self, other: Any) -> bool:
6060
return bool(self.p == other.p)
6161

62-
def set_icon(self, image: np.array) -> None:
62+
def set_icon(self, image: np.ndarray) -> None:
6363
"""Set the window icon from an image.
6464
6565
`image` is a C memory order RGB or RGBA NumPy array.

0 commit comments

Comments
 (0)