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

Move VKCell state to TVCell #607

Merged
merged 2 commits into from
Feb 10, 2025
Merged

Move VKCell state to TVCell #607

merged 2 commits into from
Feb 10, 2025

Conversation

MatthewMckee4
Copy link
Member

@MatthewMckee4 MatthewMckee4 commented Feb 10, 2025

Summary by Sourcery

Move the cell state from VKCell to TVCell.

New Features:

  • Add shapes property to TVCell to manage shapes by layer.

Enhancements:

  • Store cell shapes and name within TVCell.

Copy link
Contributor

sourcery-ai bot commented Feb 10, 2025

Reviewer's Guide by Sourcery

This PR migrates state management from VKCell to TVCell by moving key attributes such as name and shapes to the base cell (TVCell). Implementation changes include refactoring property accessors to delegate to the underlying base cell, updating transformation and shape handling methods to use the new state storage, and minor adjustments to exception handling.

Updated Class Diagram for VKCell and TVCell State Management

classDiagram
    class BaseKCell {
      <<abstract>>
    }

    class TVCell {
      - bool _locked
      - dict<int, VShapes> _shapes
      - str|None _name
      + get locked() bool
      + get shapes() dict<int, VShapes>
      + set shapes(dict<int, VShapes>)
      + get name() str|None
      + set name(str|None)
      + lock()
    }

    class ProtoKCell {
      - TBaseCell _base
      + get name() str|None
      + set name(str)
      + dup() Self
    }

    class VKCell {
      <<concrete>>
      // Previously held its own _shapes and _name fields
      // Now delegates state management to its TVCell base
      + transform(trans: kdb.Trans|kdb.DTrans|kdb.ICplxTrans|kdb.DCplxTrans)
      + dup() VKCell
      + shapes(layer: int|kdb.LayerInfo) VShapes
    }

    class LockedError {
      + __init__(kcell: AnyKCell | BaseKCell)
    }

    TVCell --|> BaseKCell : extends
    VKCell --> TVCell : uses as base cell (state delegation)
    ProtoKCell --> TVCell : _base reference
    LockedError ..> TVCell : validates state
    LockedError ..> VKCell : validates state

    %% Note: The above diagram shows how state (name and shapes) management has been moved
    %% from VKCell to TVCell. ProtoKCell delegates its name property to its base cell, now TVCell.
Loading

File-Level Changes

Change Details Files
Refactor and delegate 'name' property management from VKCell to TVCell
  • Added abstract 'name' property (getter and setter) in the base KCell class to enforce implementation in subclasses.
  • Modified ProtoKCell to implement 'name' property by delegating to its _base attribute.
  • Updated TVCell to store 'name' in a private attribute and provide property access with lock checking.
  • Changed VKCell to no longer store its own '_name'; instead, it sets the 'name' on its base, TVCell.
src/kfactory/kcell.py
Update shape handling to delegate to TVCell's state
  • Modified shape transformation and retrieval methods to access shapes via the base cell's 'shapes' property.
  • Replaced direct access to the local '_shapes' dictionary with calls to the 'shapes()' method, ensuring consistent state management.
  • Updated instance insertion logic to iterate over shapes from the base cell instead of VKCell directly.
src/kfactory/kcell.py
src/kfactory/instance.py
Enhance LockedError exception type definition
  • Updated the LockedError constructor to accept both AnyKCell and BaseKCell types, ensuring compatibility with the new cell state structure.
src/kfactory/exceptions.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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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.

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.

Copy link

codecov bot commented Feb 10, 2025

Codecov Report

Attention: Patch coverage is 80.43478% with 9 lines in your changes missing coverage. Please review.

Project coverage is 66.01%. Comparing base (3a7fad2) to head (1a73e72).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/kfactory/kcell.py 79.06% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #607      +/-   ##
==========================================
+ Coverage   65.91%   66.01%   +0.09%     
==========================================
  Files          64       64              
  Lines        9644     9656      +12     
  Branches     1786     1787       +1     
==========================================
+ Hits         6357     6374      +17     
+ Misses       2762     2761       -1     
+ Partials      525      521       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastian-goeldi sebastian-goeldi added the enhancement New feature or request label Feb 10, 2025
@sebastian-goeldi sebastian-goeldi merged commit 19691f9 into main Feb 10, 2025
15 of 16 checks passed
@sebastian-goeldi sebastian-goeldi deleted the remove-vkcell-state branch February 10, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants