Coverage for qpdk / samples / sample6.py: 100%

9 statements  

« 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# --- 

10 

11# %% [markdown] 

12# # Cross-Section Sample 

13# 

14# This sample demonstrates creating custom cross-sections with multiple layers and offsets. 

15 

16# %% 

17import gdsfactory as gf 

18 

19# %% [markdown] 

20# ## Sample Function 

21# 

22# Creates a component with a path using a custom cross-section that includes multiple layers with different widths and offsets. 

23 

24 

25# %% 

26@gf.cell 

27def sample6_cross_section(): 

28 """Returns a component with a path made of different segments.""" 

29 p = gf.path.straight() 

30 

31 # Add a few "sections" to the cross-section 

32 s0 = gf.Section(width=1, offset=0, layer=(1, 0), port_names=("in", "out")) 

33 s1 = gf.Section(width=2, offset=2, layer=(2, 0)) 

34 s2 = gf.Section(width=2, offset=-2, layer=(2, 0)) 

35 x = gf.CrossSection(sections=(s0, s1, s2)) 

36 

37 return gf.path.extrude(p, cross_section=x)