Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/numpy2 #86

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sampo/schemas/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self,
holders: list[ResourceHolder] = None,
lg: LandGraph = None,
zone_config: ZoneConfiguration = ZoneConfiguration()):
self.WAY_LENGTH = np.Inf
self.WAY_LENGTH = np.inf
self.dist_mx: list[list[float]] = None
self.path_mx: np.array = None
self.road_mx: list[list[str]] = None
Expand Down Expand Up @@ -178,7 +178,7 @@ def construct_route(self, from_node: LandGraphNode, to_node: LandGraphNode,
for u in range(self.lg.vertex_count):
if v == u:
path_mx[v][u] = 0
elif adj_matrix[v][u] != np.Inf and self.road_mx[v][u] in roads_available_set:
elif adj_matrix[v][u] != np.inf and self.road_mx[v][u] in roads_available_set:
path_mx[v][u] = v

from_ind = self._node2ind[from_node]
Expand Down Expand Up @@ -246,7 +246,7 @@ def _build_routes(self):
for u in range(count):
if v == u:
path_mx[v][u] = 0
elif dist_mx[v][u] != np.Inf:
elif dist_mx[v][u] != np.inf:
path_mx[v][u] = v
for road in self.lg.nodes[v].roads:
if self.lg.node2ind[road.finish] == u:
Expand All @@ -257,8 +257,8 @@ def _build_routes(self):
for i in range(self.lg.vertex_count):
for u in range(self.lg.vertex_count):
for v in range(self.lg.vertex_count):
if (dist_mx[u][i] != np.Inf and dist_mx[u][i] != 0
and dist_mx[i][v] != np.Inf and dist_mx[i][v] != 0
if (dist_mx[u][i] != np.inf and dist_mx[u][i] != 0
and dist_mx[i][v] != np.inf and dist_mx[i][v] != 0
and dist_mx[u][i] + dist_mx[i][v] < dist_mx[u][v]):
dist_mx[u][v] = dist_mx[u][i] + dist_mx[i][v]
path_mx[u][v] = path_mx[i][v]
Expand Down
2 changes: 1 addition & 1 deletion sampo/schemas/landscape_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _to_adj_matrix(self) -> tuple[np.array, dict[LandGraphNode, int], dict[str,
id2ind = {
v.id: i for i, v in enumerate(self.nodes)
}
adj_mtrx = np.full((len(node2ind), len(node2ind)), np.Inf)
adj_mtrx = np.full((len(node2ind), len(node2ind)), np.inf)
for v, i in node2ind.items():
for child in v.roads:
c_i = node2ind[child.finish]
Expand Down
4 changes: 2 additions & 2 deletions tests/schemas/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def dijkstra(node_ind, n, target_node_ind):

return distances[node_ind][target_node_ind]

MAX_WEIGHT = np.Inf
MAX_WEIGHT = np.inf
landscape = setup_landscape_many_holders
landscape.build_landscape()

Expand All @@ -49,7 +49,7 @@ def test_holder_sorting(setup_lg, setup_landscape_many_holders):
correct = 0
for node in lg.nodes:
target_holder = landscape.get_sorted_holders(lg.node2ind[node])[0][1]
min_dist = np.Inf
min_dist = np.inf
received_holder = 0
for holder in holders:
dist = landscape.dist_mx[lg.node2ind[node]][lg.node2ind[holder]]
Expand Down
Loading