MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / _to_tuple

Function _to_tuple

easygraph/readwrite/json_graph/node_link.py:13–27  ·  view source on GitHub ↗

Converts lists to tuples, including nested lists. All other non-list inputs are passed through unmodified. This function is intended to be used to convert potentially nested lists from json files into valid nodes. Examples -------- >>> _to_tuple([1, 2, [3, 4]]) (1, 2, (

(x)

Source from the content-addressed store, hash-verified

11
12
13def _to_tuple(x):
14 """Converts lists to tuples, including nested lists.
15
16 All other non-list inputs are passed through unmodified. This function is
17 intended to be used to convert potentially nested lists from json files
18 into valid nodes.
19
20 Examples
21 --------
22 >>> _to_tuple([1, 2, [3, 4]])
23 (1, 2, (3, 4))
24 """
25 if not isinstance(x, (tuple, list)):
26 return x
27 return tuple(map(_to_tuple, x))
28
29
30def node_link_graph(data, directed=False, multigraph=True, attrs=None):

Callers 1

node_link_graphFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected