Python Library

Examples

Runnable examples that generate GDS outputs.

pypkg/laylight-examples currently provides two runnable examples:

  • straight_waveguide.gds
  • ring_coupler.gds

Generation command, run from the repository root:

uv run --package laylight-examples laylight-examples --output-dir build/examples

If the workspace dependencies are not installed yet, you can also run:

PYTHONPATH=pypkg/laylight:pypkg/laylight-examples python -m laylight_examples --output-dir build/examples

Example Structure

The example code follows a simple pattern:

  1. Create a layout, its top cell and the technology with new_layout()
  2. Instantiate a device from laylight.structure
  3. Place it with laylight.Placer(device).into(top)
  4. Call layout.write("out.gds"), which compiles the layout's IR with the laylight command line

This pattern is a good base for more complex composition examples, such as:

  • Multi-segment waveguide routing
  • MZI structures
  • Tunable devices with heaters
  • Probe pad and routing examples

On this page