Skip to content

Crash when attempting to instantiate via_stack with metal_level==2 #30

@jreeve-nl

Description

@jreeve-nl

Describe the bug
In the existing code for handling a via_stack than spans metal2 or above, a subscriptable type is expected of m_enc which is the overhang of the metal compared to the contact.

To Reproduce

if __name__ == "__main__":
    
    PDK.activate()
    c = gf.Component()
    nfet_lv_m6 = c << gf180mcu.cells.via_stack(
        x_range=(0, 1),
        y_range=(0, 1),
        base_layer=PDK.get_layer("comp"),
        metal_level=2,
        li_enc_dir="H",
    )

    gdspath = c.write_gds()
    gf.show(gdspath)
Traceback (most recent call last):
  File "/home/jsr/dev/kiwi-devices/gf-fundamental-blocks/gdsfactory/./5t_ota_simple.py", line 131, in <module>
    nfet_lv_m6 = c << gf180mcu.cells.via_stack(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jsr/dev-ext/gdsfactory/gdsfactory/.venv/lib/python3.12/site-packages/kfactory/layout.py", line 1029, in func
    return wrapper_autocell(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jsr/dev-ext/gdsfactory/gdsfactory/.venv/lib/python3.12/site-packages/kfactory/decorators.py", line 549, in __call__
    return self._f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jsr/dev-ext/gdsfactory/gdsfactory/.venv/lib/python3.12/site-packages/kfactory/decorators.py", line 523, in wrapper_autocell
    cell_ = wrapped_cell(**params)
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jsr/dev-ext/gdsfactory/gdsfactory/.venv/lib/python3.12/site-packages/cachetools/_cached.py", line 173, in wrapper
    v = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jsr/dev-ext/gdsfactory/gdsfactory/.venv/lib/python3.12/site-packages/kfactory/decorators.py", line 408, in wrapped_cell
    cell = f(**params)  # type: ignore[call-arg]
           ^^^^^^^^^^^
  File "/home/jsr/dev-ext/gdsfactory/gf180mcu-kiwi-devices/gf180mcu/cells/via_generator.py", line 153, in via_stack
    if (via1.dxmax - via1.dxmin + 2 * m_enc[0]) < (
                                      ~~~~~^^^
TypeError: 'float' object is not subscriptable

Expected behavior
Draw the via stack with output on metal layers 1 and 2.

Suggested fix
I have created a PR that alters the via_stack argument type of m_enc to be a tuple containing the x and y overhang of the contact.

Environment (please complete the following information):

  • [ O] I have reviewed the documentation, discussions and issues and found no relevant solution.
  • [ O] I understand that this is an open-source project, and maintainers may not have the resources to address every issue. I am prepared to contribute by fixing the issue myself or hiring someone to do so, if needed, and accept that the issue may not be resolved otherwise.
  • [ O

] I am using the latest version of GDSFactory, with Python 3.11, 3.12, or 3.13.

Please provide the output for the following code:

import sys
print(sys.version)
print(sys.executable)

import gdsfactory as gf
gf.config.print_version_plugins()
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions