File tree Expand file tree Collapse file tree
cirq-core/cirq/contrib/svg Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5+ import re
6+
57import IPython .display
68import numpy as np
79import pytest
@@ -24,9 +26,16 @@ def test_svg() -> None:
2426 cirq .MatrixGate (np .eye (2 )).on (a ),
2527 )
2628 )
27- assert '?' in svg_text
2829 assert '<svg' in svg_text
2930 assert '</svg>' in svg_text
31+ # check text rendering fontsize
32+ # single letter X gate rendered at 18px
33+ assert re .search (r'<text[^>]*\bfont-size="18px[^>]*>X</text>' , svg_text )
34+ # multi-letter PhasedXPowGate rendered at 14px
35+ phx_literal = re .escape ("PhX(0.456)^0.123" )
36+ assert re .search (rf'<text[^>]*\bfont-size="14px[^>]*>{ phx_literal } </text>' , svg_text )
37+ # MatrixGate replaced with "?" rendered at 18px
38+ assert re .search (r'<text[^>]*\bfont-size="18px[^>]*>[?]</text>' , svg_text )
3039
3140
3241def test_svg_noise () -> None :
You can’t perform that action at this time.
0 commit comments