Skip to content

Commit 158a4c1

Browse files
committed
chore: format code
1 parent c81e9bc commit 158a4c1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ssspx/graph_numpy.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Iterable, List
77

88
import numpy as np
9+
import numpy.typing as npt
910

1011
from .exceptions import GraphFormatError, InputError
1112
from .graph import Edge, Float, Graph, Vertex
@@ -25,8 +26,9 @@ def __post_init__(self) -> None:
2526
"""Validate initialization arguments and allocate adjacency storage."""
2627
if not isinstance(self.n, int) or self.n <= 0:
2728
raise InputError("Graph.n must be a positive integer.")
28-
self.adj: List[np.ndarray] = [
29-
np.zeros((0, 2), dtype=float) for _ in range(self.n)
29+
# Use proper numpy typing
30+
self.adj: List[npt.NDArray[np.float64]] = [
31+
np.zeros((0, 2), dtype=np.float64) for _ in range(self.n)
3032
]
3133

3234
def add_edge(self, u: Vertex, v: Vertex, w: Float) -> None:
@@ -38,7 +40,7 @@ def add_edge(self, u: Vertex, v: Vertex, w: Float) -> None:
3840
if w < 0:
3941
raise GraphFormatError(f"negative weight {w} on edge ({u}, {v})")
4042
arr = self.adj[u]
41-
self.adj[u] = np.vstack([arr, np.array([[v, float(w)]])])
43+
self.adj[u] = np.vstack([arr, np.array([[v, float(w)]], dtype=np.float64)])
4244

4345
@classmethod
4446
def from_edges(cls, n: int, edges: Iterable[Edge]) -> "NumpyGraph":

0 commit comments

Comments
 (0)