Skip to content

feat(meshwell): check if mesh order is defined in LayerLevel.info#681

Open
David-GERARD wants to merge 1 commit intogdsfactory:mainfrom
David-GERARD:main
Open

feat(meshwell): check if mesh order is defined in LayerLevel.info#681
David-GERARD wants to merge 1 commit intogdsfactory:mainfrom
David-GERARD:main

Conversation

@David-GERARD
Copy link

@David-GERARD David-GERARD commented Mar 6, 2026

In the cspdk's LayerStack, the mesh order is defined in LayerLevel.info["mesh_order"], meaning that LayerLevel.mesh_order will default to 3 for every layer.

This PR thus adds a check in gplugins/meshwell/get_meshwell_cross_section.get_meshwell_cross_section() which first verifies if LayerLevel.info["mesh_order"] exists, if so uses it as the mesh_order, and defaulting to LayerLevel.info["mesh_order"] otherwise.

Summary by Sourcery

Bug Fixes:

  • Ensure meshwell cross section generation respects mesh order values defined in LayerLevel.info when present.

@David-GERARD David-GERARD requested a review from joamatab as a code owner March 6, 2026 10:23
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Update meshwell cross-section generation to respect per-layer mesh order defined in LayerLevel.info["mesh_order"] when available, falling back to the LayerLevel.mesh_order default otherwise.

Sequence diagram for mesh_order handling in get_meshwell_cross_section

sequenceDiagram
    participant Caller
    participant get_meshwell_cross_section
    participant layer_level
    participant PolySurface

    Caller->>get_meshwell_cross_section: call(...)
    get_meshwell_cross_section->>layer_level: access info
    alt info exists and contains mesh_order
        get_meshwell_cross_section->>get_meshwell_cross_section: mesh_order = layer_level.info["mesh_order"]
    else info missing or no mesh_order
        get_meshwell_cross_section->>layer_level: access mesh_order
        get_meshwell_cross_section->>get_meshwell_cross_section: mesh_order = layer_level.mesh_order
    end
    get_meshwell_cross_section->>PolySurface: instantiate(polygons, physical_name, mesh_order, mesh_bool=True, additive=False)
    PolySurface-->>get_meshwell_cross_section: instance
    get_meshwell_cross_section-->>Caller: return PolySurface
Loading

File-Level Changes

Change Details Files
Use mesh_order from LayerLevel.info when present, otherwise fall back to LayerLevel.mesh_order for PolySurface creation.
  • Introduce logic to check if layer_level.info exists and contains a "mesh_order" key.
  • Set mesh_order from layer_level.info["mesh_order"] when available, otherwise use layer_level.mesh_order.
  • Pass the computed mesh_order variable into the PolySurface constructor instead of using layer_level.mesh_order directly.
gplugins/meshwell/get_meshwell_cross_section.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 left some high level feedback:

  • Consider guarding the layer_level.info access with a type check (e.g., ensuring it's a mapping) or using getattr/get to avoid unexpected attribute/type errors if info is not a dict-like object.
  • You can simplify the mesh_order logic by using something like mesh_order = getattr(getattr(layer_level, 'info', None) or {}, 'get', lambda *a, **k: None)('mesh_order', layer_level.mesh_order) or a small helper function, which keeps the selection logic concise and reusable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding the `layer_level.info` access with a type check (e.g., ensuring it's a mapping) or using `getattr`/`get` to avoid unexpected attribute/type errors if `info` is not a dict-like object.
- You can simplify the mesh_order logic by using something like `mesh_order = getattr(getattr(layer_level, 'info', None) or {}, 'get', lambda *a, **k: None)('mesh_order', layer_level.mesh_order)` or a small helper function, which keeps the selection logic concise and reusable.

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.

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.

1 participant