-
Notifications
You must be signed in to change notification settings - Fork 65
feat(microwave): tidy3d_microwave and BroadbandPulse feature #2883
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
base: develop
Are you sure you want to change the base?
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.
6 files reviewed, 4 comments
fd3c06b to
84a91a5
Compare
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.
6 files reviewed, 3 comments
| def test_tidy3d_microwave(): | ||
| import importlib | ||
|
|
||
| has_tidy3d_microwave = importlib.util.find_spec("tidy3d_microwave") is not None | ||
| print(f"has_tidy3d_microwave = {has_tidy3d_microwave}") | ||
|
|
||
| if has_tidy3d_microwave: | ||
|
|
||
| @supports_microwave | ||
| def get_pulse(): | ||
| assert tidy3d_microwave["mod"] is not None | ||
| pulse = tidy3d_microwave["mod"].BroadbandPulse(fmin=0.1, fmax=10) | ||
| _ = pulse.frequency_range(2) | ||
|
|
||
| get_pulse() | ||
| else: | ||
| assert tidy3d_microwave["mod"] is None |
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.
style: Test only covers the success path. Consider adding a test case that verifies Tidy3dImportError is raised when @supports_microwave decorated functions are called without the package installed, similar to other tests in this file.
Context Used: Rule from dashboard - Add tests for all public constructors and methods to confirm expected behavior, including effects on... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/test_components/test_packaging.py
Line: 95:111
Comment:
**style:** Test only covers the success path. Consider adding a test case that verifies `Tidy3dImportError` is raised when `@supports_microwave` decorated functions are called without the package installed, similar to other tests in this file.
**Context Used:** Rule from `dashboard` - Add tests for all public constructors and methods to confirm expected behavior, including effects on... ([source](https://app.greptile.com/review/custom-context?memory=40c78813-75a7-47ea-a080-1509e6e686a9))
How can I resolve this? If you propose a fix, please make it concise.
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/source/time.pytidy3d/packaging.py |
5bab42c to
4146674
Compare
Greptile Overview
Updated On: 2025-10-09 23:26:28 UTC
Greptile Summary
This PR introduces support for the
tidy3d-microwaveplugin and adds a newBroadbandPulsesource time class for microwave simulations. The changes implement a modular architecture that allows Tidy3D to conditionally support microwave-specific functionality through an optional external package.The implementation follows the established pattern used for other optional dependencies like
tidy3d-extras. Key components include: packaging infrastructure with a@supports_microwavedecorator that handles import validation and version checking; aBroadbandPulseclass that acts as a bridge between Tidy3D's source time interface and the microwave package's implementation; build configuration updates inpyproject.toml; API documentation additions; and basic integration tests.The
BroadbandPulseclass enables users to create broadband excitation sources with guaranteed amplitude levels across specified frequency ranges, particularly useful for microwave simulation applications. The modular design ensures users can access this functionality by installing the optionaltidy3d[microwave]package while keeping the core Tidy3D package lightweight.PR Description Notes:
Important Files Changed
Changed Files
CHANGELOG.mdtidy3d/packaging.pydocs/api/sources.rsttidy3d/components/source/time.pytests/test_components/test_packaging.pypyproject.tomlConfidence score: 3/5
Sequence Diagram
sequenceDiagram participant User participant BroadbandPulse as "BroadbandPulse" participant tidy3d_microwave as "tidy3d_microwave module" participant Packaging as "packaging.py" participant SourceImplementation as "tidy3d_microwave.BroadbandPulse" User->>BroadbandPulse: "Initialize BroadbandPulse(freq_range, minimum_amplitude, offset)" BroadbandPulse->>Packaging: "@supports_microwave decorator called" Packaging->>tidy3d_microwave: "Check if tidy3d_microwave module available" alt tidy3d_microwave available tidy3d_microwave-->>Packaging: "Module found and validated" Packaging-->>BroadbandPulse: "Proceed with initialization" BroadbandPulse->>SourceImplementation: "Create tidy3d_microwave.BroadbandPulse(fmin, fmax, minRelAmp, amp, phase, offset)" SourceImplementation-->>BroadbandPulse: "Return implementation instance" BroadbandPulse-->>User: "BroadbandPulse instance created" else tidy3d_microwave not available tidy3d_microwave-->>Packaging: "ImportError raised" Packaging-->>BroadbandPulse: "Tidy3dImportError: install tidy3d[microwave]" BroadbandPulse-->>User: "Error: Missing tidy3d-microwave package" end User->>BroadbandPulse: "Call amp_time(time)" BroadbandPulse->>SourceImplementation: "Delegate to _source.amp_time(time)" SourceImplementation-->>BroadbandPulse: "Return complex amplitude" BroadbandPulse-->>User: "Complex amplitude value" User->>BroadbandPulse: "Call amp_freq(freq)" BroadbandPulse->>SourceImplementation: "Delegate to _source.amp_freq(freq)" SourceImplementation-->>BroadbandPulse: "Return complex amplitude" BroadbandPulse-->>User: "Complex amplitude value" User->>BroadbandPulse: "Call end_time()" BroadbandPulse->>SourceImplementation: "Delegate to _source.end_time(END_TIME_FACTOR_GAUSSIAN)" SourceImplementation-->>BroadbandPulse: "Return end time" BroadbandPulse-->>User: "End time value" User->>BroadbandPulse: "Call frequency_range_sigma(sigma)" BroadbandPulse->>SourceImplementation: "Delegate to _source.frequency_range(sigma)" SourceImplementation-->>BroadbandPulse: "Return frequency bounds" BroadbandPulse-->>User: "Frequency range tuple"Context used (3)
dashboard- Avoid hardcoding values ("magic numbers") that can be programmatically derived from data; use named ... (source)dashboard- In changelogs, enclose code identifiers (class, function names) in backticks and use specific names ... (source)dashboard- Require a changelog entry for any PR that is not purely an internal refactor. (source)