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

Rename gds_ports -> ports, fix port centers and remove port size calculation from base #183

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
24 changes: 12 additions & 12 deletions gplugins/common/base_models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def gds_component(self) -> GFComponent:
left=self.pad_xy_outer,
right=self.pad_xy_outer,
)
c.add_ports(self.gds_ports)
c.add_ports(self.ports)
c.copy_child_info(self.component)
return c

Expand All @@ -80,11 +80,13 @@ def _gds_bbox(self) -> tuple[tuple[float, float], tuple[float, float]]:
return tuple(map(tuple, bbox))

@cached_property
def gds_ports(self) -> dict[str, gf.Port]:
return {
n: p.move_polar_copy(self.extend_ports - self.port_offset, p.orientation)
for n, p in self.component.ports.items()
}
def ports(self) -> dict[str, gf.Port]:
return tuple(
p.move_polar_copy(
self.extend_ports + self.pad_xy_inner - self.port_offset, p.orientation
)
for p in self.component.ports.values()
)

@computed_field
@cached_property
Expand Down Expand Up @@ -173,14 +175,12 @@ def device_layers(self) -> tuple[str, ...]:
)

@cached_property
def port_centers(self) -> tuple[tuple[float, float, float], ...]:
return tuple(self.get_port_center(p) for p in self.gds_ports.values())
def port_names(self) -> tuple[str, ...]:
return tuple(p.name for p in self.ports)

@cached_property
def port_sizes(self):
# TODO calculate maximum port sizes from neighbors
for name, port in self.gds_ports.items():
print(name, self.port_center(port))
def port_centers(self) -> tuple[tuple[float, float, float], ...]:
return tuple(self.get_port_center(p) for p in self.ports)

def get_port_center(self, port: gf.Port) -> tuple[float, float, float]:
layer_czs = np.array(tuple(self.layer_centers.values()))
Expand Down