Skip to content

Commit

Permalink
Merge branch 'main' into exports
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMckee4 committed Jan 30, 2025
2 parents 1e92587 + 6168530 commit f5de0ae
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 121 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## New

- Add tests for Instance Ports [#593](https://github.com/gdsfactory/kfactory/pull/593)
- Add ruff bugbear rule [#592](https://github.com/gdsfactory/kfactory/pull/592)
- Add to_itype, to_dtype to dbu, um classes [#589](https://github.com/gdsfactory/kfactory/pull/589)
- Make vinstance connect take ProtoPort [#587](https://github.com/gdsfactory/kfactory/pull/587)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/notebooks/01_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class LayerInfos(kf.LayerInfos):
c = kf.cells.straight.straight(length=10, width=0.6, layer=LAYER.WG)
c3 = kf.KCell() # Create a new blank Cell
aref = c3.create_inst(
c, na=1, nb=3, a=kf.kdb.Vector(20000, 0), b=kf.kdb.Vector(0, 15000)
c, na=1, nb=3, a=(20000, 0), b=(0, 15000)
) # instance the Cell "c" 3 instances in it with a 3 rows, 1 columns array

c3.add_ports(aref.ports)
Expand Down
12 changes: 6 additions & 6 deletions src/kfactory/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def grid(
shape: tuple[int, int] | None = None,
align_x: Literal["origin", "xmin", "xmax", "center"] = "center",
align_y: Literal["origin", "ymin", "ymax", "center"] = "center",
rotation: Literal[0, 1, 2, 3] = 0,
rotation: float = 0,
mirror: bool = False,
) -> DInstanceGroup:
"""Create a grid of instances.
Expand Down Expand Up @@ -565,7 +565,7 @@ def grid(

insts = [
[
target.create_inst(kcell, kdb.ICplxTrans(1, rotation, mirror, 0, 0))
target.create_inst(kcell, kdb.DCplxTrans(1, rotation, mirror, 0, 0))
for kcell in array
]
for array in kcell_array
Expand Down Expand Up @@ -637,7 +637,7 @@ def grid(
_insts = [
None
if kcell is None
else target.create_inst(kcell, kdb.ICplxTrans(1, rotation, mirror, 0, 0))
else target.create_inst(kcell, kdb.DCplxTrans(1, rotation, mirror, 0, 0))
for kcell in _kcells
]

Expand Down Expand Up @@ -704,7 +704,7 @@ def flexgrid(
shape: tuple[int, int] | None = None,
align_x: Literal["origin", "xmin", "xmax", "center"] = "center",
align_y: Literal["origin", "ymin", "ymax", "center"] = "center",
rotation: Literal[0, 1, 2, 3] = 0,
rotation: float = 0,
mirror: bool = False,
) -> DInstanceGroup:
"""Create a grid of instances.
Expand Down Expand Up @@ -786,7 +786,7 @@ def flexgrid(
None
if kcell is None
else target.create_inst(
kcell, kdb.ICplxTrans(1, rotation, mirror, 0, 0)
kcell, kdb.DCplxTrans(1, rotation, mirror, 0, 0)
)
for kcell in array
]
Expand Down Expand Up @@ -867,7 +867,7 @@ def flexgrid(
_insts = [
None
if kcell is None
else target.create_inst(kcell, kdb.ICplxTrans(1, rotation, mirror, 0, 0))
else target.create_inst(kcell, kdb.DCplxTrans(1, rotation, mirror, 0, 0))
for kcell in _kcells
]

Expand Down
4 changes: 2 additions & 2 deletions src/kfactory/instance_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
class ProtoInstanceGroup(Generic[TUnit, TInstance], GeometricObject[TUnit]):
insts: list[TInstance]

def __init__(self, insts: Sequence[TInstance]) -> None:
def __init__(self, insts: Sequence[TInstance] | None = None) -> None:
"""Initialize the InstanceGroup."""
self.insts = list(insts)
self.insts = list(insts) if insts is not None else []

@property
def kcl(self) -> KCLayout:
Expand Down
6 changes: 3 additions & 3 deletions src/kfactory/instance_ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def bases(self) -> list[BasePort]:

def filter(
self,
angle: TUnit | None = None,
angle: int | None = None,
orientation: float | None = None,
layer: LayerEnum | int | None = None,
port_type: str | None = None,
Expand All @@ -111,7 +111,7 @@ def filter(
if port_type:
ports = filter_port_type(ports, port_type)
if angle is not None:
ports = filter_direction(ports, round(angle / 90))
ports = filter_direction(ports, angle)
if orientation is not None:
ports = filter_orientation(ports, orientation)
return list(ports)
Expand Down Expand Up @@ -355,7 +355,7 @@ def cell_ports(self) -> DPorts:

def filter(
self,
angle: float | None = None,
angle: int | None = None,
orientation: float | None = None,
layer: LayerEnum | int | None = None,
port_type: str | None = None,
Expand Down
Loading

0 comments on commit f5de0ae

Please sign in to comment.