Skip to content

Commit

Permalink
Fix retrieval of port centers
Browse files Browse the repository at this point in the history
  • Loading branch information
yaugenst committed Oct 13, 2023
1 parent f06d2bc commit ff1d48c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions gplugins/common/base_models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,23 @@ def port_centers(self) -> tuple[tuple[float, float, float], ...]:
@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))
for idx, name in enumerate(self.gds_ports.keys()):
print(name, self.port_centers[idx])

def get_port_center(self, port: gf.Port) -> tuple[float, float, float]:
layer_czs = np.array(tuple(self.layer_centers.values()))
layers = self.get_layer_names_from_index(port.layer)
return (
*port.center,
np.mean(
[
layer_czs[idx, 2]
for idx, layer in enumerate(self.geometry_layers.values())
if layer.layer == port.layer
]
),
np.mean([self.get_layer_center(layer)[2] for layer in layers]),
)

def get_layer_names_from_index(
self, layer_index: tuple[int, int]
) -> tuple[str, ...]:
return tuple(
k
for k, v in self.layer_stack.layers.items()
if tuple(v.layer) == layer_index
)

def get_layer_bbox(
Expand Down

0 comments on commit ff1d48c

Please sign in to comment.