@@ -591,7 +591,7 @@ def _world_array(shape: tuple[int, ...], dtype: DTypeLike = np.int32) -> NDArray
591591 )
592592
593593
594- def _as_hashable (obj : np .ndarray [Any , Any ] | None ) -> Any | None :
594+ def _as_hashable (obj : np .ndarray [Any , Any ] | None ) -> object | None :
595595 """Return NumPy arrays as a more hashable form."""
596596 if obj is None :
597597 return obj
@@ -661,6 +661,7 @@ class CustomGraph:
661661 """
662662
663663 def __init__ (self , shape : tuple [int , ...], * , order : str = "C" ) -> None :
664+ """Initialize the custom graph."""
664665 self ._shape = self ._shape_c = tuple (shape )
665666 self ._ndim = len (self ._shape )
666667 self ._order = order
@@ -894,8 +895,7 @@ def add_edges(
894895 edge_array = np .transpose (edge_nz )
895896 edge_array -= edge_center
896897 for edge , edge_cost in zip (edge_array , edge_costs ):
897- edge = tuple (edge )
898- self .add_edge (edge , edge_cost , cost = cost , condition = condition )
898+ self .add_edge (tuple (edge ), edge_cost , cost = cost , condition = condition )
899899
900900 def set_heuristic (self , * , cardinal : int = 0 , diagonal : int = 0 , z : int = 0 , w : int = 0 ) -> None :
901901 """Set a pathfinder heuristic so that pathfinding can done with A*.
@@ -1028,6 +1028,7 @@ class SimpleGraph:
10281028 """
10291029
10301030 def __init__ (self , * , cost : ArrayLike , cardinal : int , diagonal : int , greed : int = 1 ) -> None :
1031+ """Initialize the graph."""
10311032 cost = np .asarray (cost )
10321033 if cost .ndim != 2 : # noqa: PLR2004
10331034 msg = f"The cost array must e 2 dimensional, array of shape { cost .shape !r} given."
@@ -1087,6 +1088,7 @@ class Pathfinder:
10871088 """
10881089
10891090 def __init__ (self , graph : CustomGraph | SimpleGraph ) -> None :
1091+ """Initialize the pathfinder from a graph."""
10901092 self ._graph = graph
10911093 self ._order = graph ._order
10921094 self ._frontier_p = ffi .gc (lib .TCOD_frontier_new (self ._graph ._ndim ), lib .TCOD_frontier_delete )
@@ -1273,7 +1275,7 @@ def resolve(self, goal: tuple[int, ...] | None = None) -> None:
12731275 if self ._order == "F" :
12741276 # Goal is now ij indexed for the rest of this function.
12751277 goal = goal [::- 1 ]
1276- if self ._distance [goal ] != np .iinfo (self ._distance .dtype ).max :
1278+ if self ._distance [goal ] != np .iinfo (self ._distance .dtype ).max : # noqa: SIM102
12771279 if not lib .frontier_has_index (self ._frontier_p , goal ):
12781280 return
12791281 self ._update_heuristic (goal )
0 commit comments