Skip to content

Commit 647d5d7

Browse files
committed
enh(net): accurate prune() assertions
1 parent cd0dff3 commit 647d5d7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

graphtik/network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ def prune(
679679
f"Unknown output nodes: {list(unknown_outputs)}\n {self}"
680680
)
681681

682-
assert inputs is not None and not isinstance(inputs, str)
683-
# but outputs may still be null.
682+
assert isinstance(inputs, abc.Collection)
683+
assert outputs is None or isinstance(outputs, abc.Collection)
684684

685685
broken_dag = dag.copy() # preserve net's graph
686686
broken_edges = set() # unordered, not iterated
@@ -720,8 +720,8 @@ def prune(
720720
)
721721

722722
assert all(_yield_datanodes(pruned_dag)), pruned_dag
723-
assert inputs is not None and not isinstance(inputs, str)
724-
assert outputs is not None and not isinstance(outputs, str)
723+
assert inputs is not None or isinstance(inputs, abc.Collection)
724+
assert outputs is not None or isinstance(outputs, abc.Collection)
725725

726726
return pruned_dag, broken_edges, tuple(inputs), tuple(outputs)
727727

0 commit comments

Comments
 (0)