Skip to article frontmatterSkip to article content

8 to 9

8 to 9

Due to the recent release of KFactory v1.0.0, we have had to make some small changes to the API of the following classes:

  • Component
  • Port
  • ComponentReference
  • ComponentReferences

GDSFactory v9 is not a big change but it makes ports and instance units consistent with each other.

Main changes

Note the migration changes:

  • port.dangle has been renamed to port.orientation
    • port.angle represents the angle 90 degrees multiples.
    • port.orientation represents the angle in degrees.
  • CHECK_INSTANCES has been renamed to CheckInstances
    • Most often used in the @cell decorator.
  • Port(..., layer: tuple[int, int]) has been replaced with Port(..., layer: int)
    • layer now represents the layer index in the KLayout layer stack.
    • To update your code you can do Port(..., layer=gf.kcl.layout.layer(*layer))
    • We also recommend just using Component.add_port, with which you can specify the layer as tuple.
  • Most of the d prefix attributes and functions can now be used without the d prefix.
  • ComponentReference.parent has been removed, you should use ComponentReference.cell instead.
  • ComponentReference.info has been removed, you should use ComponentReference.cell.info instead.
import gdsfactory as gf

c = gf.components.straight(length=10)
c.pprint_ports()
Loading...
print('port orientation in degrees', c.ports['o2'].orientation)
print('port x in um', c.ports['o2'].x)
print('port dx in um (decimal)', c.ports['o2'].dx)
print('port ix in integer (database units)', c.ports['o2'].ix)
port orientation in degrees 0.0
port x in um 10.0
port dx in um (decimal) 10.0
port ix in integer (database units) 10000
c = gf.Component()
ref = c << gf.c.straight()
ref.xmin = 10
print('reference x in um', ref.x)
print('reference dx in um (decimal)', ref.dx)
print('reference ix in integer (database units)', ref.ix)
reference x in um 15.0
reference dx in um (decimal) 15.0
reference ix in integer (database units) 15000
c
<Figure size 800x600 with 1 Axes>