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

partials don't work well with cell decorator #457

Closed
joamatab opened this issue Aug 23, 2024 · 0 comments
Closed

partials don't work well with cell decorator #457

joamatab opened this issue Aug 23, 2024 · 0 comments

Comments

@joamatab
Copy link
Collaborator

joamatab commented Aug 23, 2024

import kfactory as kf
from functools import partial


def add_label(c, text="label", layer=1, x=0, y=0):
    trans = kf.kdb.DTrans(0, False, x, y)
    c.shapes(layer).insert(kf.kdb.DText(text, trans))
    return c


@kf.cell
def straight_with_label(add_label=None, width=1, length=10, layer=1):
    c = kf.KCell()
    c << kf.cells.straight.straight(width=width, length=length, layer=layer)
    if add_label:
        c = add_label(c)
    return c


add_label1 = partial(add_label, text="label1", layer=2, x=0, y=0)
add_label2 = partial(add_label, text="label1", layer=2, x=0, y=0)

straight_with_label1 = partial(straight_with_label, add_label=add_label1)
straight_with_label2 = partial(straight_with_label, add_label=add_label2)


c = kf.KCell()
c << straight_with_label1()
c << straight_with_label2()
c.show()

will raise an error

RuntimeError: The following cell name(s) are used for more than one cell - can't write this layout:
  straight_with_label_ALFadd_label_M__main___STlabel1_L2_X0_Y0_W1_L10_L1 in Cell.write

inspired by gdsfactory/gdsfactory#3141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant