-
Notifications
You must be signed in to change notification settings - Fork 54
Fix extrusion layer handling in MEOW class by using layer tuples #668
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
Conversation
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
|
There was a problem hiding this 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 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.
joamatab
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Fiodar!
Summary by Sourcery
Bug Fixes: