Coverage for qpdk / samples / sample2.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-14 10:27 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-14 10:27 +0000
1# ---
2# jupyter:
3# jupytext:
4# text_representation:
5# extension: .py
6# format_name: percent
7# format_version: '1.3'
8# jupytext_version: 1.17.3
9# ---
11# %% [markdown]
12# # Write GDS with Remove Layers
13#
14# This sample demonstrates how to remove specific layers from a component after creation.
16# %%
17import gdsfactory as gf
19from qpdk import LAYER
21# %% [markdown]
22# ## Sample Function
23#
24# Creates a component with text and rectangles, then removes the etch layer to show layer manipulation.
27# %%
28@gf.cell
29def sample2_remove_layers() -> gf.Component:
30 """Returns a component with 'Hello world' text and a rectangle."""
31 c = gf.Component()
33 ref1 = c.add_ref(gf.components.rectangle(size=(10, 10), layer=LAYER.M1_ETCH))
34 ref2 = c.add_ref(gf.components.text("Hello", size=10, layer=LAYER.M1_DRAW))
35 ref3 = c.add_ref(gf.components.text("world", size=10, layer=LAYER.M1_DRAW))
36 ref1.xmax = ref2.xmin - 5
37 ref3.xmin = ref2.xmax + 2
38 c.flatten()
39 return c.remove_layers(layers=["M1_ETCH"])