(kernel, *args)
| 10 | |
| 11 | |
| 12 | def getSVGstring(kernel, *args): |
| 13 | from subprocess import check_output, STDOUT |
| 14 | from tempfile import TemporaryDirectory |
| 15 | |
| 16 | latex_string = cudaq.draw("latex", kernel, *args) |
| 17 | with TemporaryDirectory() as tmpdirname: |
| 18 | with open(tmpdirname + "/cudaq-trace.tex", "w") as f: |
| 19 | f.write(latex_string) |
| 20 | # this needs `latex` and `quantikz` to be installed, e.g. through `apt install texlive-latex-extra` |
| 21 | check_output(["latex", "cudaq-trace"], cwd=tmpdirname, stderr=STDOUT) |
| 22 | check_output(["dvisvgm", "cudaq-trace"], cwd=tmpdirname, stderr=STDOUT) |
| 23 | with open(tmpdirname + "/cudaq-trace.svg", "rb") as f: |
| 24 | return str(f.read(), encoding="utf-8") |
| 25 | |
| 26 | |
| 27 | def displaySVG(kernel, *args): |
no test coverage detected