Fix extrusion layer handling in MEOW class by using layer tuples#668
Merged
joamatab merged 1 commit intogdsfactory:mainfrom Jan 30, 2026
Merged
Fix extrusion layer handling in MEOW class by using layer tuples#668joamatab merged 1 commit intogdsfactory:mainfrom
joamatab merged 1 commit intogdsfactory:mainfrom
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors 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 handlingclassDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
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 bothderived_layerandlayershare a.layerattribute; 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 checkingif 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Bug Fixes: