Skip to content

Commit

Permalink
Docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Jan 21, 2025
1 parent b02d26f commit f36cbc5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pyzx/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,12 @@ def to_matrix(self,preserve_scalar:bool=True) -> np.ndarray:
return tensor_to_matrix(tensorfy(self, preserve_scalar), self.num_inputs(), self.num_outputs())

def to_dict(self, include_scalar:bool=True) -> Dict[str, Any]:
"""Returns a json representation of the graph that follows the Quantomatic .qgraph format.
Convert back into a graph using :meth:`from_json`."""
"""Returns a dictionary representation of the graph, which can then be converted into json."""
from .jsonparser import graph_to_dict
return graph_to_dict(self, include_scalar)

def to_json(self, include_scalar:bool=True) -> str:
"""Returns a json representation of the graph that follows the Quantomatic .qgraph format.
"""Returns a json representation of the graph.
Convert back into a graph using :meth:`from_json`."""
from .jsonparser import graph_to_json
return graph_to_json(self, include_scalar)
Expand All @@ -755,7 +754,7 @@ def from_json(cls, js:Union[str,Dict[str,Any]]) -> BaseGraph[VT,ET]:
"""Converts the given .qgraph json string into a Graph.
Works with the output of :meth:`to_json`."""
from .jsonparser import json_to_graph
return json_to_graph(js)
return json_to_graph(js, backend=cls.backend)

@classmethod
def from_tikz(cls, tikz: str, warn_overlap:bool= True, fuse_overlap:bool = True, ignore_nonzx:bool = False) -> BaseGraph[VT,ET]:
Expand Down

0 comments on commit f36cbc5

Please sign in to comment.