Skip to content

Conversation

@FiodarM
Copy link

@FiodarM FiodarM commented Jan 29, 2026

Summary by Sourcery

Bug Fixes:

  • Correct extrusion mapping to use the derived or base layer tuple, ensuring extrusions are keyed consistently with GDS layer definitions.

@FiodarM FiodarM requested a review from joamatab as a code owner January 29, 2026 19:56
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the MEOW extrusion layer mapping to key extrusions by normalized layer tuples derived from either a layer’s derived_layer or its base layer, ensuring consistent handling of layers in the LayerStack-to-extrusion conversion.

Class diagram for updated MEOW extrusion layer handling

classDiagram
    class MeowEme {
        LayerStack layer_stack
        dict layer_stack_to_extrusion()
        MeowMaterial gf_material_to_meow_material(Material material)
    }

    class LayerStack {
        dict~int,Layer~ layers
    }

    class Layer {
        int layer
        Layer derived_layer
        Material material
    }

    class GdsExtrusionRule {
        MeowMaterial material
    }

    MeowEme --> LayerStack : uses
    LayerStack --> Layer : contains
    MeowEme --> GdsExtrusionRule : creates
    Layer --> Layer : derived_layer
Loading

File-Level Changes

Change Details Files
Normalize extrusion mapping keys to use layer tuples derived from either derived_layer or base layer.
  • Introduce layer_tuple derived via gf.get_layer_tuple from the effective layer (derived_layer if present, otherwise layer.layer)
  • Replace use of layer.layer as the dictionary key with the normalized layer_tuple
  • Adjust creation and appending of extrusion lists to be indexed by layer_tuple instead of layer.layer
gplugins/meow/meow_eme.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new key construction gf.get_layer_tuple((layer.derived_layer or layer.layer).layer) assumes both derived_layer and layer share a .layer attribute; consider guarding this with clearer typing or intermediate variables so it’s obvious what types are expected and to avoid attribute errors if the structure changes.
  • You can simplify the dictionary initialization logic by using extrusions.setdefault(layer_tuple, []).append(...) instead of explicitly checking if layer_tuple not in extrusions.keys().
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new key construction `gf.get_layer_tuple((layer.derived_layer or layer.layer).layer)` assumes both `derived_layer` and `layer` share a `.layer` attribute; consider guarding this with clearer typing or intermediate variables so it’s obvious what types are expected and to avoid attribute errors if the structure changes.
- You can simplify the dictionary initialization logic by using `extrusions.setdefault(layer_tuple, []).append(...)` instead of explicitly checking `if layer_tuple not in extrusions.keys()`.

## Individual Comments

### Comment 1
<location> `gplugins/meow/meow_eme.py:289` </location>
<code_context>
-            if layer.layer not in extrusions.keys():
-                extrusions[layer.layer] = []
-            extrusions[layer.layer].append(
+            layer_tuple = gf.get_layer_tuple((layer.derived_layer or layer.layer).layer)
+            if layer_tuple not in extrusions.keys():
+                extrusions[layer_tuple] = []
</code_context>

<issue_to_address>
**issue:** Double-check the `.layer` attribute access before `gf.get_layer_tuple`, as it may already accept the layer spec directly.

If `layer.derived_layer` / `layer.layer` is already a valid layer spec for `gf.get_layer_tuple` (int, tuple, or `Layer`-like), chaining `.layer` may be incorrect or overly brittle. Consider passing `layer.derived_layer or layer.layer` directly to `gf.get_layer_tuple`, unless you have a strict guarantee that the extra `.layer` is always valid and non-`None`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@joamatab joamatab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Fiodar!

@joamatab joamatab merged commit 63607a3 into gdsfactory:main Jan 30, 2026
13 of 14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants