Skip to content

Conversation

@joamatab
Copy link
Contributor

@joamatab joamatab commented Jan 4, 2026

Summary by Sourcery

Align Elmer capacitive simulation helper with updated component and meshing APIs to resolve runtime issues.

Bug Fixes:

  • Use the component ports attribute instead of get_ports() when deriving ground layers for Elmer boundary conditions.
  • Update mesh prism generation to match the current get_meshwell_prisms signature by dropping obsolete parameters.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the Elmer capacitive simulation helper to use the new prism mesh generation signature and the updated component ports API when deriving ground layers, removing now-invalid parameters and attributes.

Class diagram for updated Elmer capacitance helper dependencies

classDiagram
    class Component {
        +ports list~Port~
    }

    class Port {
        +layer int
    }

    class LayerStack {
        +layers dict~str,Layer~
    }

    class Layer {
        +layer int
    }

    class MeshwellPrismGenerator {
        +get_meshwell_prisms(component Component, layer_stack LayerStack) list~Prism~
    }

    class Prism {
    }

    class ElmerCapacitanceHelper {
        +run_capacitive_simulation_elmer(component Component, layer_stack LayerStack, simulation_folder Path, filename str, n_processes int) None
    }

    ElmerCapacitanceHelper --> Component
    ElmerCapacitanceHelper --> LayerStack
    ElmerCapacitanceHelper --> MeshwellPrismGenerator
    Component "1" --> "many" Port
    LayerStack "1" --> "many" Layer
    MeshwellPrismGenerator --> Prism
    Port --> Layer
Loading

File-Level Changes

Change Details Files
Update prism mesh generation call to match the new get_meshwell_prisms API.
  • Remove explicit mesh type parameter now that the prism generator infers dimensionality internally.
  • Stop passing a filename path into the prism generator, implying mesh output is handled elsewhere or defaults are used.
  • Remove the n_threads argument, relying on the function’s internal concurrency behavior or defaults.
gplugins/elmer/get_capacitance.py
Switch from the deprecated get_ports() method to direct ports attribute access when computing ground layers.
  • Iterate over component.ports instead of component.get_ports() when collecting port layers.
  • Preserve the existing logic that maps port layers to layer_stack layers and filters to metal layers.
gplugins/elmer/get_capacitance.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

@github-actions github-actions bot added the bug Something isn't working label Jan 4, 2026
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 get_meshwell_prisms call no longer passes filename or n_threads; if the mesh output location or parallelism is still important for performance or reproducibility, consider explicitly configuring these via the updated API rather than relying on defaults.
  • Switching from component.get_ports() to component.ports changes the dependency on the component API; ensure component.ports is guaranteed to return the same type/structure (e.g., ordered, filtered to relevant ports) or add a small adapter if normalization is needed here.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `get_meshwell_prisms` call no longer passes `filename` or `n_threads`; if the mesh output location or parallelism is still important for performance or reproducibility, consider explicitly configuring these via the updated API rather than relying on defaults.
- Switching from `component.get_ports()` to `component.ports` changes the dependency on the component API; ensure `component.ports` is guaranteed to return the same type/structure (e.g., ordered, filtered to relevant ports) or add a small adapter if normalization is needed here.

## Individual Comments

### Comment 1
<location> `gplugins/elmer/get_capacitance.py:263` </location>
<code_context>
     ground_layers = {
         next(k for k, v in layer_stack.layers.items() if v.layer == port.layer)
-        for port in component.get_ports()
+        for port in component.ports
     }  # ports allowed only on metal
     metal_surfaces = [
</code_context>

<issue_to_address>
**issue (bug_risk):** Iterating over `component.ports` likely yields keys, not Port objects, which will break `port.layer` access.

If `component.ports` is a mapping (name -> Port), iterating over it returns names, so `port.layer` will raise at runtime. To match the original `get_ports()` behavior of yielding Port objects, iterate over the values instead, e.g. `for port in component.ports.values()` (or the equivalent for this component type).
</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.

@joamatab joamatab enabled auto-merge January 4, 2026 21:05
@joamatab joamatab disabled auto-merge January 4, 2026 22:31
@joamatab joamatab merged commit f6d70cc into main Jan 4, 2026
16 of 17 checks passed
@joamatab joamatab deleted the fix_elmer branch January 4, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants