-
Notifications
You must be signed in to change notification settings - Fork 66
improve performance of antenna metrics calculation #2852
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
4 files reviewed, 2 comments
Contributor
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
cec125b to
126a777
Compare
weiliangjin2021
approved these changes
Sep 30, 2025
daquinteroflex
approved these changes
Oct 1, 2025
Collaborator
daquinteroflex
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.
Nice! I really like how you've done this and separated the cached properties from the actual computation
ef74b3e to
deb7730
Compare
deb7730 to
8fd5516
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Small refactoring so that the TerminalComponentModelerData class caches some results that are needed repeatedly for antenna metrics calculations
Greptile Overview
Updated On: 2025-09-29 19:23:47 UTC
Summary
This PR introduces performance optimizations to the antenna metrics calculation by implementing caching mechanisms in the
TerminalComponentModelerDataclass. The key changes include:@cached_propertydecorators forport_voltage_currents,port_pseudo_waves, andport_power_wavesto cache expensive computationsterminal_construct_smatrixfunction now uses pre-computed cached wave amplitude data instead of recalculating it for each S-matrix construction_monitor_data_at_port_amplitudemethod now takes an additionala_raw_portparameter to avoid redundant calculationsThe caching strategy significantly reduces redundant calculations when multiple antenna metrics are computed, as the expensive port voltage/current and wave amplitude computations are now performed only once and reused across subsequent calls.
Confidence Score: 4/5
@cached_propertydecorator. The logic changes are minimal and mostly involve using pre-computed cached results instead of recalculating them. The test updates are appropriate and maintain existing functionality. Two minor typos were found in docstrings.Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant Client participant TerminalComponentModelerData participant CachedProps as Cached Properties participant Terminal as terminal.py helpers Client->>TerminalComponentModelerData: get_antenna_metrics_data() TerminalComponentModelerData->>TerminalComponentModelerData: port_power_waves (cached_property) alt First access (cache miss) TerminalComponentModelerData->>TerminalComponentModelerData: compute_port_wave_amplitudes() TerminalComponentModelerData->>TerminalComponentModelerData: port_voltage_currents (cached_property) alt First VI access (cache miss) TerminalComponentModelerData->>Terminal: _compute_port_voltages_currents() Terminal-->>TerminalComponentModelerData: voltage_array, current_array TerminalComponentModelerData->>CachedProps: cache VI data else VI cache hit CachedProps-->>TerminalComponentModelerData: cached VI data end TerminalComponentModelerData->>Terminal: _compute_wave_amplitudes_from_VI() Terminal-->>TerminalComponentModelerData: a_array, b_array TerminalComponentModelerData->>CachedProps: cache wave amplitude data else Wave cache hit CachedProps-->>TerminalComponentModelerData: cached wave amplitudes end TerminalComponentModelerData->>TerminalComponentModelerData: _monitor_data_at_port_amplitude() TerminalComponentModelerData-->>Client: AntennaMetricsData