-
Notifications
You must be signed in to change notification settings - Fork 64
Include RF data structures immutability #2741
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
Conversation
d15e14a
to
5681c5e
Compare
fix setting data attributes
e5d7aa6
to
dccf437
Compare
We can fix the missing issues on the other branch |
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.
7 files reviewed, 4 comments
s_param_def: SParamDef = pd.Field( | ||
"pseudo", | ||
title="Scattering Parameter Definition", | ||
description="Whether to scattering parameters are defined using the 'pseudo' or 'power' wave definitions.", |
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.
syntax: Grammar error: 'Whether to scattering parameters' should be 'Whether scattering parameters'
description="Whether to scattering parameters are defined using the 'pseudo' or 'power' wave definitions.", | |
description="Whether scattering parameters are defined using the 'pseudo' or 'power' wave definitions.", |
@@ -16,6 +34,13 @@ | |||
from tidy3d.plugins.smatrix.network import SParamDef | |||
from tidy3d.plugins.smatrix.ports.coaxial_lumped import CoaxialLumpedPort | |||
from tidy3d.plugins.smatrix.ports.rectangular_lumped import LumpedPort | |||
from tidy3d.plugins.smatrix.data.data_array import PortDataArray, TerminalPortDataArray |
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.
syntax: Duplicate import - this line repeats the import from line 33
return cls.assign_data_attrs(cls(data=result.data, coords=result.coords)) | ||
|
||
|
||
def _make_voltage_data_array(result: DataArray) -> CurrentIntegralResultTypes: |
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.
logic: Type annotation mismatch - function name suggests voltage but returns CurrentIntegralResultTypes
def _make_voltage_data_array(result: DataArray) -> CurrentIntegralResultTypes: | |
def _make_voltage_data_array(result: DataArray) -> VoltageIntegralResultTypes: |
return cls.assign_data_attrs(cls(data=result.data, coords=result.coords)) | ||
|
||
|
||
def _make_current_data_array(result: DataArray) -> VoltageIntegralResultTypes: |
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.
logic: Type annotation mismatch - function name suggests current but returns VoltageIntegralResultTypes
def _make_current_data_array(result: DataArray) -> VoltageIntegralResultTypes: | |
def _make_current_data_array(result: DataArray) -> CurrentIntegralResultTypes: |
Greptile Summary
This PR implements immutable RF data structures for Tidy3D's microwave simulation capabilities. The changes consolidate RF data array creation logic into centralized utility functions and introduce specialized data array types for voltage, current, and impedance measurements across frequency, time, and modal domains.
The main architectural changes include:
New RF Data Structures: Added comprehensive voltage, current, and impedance array classes (
VoltageArray
,CurrentArray
,ImpedanceArray
) with domain-specific subclasses (frequency, time, frequency-mode variants) indata_array.py
Centralized Utility Functions: Moved data array creation logic from individual classes to centralized helper functions in
smatrix/utils.py
(_make_voltage_data_array
,_make_current_data_array
,_make_impedance_data_array
)S-Parameter Definition Tracking: Added
s_param_def
field toMicrowaveSMatrixData
to track whether scattering parameters use 'pseudo' or 'power' wave definitionsMatrix Operations Refactoring: Moved matrix inversion from class methods to utility functions (
port_array_inv
) to support immutability patternsType Safety Improvements: Updated return types throughout the RF modules to use specific type aliases (
CurrentIntegralResultTypes
,VoltageIntegralResultTypes
,ImpedanceResultTypes
) instead of generic typesThese changes align with functional programming principles by moving operations from instance methods to pure utility functions, supporting the goal of making RF data structures immutable. The refactoring affects microwave path integrals, impedance calculations, and S-matrix computations across the RF simulation framework.
Important Files Changed
Click to expand file changes
tidy3d/components/data/data_array.py
tidy3d/plugins/smatrix/utils.py
tidy3d/plugins/microwave/custom_path_integrals.py
tidy3d/plugins/microwave/path_integrals.py
tidy3d/plugins/microwave/impedance_calculator.py
tidy3d/plugins/smatrix/data/terminal.py
tests/test_plugins/smatrix/test_terminal_component_modeler.py
Confidence score: 1/5
tidy3d/components/data/data_array.py
andtidy3d/plugins/smatrix/utils.py
which contain the most critical bugs that need fixing before mergeSequence Diagram