Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- More accurate frequency range for ``GaussianPulse`` when DC is removed.
- 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.
- Improved type hints for `Tidy3dBaseModel`, so that all derived classes will have more accurate return types.
- More robust method for suppressing RF license warnings during tests.

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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ addopts = "--cov=tidy3d --doctest-modules -n auto --dist worksteal --assert=plai
markers = [
"numerical: marks numerical tests for adjoint gradients that require running simulations (deselect with '-m \"not numerical\"')",
]
env = ["MPLBACKEND=Agg", "OMP_NUM_THREADS=1"]
env = ["MPLBACKEND=Agg", "OMP_NUM_THREADS=1", "TIDY3D_MICROWAVE__SUPPRESS_RF_LICENSE_WARNING=true"]
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS"
norecursedirs = [
"tests/_test_local",
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def reset_logger():
set_logging_level(DEFAULT_LEVEL)


@pytest.fixture(autouse=True)
def clear_log_cache():
"""Ensure log-once cache does not leak between tests."""
td.log._static_cache.clear()
yield


@pytest.fixture
def check_grads_with_tolerance(monkeypatch):
@unary_to_nary
Expand Down
11 changes: 11 additions & 0 deletions tests/test_components/test_microwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,3 +1783,14 @@ def test_impedance_calculator_mode_direction_handling():
# Both should produce valid impedance values
assert hasattr(impedance_mode_solver, "values")
assert hasattr(impedance_mode, "values")


def test_RF_license_suppression():
"""Ensure license warnings are being emitted properly and default instantiations avoid the warning."""
original_setting = td.config.microwave.suppress_rf_license_warning
td.config.microwave.suppress_rf_license_warning = False
with AssertLogLevel("WARNING", contains_str="new license requirements"):
mode_spec = td.MicrowaveModeSpec()
with AssertLogLevel(None):
mode_spec = td.MicrowaveModeSpec._default_without_license_warning()
td.config.microwave.suppress_rf_license_warning = original_setting
15 changes: 7 additions & 8 deletions tidy3d/components/microwave/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from tidy3d.components.base import Tidy3dBaseModel
from tidy3d.config import config
from tidy3d.log import log
from tidy3d.utils import is_running_pytest


class MicrowaveBaseModel(Tidy3dBaseModel):
Expand All @@ -17,8 +16,8 @@ class MicrowaveBaseModel(Tidy3dBaseModel):
def _warn_rf_license(cls, values):
from tidy3d.config import config

# Skip warning during test runs or when globally suppressed via config
if not is_running_pytest() and not config.suppress_rf_license_warning:
# Skip warning when globally suppressed via config
if not config.microwave.suppress_rf_license_warning:
log.warning(
"ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. "
"You have instantiated at least one RF-specific component.",
Expand All @@ -29,10 +28,10 @@ def _warn_rf_license(cls, values):
@classmethod
def _default_without_license_warning(cls) -> MicrowaveBaseModel:
"""Internal helper factory function for classes inheriting from ``MicrowaveBaseModel``."""
if config.suppress_rf_license_warning is True:
if config.microwave.suppress_rf_license_warning is True:
return cls()
else:
config.suppress_rf_license_warning = True
default_contructed = cls()
config.suppress_rf_license_warning = False
return default_contructed
config.microwave.suppress_rf_license_warning = True
default_constructed = cls()
config.microwave.suppress_rf_license_warning = False
return default_constructed
10 changes: 0 additions & 10 deletions tidy3d/utils.py

This file was deleted.