Skip to content

Commit cdbb3ef

Browse files
committed
MNT: extend type for type-checking
1 parent fa05508 commit cdbb3ef

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

examples/json_load.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,26 @@ 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__(self, *arg, **kw):
55+
super().__init__(*arg, **kw)
56+
self.roots: dict | None = None
57+
self.level_of_var: dict | None = None
58+
59+
5060
def load_and_map_to_nx(
5161
filename:
5262
str
53-
) -> _nx.DiGraph:
63+
) -> BDDGraph:
5464
"""Return graph loaded from JSON."""
5565
with open(filename, 'r') as fd:
5666
data = fd.read()
5767
data = json.loads(data)
5868
# map to nx
59-
graph = _nx.DiGraph()
69+
graph = BDDGraph()
6070
for k, v in data.items():
6171
print(k, v)
6272
if k in ('roots', 'level_of_var'):

0 commit comments

Comments
 (0)