Skip to content

Commit

Permalink
Save variable types in json
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Nov 27, 2023
1 parent dd4de57 commit ee53416
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyzx/graph/jsonparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def json_to_graph(js: str, backend:Optional[str]=None) -> BaseGraph:
a pyzx graph."""
j = json.loads(js, cls=ComplexDecoder)
g = Graph(backend)
g.variable_types = j.get('variable_types',{})

names: Dict[str, Any] = {} # TODO: Any = VT
hadamards: Dict[str, List[Any]] = {}
Expand Down Expand Up @@ -200,7 +201,6 @@ def graph_to_json(g: BaseGraph[VT,ET], include_scalar: bool=True) -> str:
freenamesb.remove(name) if t==VertexType.BOUNDARY else freenamesv.remove(name)
except:
pass
#print("couldn't remove name '{}'".format(name))

names[v] = name
if t == VertexType.BOUNDARY:
Expand Down Expand Up @@ -270,7 +270,8 @@ def graph_to_json(g: BaseGraph[VT,ET], include_scalar: bool=True) -> str:
d: Dict[str,Any] = {
"wire_vertices": wire_vs,
"node_vertices": node_vs,
"undir_edges": edges
"undir_edges": edges,
"variable_types": g.variable_types,
}
if include_scalar:
d["scalar"] = g.scalar.to_json()
Expand Down

0 comments on commit ee53416

Please sign in to comment.