quantcore_circuits.design.pyscript¶
design.json → a readable Python script that rebuilds the same design with the Designer API.
qcc design to-python DESIGN -o design.py (the KLayout plugin’s Design ▸ Save as Python script) writes the script;
running it writes the design.json again (python design.py or %run design.py) and leaves the live
Designer as d so the chip can be continued as code.
The script is checked before it is returned: it is executed here and the design it builds must have the same
design_hash as the source. What the Designer calls cannot say (a static cell’s ports, explicit nets, another
chip cell, a coupling’s fem flag, a waypoint’s corner radius, …) is written for that one entry as a plain
d.data[...] = {...} assignment with a comment, so the round trip never silently drops anything.
Exceptions¶
The generated script did not rebuild the same design. |
Functions¶
|
The script text for |
|
A Python literal for JSON-like |
|
Module Contents¶
- exception quantcore_circuits.design.pyscript.RoundTripError¶
Bases:
RuntimeErrorThe generated script did not rebuild the same design.
- quantcore_circuits.design.pyscript.design_to_python(source, check: bool = True) str¶
The script text for
source(a design file, dict orDesign). Withcheck(default) the script is executed and must rebuild a design with the samedesign_hash(elseRoundTripError); an entry the Designer rejects or rebuilds differently is written as plain data.
- quantcore_circuits.design.pyscript.lit(value, indent: int = 0, width: int = _WIDTH) str¶
A Python literal for JSON-like
value: one line when it fits, else one entry per line.
- quantcore_circuits.design.pyscript.write_python(source, out: str | pathlib.Path, check: bool = True) pathlib.Path¶