|
11 | 11 | import numpy as np |
12 | 12 | from dataclasses import dataclass, field |
13 | 13 | from collections import defaultdict, deque |
14 | | -import logging |
15 | 14 |
|
16 | 15 | from ...utils import getLogger |
17 | 16 |
|
18 | 17 | if TYPE_CHECKING: |
19 | | - from typing import Callable |
| 18 | + pass |
20 | 19 |
|
21 | 20 | logger = getLogger(__name__) |
22 | 21 |
|
@@ -642,7 +641,7 @@ def topological_sort_by_dependencies(self) -> Dict[str, Union[List[str], List[Li |
642 | 641 | deps = self.build_dependency_graph() |
643 | 642 |
|
644 | 643 | # Compute in-degree for Kahn's algorithm |
645 | | - indeg: Dict[str, int] = {n: 0 for n in deps.keys()} |
| 644 | + indeg: Dict[str, int] = dict.fromkeys(deps.keys(), 0) |
646 | 645 | for u, succs in deps.items(): |
647 | 646 | for v in succs: |
648 | 647 | indeg[v] = indeg.get(v, 0) + 1 |
@@ -1072,7 +1071,7 @@ def _check_for_cycles(self): |
1072 | 1071 |
|
1073 | 1072 | # DFS cycle detection with coloring |
1074 | 1073 | WHITE, GRAY, BLACK = 0, 1, 2 |
1075 | | - color = {uid: WHITE for uid in unit_ids} |
| 1074 | + color = dict.fromkeys(unit_ids, WHITE) |
1076 | 1075 |
|
1077 | 1076 | def dfs_visit(node_id: str, path: List[str]): |
1078 | 1077 | color[node_id] = GRAY |
@@ -1119,7 +1118,7 @@ def _sort_units_within_group(self, units: List[GeologicalObject]) -> List[Geolog |
1119 | 1118 |
|
1120 | 1119 | # Build adjacency for relationships within this group |
1121 | 1120 | adj: Dict[str, List[str]] = defaultdict(list) |
1122 | | - in_degree = {uid: 0 for uid in unit_ids} |
| 1121 | + in_degree = dict.fromkeys(unit_ids, 0) |
1123 | 1122 |
|
1124 | 1123 | for unit_id in unit_ids: |
1125 | 1124 | rels = self.graph.get_relationships(from_object_id=unit_id) |
@@ -1188,7 +1187,7 @@ def _sort_groups(self, groups: List[List[GeologicalObject]]) -> List[List[Geolog |
1188 | 1187 |
|
1189 | 1188 | # Build inter-group adjacency based on unconformity relationships |
1190 | 1189 | group_adj: Dict[int, Set[int]] = defaultdict(set) |
1191 | | - group_in_degree = {i: 0 for i in range(len(groups))} |
| 1190 | + group_in_degree = dict.fromkeys(range(len(groups)), 0) |
1192 | 1191 |
|
1193 | 1192 | unconformity_types = { |
1194 | 1193 | RelationshipType.ERODE_UNCONFORMABLY_OVERLIES, |
|
0 commit comments