Skip to content

Commit

Permalink
use a _build_box method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjaskula-aws committed Dec 28, 2023
1 parent fbf4d83 commit c876b51
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/braket/circuits/box_drawing_circuit_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,32 @@ def _draw_symbol(
# We do not box when no gate is applied.
pass
else:
top_edge_symbol = "┴" if connection == "above" or connection == "both" else "─"
top = f"┌─{fill_symbol(top_edge_symbol, '─', len(symbol))}─┐"

bottom_edge_symbol = "┬" if connection == "below" or connection == "both" else "─"
bottom = f"└─{fill_symbol(bottom_edge_symbol, '─', len(symbol))}─┘"

symbol = f"┤ {symbol} ├"
top, symbol, bottom = BoxDrawingCircuitDiagram._build_box(symbol, connection)

output = fill_symbol(top, " ", symbols_width + 1) + "\n"
output += fill_symbol(symbol, "─", symbols_width + 1) + "\n"
output += fill_symbol(bottom, " ", symbols_width + 1) + "\n"
return output

@staticmethod
def _build_box(
symbol: str, connection: Literal["above, below, both, none"]
) -> tuple[str, str, str]:
fill_symbol = BoxDrawingCircuitDiagram._fill_symbol

top_edge_symbol = "┴" if connection == "above" or connection == "both" else "─"
top = f"┌─{fill_symbol(top_edge_symbol, '─', len(symbol))}─┐"

bottom_edge_symbol = "┬" if connection == "below" or connection == "both" else "─"
bottom = f"└─{fill_symbol(bottom_edge_symbol, '─', len(symbol))}─┘"

symbol = f"┤ {symbol} ├"
return top, symbol, bottom

@staticmethod
def _build_verbatim_box(
symbol: Literal["StartVerbatim", "EndVerbatim"],
connection: Literal["above, below, both, none"] = "none",
connection: Literal["above, below, both, none"],
) -> str:
top = ""
bottom = ""
Expand Down

0 comments on commit c876b51

Please sign in to comment.