File tree 3 files changed +21
-8
lines changed
tests/test_plugins/smatrix
tidy3d/plugins/smatrix/component_modelers
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
28
28
### Fixed
29
29
- Make gauge selection for non-converged modes more robust.
30
30
- Fixed extremely long runtime generated by ` RunTimeSpec ` in the presence of ` LossyMetalMedium ` .
31
+ - Fixed ` ComponentModeler.to_file ` when its batch is empty.
31
32
32
33
## [ 2.8.0rc2] - 2025-01-28
33
34
Original file line number Diff line number Diff line change @@ -381,6 +381,17 @@ def test_import_smatrix_smatrix():
381
381
from tidy3d .plugins .smatrix .smatrix import ComponentModeler , Port # noqa: F401
382
382
383
383
384
+ def test_to_from_file_empty_batch (tmp_path ):
385
+ modeler = make_component_modeler ()
386
+
387
+ fname = str (tmp_path ) + "/modeler.json"
388
+
389
+ modeler .to_file (fname )
390
+ modeler2 = modeler .from_file (fname )
391
+
392
+ assert modeler2 .batch_cached is None
393
+
394
+
384
395
def test_to_from_file_batch (tmp_path , monkeypatch ):
385
396
modeler = make_component_modeler ()
386
397
_ = run_component_modeler (monkeypatch , modeler )
Original file line number Diff line number Diff line change @@ -137,14 +137,15 @@ def to_file(self, fname: str) -> None:
137
137
"""
138
138
139
139
batch_cached = self ._cached_properties .get ("batch" )
140
- jobs_cached = batch_cached ._cached_properties .get ("jobs" )
141
- if jobs_cached is not None :
142
- jobs = {}
143
- for key , job in jobs_cached .items ():
144
- task_id = job ._cached_properties .get ("task_id" )
145
- jobs [key ] = job .updated_copy (task_id_cached = task_id )
146
- batch_cached = batch_cached .updated_copy (jobs_cached = jobs )
147
- self = self .updated_copy (batch_cached = batch_cached )
140
+ if batch_cached is not None :
141
+ jobs_cached = batch_cached ._cached_properties .get ("jobs" )
142
+ if jobs_cached is not None :
143
+ jobs = {}
144
+ for key , job in jobs_cached .items ():
145
+ task_id = job ._cached_properties .get ("task_id" )
146
+ jobs [key ] = job .updated_copy (task_id_cached = task_id )
147
+ batch_cached = batch_cached .updated_copy (jobs_cached = jobs )
148
+ self = self .updated_copy (batch_cached = batch_cached )
148
149
super (AbstractComponentModeler , self ).to_file (fname = fname ) # noqa: UP008
149
150
150
151
@cached_property
You can’t perform that action at this time.
0 commit comments