Skip to content

Commit c5e7ad3

Browse files
committed
fix(rf): more robust suppression of RF license warning
1 parent 0ed42f3 commit c5e7ad3

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5555
- More accurate frequency range for ``GaussianPulse`` when DC is removed.
5656
- Bug in `TerminalComponentModelerData.get_antenna_metrics_data()` where `WavePort` mode indices were not properly handled. Improved docstrings and type hints to make the usage clearer.
5757
- Improved type hints for `Tidy3dBaseModel`, so that all derived classes will have more accurate return types.
58+
- More robust method for suppressing RF license warnings during tests.
5859

5960
## [v2.10.0rc2] - 2025-10-01
6061

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ addopts = "--cov=tidy3d --doctest-modules -n auto --dist worksteal --assert=plai
298298
markers = [
299299
"numerical: marks numerical tests for adjoint gradients that require running simulations (deselect with '-m \"not numerical\"')",
300300
]
301-
env = ["MPLBACKEND=Agg", "OMP_NUM_THREADS=1"]
301+
env = ["MPLBACKEND=Agg", "OMP_NUM_THREADS=1", "TIDY3D_MICROWAVE__SUPPRESS_RF_LICENSE_WARNING=true"]
302302
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS"
303303
norecursedirs = [
304304
"tests/_test_local",

tests/test_components/test_microwave.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,3 +1740,14 @@ def test_impedance_calculator_mode_direction_handling():
17401740
# Both should produce valid impedance values
17411741
assert hasattr(impedance_mode_solver, "values")
17421742
assert hasattr(impedance_mode, "values")
1743+
1744+
1745+
def test_RF_license_suppression():
1746+
"""Ensure license warnings are being emitted properly and default instantiations avoid the warning."""
1747+
original_setting = td.config.microwave.suppress_rf_license_warning
1748+
td.config.microwave.suppress_rf_license_warning = False
1749+
with AssertLogLevel("WARNING", contains_str="new license requirements"):
1750+
mode_spec = td.MicrowaveModeSpec()
1751+
with AssertLogLevel(None):
1752+
mode_spec = td.MicrowaveModeSpec._default_without_license_warning()
1753+
td.config.microwave.suppress_rf_license_warning = original_setting

tidy3d/components/microwave/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from tidy3d.components.base import Tidy3dBaseModel
88
from tidy3d.config import config
99
from tidy3d.log import log
10-
from tidy3d.utils import is_running_pytest
1110

1211

1312
class MicrowaveBaseModel(Tidy3dBaseModel):
@@ -17,8 +16,8 @@ class MicrowaveBaseModel(Tidy3dBaseModel):
1716
def _warn_rf_license(cls, values):
1817
from tidy3d.config import config
1918

20-
# Skip warning during test runs or when globally suppressed via config
21-
if not is_running_pytest() and not config.suppress_rf_license_warning:
19+
# Skip warning when globally suppressed via config
20+
if not config.microwave.suppress_rf_license_warning:
2221
log.warning(
2322
"ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. "
2423
"You have instantiated at least one RF-specific component.",
@@ -29,10 +28,10 @@ def _warn_rf_license(cls, values):
2928
@classmethod
3029
def _default_without_license_warning(cls) -> MicrowaveBaseModel:
3130
"""Internal helper factory function for classes inheriting from ``MicrowaveBaseModel``."""
32-
if config.suppress_rf_license_warning is True:
31+
if config.microwave.suppress_rf_license_warning is True:
3332
return cls()
3433
else:
35-
config.suppress_rf_license_warning = True
36-
default_contructed = cls()
37-
config.suppress_rf_license_warning = False
38-
return default_contructed
34+
config.microwave.suppress_rf_license_warning = True
35+
default_constructed = cls()
36+
config.microwave.suppress_rf_license_warning = False
37+
return default_constructed

tidy3d/utils.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)