Skip to content

Commit 5e832f0

Browse files
committed
MNT: extend type for type-checking
1 parent aca929a commit 5e832f0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

examples/json_load.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,29 @@ def create_and_dump_bdd(
4747
roots=roots)
4848

4949

50+
class BDDGraph(
51+
_nx.DiGraph):
52+
"""Storing also roots and variable levels."""
53+
54+
def __init__(
55+
self,
56+
*arg,
57+
**kw):
58+
super().__init__(*arg, **kw)
59+
self.roots: dict | None = None
60+
self.level_of_var: dict | None = None
61+
62+
5063
def load_and_map_to_nx(
5164
filename:
5265
str
53-
) -> _nx.DiGraph:
66+
) -> BDDGraph:
5467
"""Return graph loaded from JSON."""
5568
with open(filename, 'r') as fd:
5669
data = fd.read()
5770
data = json.loads(data)
5871
# map to nx
59-
graph = _nx.DiGraph()
72+
graph = BDDGraph()
6073
for k, v in data.items():
6174
print(k, v)
6275
if k in ('roots', 'level_of_var'):

0 commit comments

Comments
 (0)