Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default args for DPort center and orientation #601

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/kfactory/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,8 @@ def __init__(
port_type: str = "optical",
trans: kdb.Trans | str | None = None,
dcplx_trans: kdb.DCplxTrans | str | None = None,
orientation: float | None = None,
center: tuple[float, float] | None = None,
orientation: float = 0,
center: tuple[float, float] = (0, 0),
mirror_x: bool = False,
port: ProtoPort[Any] | None = None,
kcl: KCLayout | None = None,
Expand Down Expand Up @@ -1002,7 +1002,7 @@ def __init__(
info=info_,
port_type=port_type,
)
elif orientation is not None:
else:
assert center is not None
dcplx_trans_ = kdb.DCplxTrans.R0
self._base = BasePort(
Expand All @@ -1016,8 +1016,6 @@ def __init__(
self.center = center
self.orientation = orientation
self.mirror_x = mirror_x
else:
raise ValueError("Missing port parameters given")

def copy(
self,
Expand Down
3 changes: 0 additions & 3 deletions tests/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ def test_dport_invalid_init() -> None:
with pytest.raises(ValueError):
kf.DPort(name="o1", width=10, center=(1000, 1000), orientation=90)

with pytest.raises(ValueError):
kf.DPort(name="o1", layer=1, width=10)

with pytest.raises(ValueError, match="Width must be greater than 0."):
kf.DPort(name="o1", width=-10, layer=1, center=(1000, 1000), orientation=90)

Expand Down
Loading