Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/circuit renderer #1614

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pytket/docs/display.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ from pytket.circuit.display import get_circuit_renderer

circuit_renderer = get_circuit_renderer() # Instantiate a circuit renderer
circuit_renderer.set_render_options(zx_style=True) # Configure render options
circuit_renderer.condense_c_bits = False # You can also set the properties on the instance directly
circuit_renderer.config.render_options.condense_c_bits = False # You can also set the properties on the instance directly
circuit_renderer.config.min_height = "300px" # Change the display height
print("Render options:")
print(circuit_renderer.get_render_options()) # View currently set render options

circuit_renderer.min_height = "300px" # Change the display height
circuit_renderer.save_render_options() # Export current render options to the pytket config

circ = Circuit(2,2) # Define Circuit
circ.H(0).H(1).CX(0, 1).Rz(0.4, 1).CX(0, 1).H(0).H(1).measure_all()
Expand Down
6 changes: 4 additions & 2 deletions pytket/pytket/circuit/display/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ class CircuitDisplayConfig(PytketExtConfig):

@classmethod
def from_extension_dict(cls, ext_dict: dict[str, Any]) -> "CircuitDisplayConfig":
min_h = ext_dict.get("min_height")
min_w = ext_dict.get("min_width")
return CircuitDisplayConfig(
min_height=str(ext_dict.get("min_height")),
min_width=str(ext_dict.get("min_width")),
min_height=str(min_h) if min_h is not None else "400px",
min_width=str(min_w) if min_w is not None else "500px",
orient=ext_dict.get("orient"),
render_options=RenderOptions(
**(ext_dict["render_options"] if "render_options" in ext_dict else {})
Expand Down
Loading