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

Possibility of specifying offset in add_fiber_array #2543

Merged
merged 1 commit into from Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions gdsfactory/routing/add_fiber_array.py
Expand Up @@ -18,6 +18,7 @@
ComponentSpec,
ComponentSpecOrList,
CrossSectionSpec,
Floats,
LayerSpec,
Literal,
)
Expand All @@ -37,6 +38,7 @@
dev_id: str | None = None,
text: ComponentSpec | None = None,
id_placement: Literal[AnchorSubset] = "center",
id_placement_offset: Floats = (0, 0),
**kwargs,
) -> Component:
"""Returns component with south routes and grating_couplers.
Expand Down Expand Up @@ -203,7 +205,10 @@
lab = component_new << text(text=dev_id, justify="center")
xs = [r.x for r in io_gratings_lines[0]]
ys = [r.y for r in io_gratings_lines[0]]
lab.center = (np.average(xs), ys[0])
lab.center = (

Check warning on line 208 in gdsfactory/routing/add_fiber_array.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/routing/add_fiber_array.py#L208

Added line #L208 was not covered by tests
np.average(xs) + id_placement_offset[0],
ys[0] + +id_placement_offset[1],
)
elif id_placement == "r":
lab = component_new << text(text=dev_id, justify="left")
xmax = [r.xmax for r in io_gratings_lines[0]]
Expand All @@ -213,8 +218,8 @@
r.xmax for r in io_gratings_lines[-1] + io_gratings_lines[-2]
]
ys = [r.y for r in io_gratings_lines[0]]
lab.xmin = np.max(xmax) + 20
lab.y = ys[0]
lab.xmin = np.max(xmax) + 20 + id_placement_offset[0]
lab.y = ys[0] + id_placement_offset[1]

Check warning on line 222 in gdsfactory/routing/add_fiber_array.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/routing/add_fiber_array.py#L221-L222

Added lines #L221 - L222 were not covered by tests
elif id_placement == "l":
lab = component_new << text(text=dev_id, justify="right")
xmin = [r.xmin for r in io_gratings_lines[0]]
Expand All @@ -224,13 +229,16 @@
r.xmin for r in io_gratings_lines[-1] + io_gratings_lines[-2]
]
ys = [r.y for r in io_gratings_lines[0]]
lab.xmax = np.min(xmin) - 20
lab.y = ys[0]
lab.xmax = np.min(xmin) - 20 + id_placement_offset[0]
lab.y = ys[0] + id_placement_offset[1]

Check warning on line 233 in gdsfactory/routing/add_fiber_array.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/routing/add_fiber_array.py#L232-L233

Added lines #L232 - L233 were not covered by tests
elif id_placement == "s":
lab = component_new << text(text=dev_id, justify="center")
xs = [r.x for r in io_gratings_lines[0]]
ymins = [r.ymin for r in io_gratings_lines[0]]
lab.center = (np.average(xs), np.min(ymins) - 20)
lab.center = (

Check warning on line 238 in gdsfactory/routing/add_fiber_array.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/routing/add_fiber_array.py#L238

Added line #L238 was not covered by tests
np.average(xs) + id_placement_offset[0],
np.min(ymins) - 20 + id_placement_offset[1],
)

return component_new

Expand Down