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.

gdsfactory.typings#

Some of the type aliases have been removed, you can now use the following:

Moved from gdsfactory.typings to gdsfactory.cross_section:

  • MultiCrossSectionAngleSpec

  • CrossSectionFactory

  • CrossSectionSpec

Moved from gdsfactory.typings to gdsfactory.component:

  • AnyComponent

  • AnyComponentT

  • AnyComponentFactory

  • AnyComponentPostProcess

  • ComponentFactory

  • ComponentAllAngleFactory

  • ComponentFactoryDict

  • ComponentFactories

  • ComponentSpecOrList

  • CellSpec

Removed from gdsfactory.typings:

  • NameToFunctionDict

  • ComponentBaseFactory

import gdsfactory as gf

c = gf.components.straight(length=10)
c.pprint_ports()
┏━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ name  width  orientation  layer     center       port_type ┃
┡━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ o1   │ 0.5   │ 180.0       │ WG (1/0) │ (0.0, 0.0)  │ optical   │
│ o2   │ 0.5   │ 0.0         │ WG (1/0) │ (10.0, 0.0) │ optical   │
└──────┴───────┴─────────────┴──────────┴─────────────┴───────────┘
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
../_images/68d91491575a6f1a7abd0b6434b541c31470cfdc55cae29442015ddae5e4fdce.png