-
Notifications
You must be signed in to change notification settings - Fork 16
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
Update base_kcell to base and add locked setters #599
Conversation
Reviewer's Guide by SourceryThis PR refactors the code to replace the 'base_kcell' attribute with a more generic 'base' property across the codebase, while also adding locked setters for the locked property in multiple classes. The changes are implemented by renaming member variables and updating property accessors, setters, and constructors to use the new attribute, ensuring consistency in both internal logic and the public API. Additionally, the PR updates the call sites in layout handling and test files to align with these modifications. Updated Class Diagram for KCell Hierarchy (Class Diagram)classDiagram
%% Abstract base class for cells containing the new 'base' attribute and locked property with setter
class ProtoKCell {
<<abstract>>
- _base: TBaseCell
+ locked() : bool
+ locked(value: bool) : void
+ lock() : void
+ base() : TBaseCell
}
%% A concrete implementation that uses its own _locked attribute
class TVCell {
- _locked: bool
+ locked() : bool
+ locked(value: bool) : void
+ lock() : void
}
%% ProtoTKCell extends ProtoKCell and is used as a base for specific cell types
class ProtoTKCell {
<<abstract>>
+ __getitem__(key: int | str | None) : ProtoPort
+ dup() : Self
%% ... other methods ...
}
%% KCell: A concrete cell, user-facing with ports and instances
class KCell {
+ ports() : Ports
+ insts() : Instances
%% ... other methods ...
}
%% DKCell: Another concrete cell type for a different design, e.g., um cell
class DKCell {
+ ports() : DPorts
+ insts() : DInstances
%% ... other methods ...
}
%% TKCell represents the underlying cell structure that is now encapsulated in 'base'
class TKCell {
%% Represents the underlying cell properties like locked, info, settings, etc.
}
%% Relationships
ProtoKCell <|-- ProtoTKCell : extends
ProtoTKCell <|-- KCell : extends
ProtoTKCell <|-- DKCell : extends
TVCell ..|> ProtoKCell : implements
%% Composition: ProtoKCell holds a reference to a TKCell via 'base'
ProtoKCell o-- TKCell : base
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.
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.
if isinstance(inst, Instance): | ||
return Instance(self.kcl, self._base_kcell.kdb_cell.insert(inst.instance)) | ||
return Instance(self.kcl, self._base.kdb_cell.insert(inst.instance)) | ||
else: | ||
if not property_id: | ||
return Instance(self.kcl, self._base_kcell.kdb_cell.insert(inst)) | ||
return Instance(self.kcl, self._base.kdb_cell.insert(inst)) | ||
else: | ||
assert isinstance(inst, kdb.CellInstArray | kdb.DCellInstArray) | ||
return Instance( | ||
self.kcl, self._base_kcell.kdb_cell.insert(inst, property_id) | ||
) | ||
return Instance(self.kcl, self._base.kdb_cell.insert(inst, property_id)) |
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.
issue (code-quality): We've found these issues:
- Remove unnecessary else after guard condition (
remove-unnecessary-else
) - Swap if/else branches [×2] (
swap-if-else-branches
)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #599 +/- ##
==========================================
+ Coverage 65.85% 65.90% +0.04%
==========================================
Files 64 64
Lines 9636 9644 +8
Branches 1786 1786
==========================================
+ Hits 6346 6356 +10
- Misses 2766 2767 +1
+ Partials 524 521 -3 ☔ View full report in Codecov by Sentry. |
Summary by Sourcery
Rename the
_base_kcell
attribute to_base
and add a public setter for thelocked
property.Enhancements:
locked
property of KCells.Tests:
_base_kcell
to_base
.