-
Notifications
You must be signed in to change notification settings - Fork 66
fix: _stored_freqs in MicrowaveModeSolverMonitor #3005
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: _stored_freqs in MicrowaveModeSolverMonitor #3005
Conversation
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.
2 files reviewed, no comments
|
Does |
|
I guess I knew this would start causing issues. The complicated inheritance is not great. I was trying an approach like @weiliangjin2021 suggested, but I think a few more changes are required. One of them is that I think an approach that might work better is to break this diamond inheritance and use a mixin pattern. Then the I'll try to make a quick PR that you can include with your test. |
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
dmarek-flex
left a comment
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.
Think this is good, you can drop my commit after rebasing though
weiliangjin2021
left a comment
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.
Looks good!
thanks for the neat refactor @dmarek-flex ! |
This is a little bit silly: while
MicrowaveModeSolverDatais inheritedModeSolverData, which contains the correct_stored_freqs, it also is inherited fromMicrowaveModeData, which takes the priority and which is, in its turn, inherited fromModeData, with_stored_freqsincompatible withModeSolverData/MicrowaveModeSolverData.Greptile Overview
Greptile Summary
Fixes a Python Method Resolution Order (MRO) bug in
MicrowaveModeSolverMonitorwhere the_stored_freqsproperty was returning incorrect values due to inheritance priority.The Issue:
MicrowaveModeSolverMonitorinherits from bothMicrowaveModeMonitor(which inheritsModeMonitor) andModeSolverMonitorMicrowaveModeMonitor, which inherits_stored_freqsfromModeMonitor(returns all frequencies)ModeSolverMonitor._stored_freqscorrectly handles frequency reduction withinterp_specby callingmode_spec._sampling_freqs_mode_solver_dataMicrowaveModeSolverMonitorwas using the wrong implementation that ignoredinterp_specsettingsThe Fix:
_stored_freqsproperty override inMicrowaveModeSolverMonitorthat callsmode_spec._sampling_freqs_mode_solver_datainterp_specandreduce_dataflagsModeSolverMonitorandMicrowaveModeSolverMonitorbehavior (viarfparameter)Confidence Score: 5/5
ModeSolverMonitor._stored_freqslogic exactly. Comprehensive test coverage verifies the fix across multiple scenarios including edge cases.Important Files Changed
File Analysis
_stored_freqsproperty override to fix MRO inheritance issue with mode solver data storage_stored_freqsbehavior for both regular and microwave mode solver monitorsSequence Diagram
sequenceDiagram participant User participant MicrowaveModeSolverMonitor participant MicrowaveModeMonitor participant ModeMonitor participant ModeSolverMonitor Note over MicrowaveModeSolverMonitor: Class hierarchy: MicrowaveModeSolverMonitor(MicrowaveModeMonitor, ModeSolverMonitor) Note over MicrowaveModeMonitor: MicrowaveModeMonitor inherits from ModeMonitor Note over ModeMonitor: ModeMonitor._stored_freqs returns self.freqs (all frequencies) Note over ModeSolverMonitor: ModeSolverMonitor._stored_freqs calls mode_spec._sampling_freqs_mode_solver_data (reduced frequencies with interp_spec) User->>MicrowaveModeSolverMonitor: Access _stored_freqs property rect rgb(255, 200, 200) Note over MicrowaveModeSolverMonitor: BEFORE FIX: MRO looks up MicrowaveModeMonitor first MicrowaveModeSolverMonitor->>MicrowaveModeMonitor: Check for _stored_freqs MicrowaveModeMonitor->>ModeMonitor: Inherit _stored_freqs ModeMonitor-->>MicrowaveModeSolverMonitor: Returns self.freqs (WRONG - ignores interp_spec) end rect rgb(200, 255, 200) Note over MicrowaveModeSolverMonitor: AFTER FIX: Override _stored_freqs directly MicrowaveModeSolverMonitor->>MicrowaveModeSolverMonitor: Use own _stored_freqs MicrowaveModeSolverMonitor->>MicrowaveModeSolverMonitor: Call mode_spec._sampling_freqs_mode_solver_data MicrowaveModeSolverMonitor-->>User: Returns reduced frequencies (CORRECT - respects interp_spec) end