Skip to content
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

Fix X SPICE element parsing for Calibre-style model names #528

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

nikosavola
Copy link
Member

@nikosavola nikosavola commented Dec 31, 2024

Summary by Sourcery

Bug Fixes:

  • Fixed an issue where Calibre-style model names (e.g., $[model_name]) were not parsed correctly for elements other than resistors and capacitors.

@nikosavola nikosavola self-assigned this Dec 31, 2024
@nikosavola nikosavola requested a review from joamatab December 31, 2024 14:55
Copy link
Contributor

sourcery-ai bot commented Dec 31, 2024

Reviewer's Guide by Sourcery

This pull request fixes the parsing of X SPICE elements with Calibre-style model names. Previously, the code would remove brackets around model names for all elements, including X elements. This caused issues because X elements use a different syntax for model names. The fix is to only remove the brackets for resistors and capacitors.

Sequence diagram for SPICE element parsing with Calibre-style model names

sequenceDiagram
    participant Parser as SPICE Parser
    participant Regex as Regex Engine
    participant Element as Element Handler

    Parser->>Element: parse_element(s, element)
    alt element != 'X'
        Element->>Regex: Remove brackets from model name
        Regex-->>Element: Processed string
    else element == 'X'
        Note over Element: Keep original model name format
    end
    Element-->>Parser: ParseElementData
Loading

Class diagram showing the modified parse_element method

classDiagram
    class NetlistSpiceReader {
        +parse_element(s: str, element: str) ParseElementData
    }
    note for NetlistSpiceReader "Modified to preserve X element model names"

    class ParseElementData {
    }

    NetlistSpiceReader ..> ParseElementData : creates
Loading

File-Level Changes

Change Details Files
Conditional removal of brackets around model names
  • Added a conditional statement to only remove brackets from resistor and capacitor element model names when parsing SPICE netlists.
  • The condition checks that the element type is not "X" before removing the brackets around the model name from the input string 's'.
gplugins/klayout/netlist_spice_reader.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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 Dec 31, 2024
@nikosavola nikosavola marked this pull request as ready for review December 31, 2024 14:56
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.

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

@nikosavola nikosavola enabled auto-merge December 31, 2024 14:56
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.

awesome! thank you Niko!

@nikosavola nikosavola merged commit 2c5706c into main Jan 1, 2025
15 of 19 checks passed
@nikosavola nikosavola deleted the fix-variant-for-non-x-spice branch January 1, 2025 03:25
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