Skip to content

Commit 551efdf

Browse files
committed
remove all v1 remnants
1 parent f9fd5be commit 551efdf

File tree

15 files changed

+26
-26
lines changed

15 files changed

+26
-26
lines changed

tidy3d/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ def set_logging_level(level: str) -> None:
397397

398398
log.info(f"Using client version: {__version__}")
399399

400-
Transformed.update_forward_refs()
401-
ClipOperation.update_forward_refs()
402-
GeometryGroup.update_forward_refs()
400+
Transformed.model_rebuild()
401+
ClipOperation.model_rebuild()
402+
GeometryGroup.model_rebuild()
403403

404404
__all__ = [
405405
"C_0",

tidy3d/components/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Tidy3dBaseModel(BaseModel):
129129
"For example, the following is allowed for setting an ``attr`` ``obj.attrs['foo'] = bar``. "
130130
"Also note that `Tidy3D`` will raise a ``TypeError`` if ``attrs`` contain objects "
131131
"that can not be serialized. One can check if ``attrs`` are serializable "
132-
"by calling ``obj.json()``.",
132+
"by calling ``obj.model_dump_json()``.",
133133
)
134134

135135
_cached_properties: dict = PrivateAttr(default_factory=dict)
@@ -181,7 +181,7 @@ def __hash__(self) -> int:
181181
try:
182182
return super().__hash__(self)
183183
except TypeError:
184-
return hash(self.json())
184+
return hash(self.model_dump_json())
185185

186186
def _hash_self(self) -> str:
187187
"""Hash this component with ``hashlib`` in a way that is the same every session."""

tidy3d/components/data/monitor_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _updated(self, update: dict) -> MonitorData:
153153
thus be used carefully.
154154
155155
"""
156-
data_dict = self.dict()
156+
data_dict = self.model_dump()
157157
data_dict.update(update)
158158
return type(self).model_validate(data_dict)
159159

tidy3d/components/data/sim_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ def to_mat_file(self, fname: str, **kwargs):
13221322
)
13231323

13241324
# Get SimData object as dictionary
1325-
sim_dict = self.dict()
1325+
sim_dict = self.model_dump()
13261326

13271327
# set long field names true by default, otherwise it wont save fields with > 31 characters
13281328
if "long_field_names" not in kwargs:

tidy3d/components/eme/grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class EMEModeSpec(ModeSpec):
9090

9191
def _to_mode_spec(self) -> ModeSpec:
9292
"""Convert to ordinary :class:`.ModeSpec`."""
93-
ms_dict = self.dict()
93+
ms_dict = self.model_dump()
9494
ms_dict.pop("type")
9595
return ModeSpec.model_validate(ms_dict)
9696

tidy3d/components/microwave/data/monitor_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def from_directivity_data(
9595
New instance combining directivity data with incident and reflected power measurements.
9696
"""
9797
antenna_params_dict = {
98-
**dir_data.dict(),
98+
**dir_data.model_dump(),
9999
"power_incident": power_inc,
100100
"power_reflected": power_refl,
101101
}

tidy3d/components/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class SurfaceIntegrationMonitor(Monitor, ABC):
605605
def integration_surfaces(self):
606606
"""Surfaces of the monitor where fields will be recorded for subsequent integration."""
607607
if self.size.count(0.0) == 0:
608-
return self.surfaces_with_exclusion(**self.dict())
608+
return self.surfaces_with_exclusion(**self.model_dump())
609609
return [self]
610610

611611
@model_validator(mode="after")

tidy3d/components/scene.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def intersecting_media(
305305
return mediums
306306

307307
# if the test object is a volume, test each surface recursively
308-
surfaces = test_object.surfaces_with_exclusion(**test_object.dict())
308+
surfaces = test_object.surfaces_with_exclusion(**test_object.model_dump())
309309
mediums = set()
310310
for surface in surfaces:
311311
_mediums = Scene.intersecting_media(surface, structures)
@@ -347,7 +347,7 @@ def intersecting_structures(
347347
return structures_merged
348348

349349
# if the test object is a volume, test each surface recursively
350-
surfaces = test_object.surfaces_with_exclusion(**test_object.dict())
350+
surfaces = test_object.surfaces_with_exclusion(**test_object.model_dump())
351351
structures_merged = []
352352
for surface in surfaces:
353353
structures_merged += Scene.intersecting_structures(surface, structures)
@@ -1766,7 +1766,7 @@ def perturbed_mediums_copy(
17661766
Simulation after application of heat and/or charge data.
17671767
"""
17681768

1769-
scene_dict = self.dict()
1769+
scene_dict = self.model_dump()
17701770
structures = self.sorted_structures
17711771
array_dict = {
17721772
"temperature": temperature,

tidy3d/components/simulation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,8 @@ def plot_grid(
977977
cell_boundaries = self.grid.boundaries
978978
axis, _ = self.parse_xyz_kwargs(x=x, y=y, z=z)
979979
_, (axis_x, axis_y) = self.pop_axis([0, 1, 2], axis=axis)
980-
boundaries_x = cell_boundaries.dict()["xyz"[axis_x]]
981-
boundaries_y = cell_boundaries.dict()["xyz"[axis_y]]
980+
boundaries_x = cell_boundaries.model_dump()["xyz"[axis_x]]
981+
boundaries_y = cell_boundaries.model_dump()["xyz"[axis_y]]
982982

983983
if self.size[axis_x] > 0:
984984
for b in boundaries_x:
@@ -5194,7 +5194,7 @@ def perturbed_mediums_copy(
51945194
normal_axis=data.normal_axis,
51955195
)
51965196

5197-
sim_dict = self.dict()
5197+
sim_dict = self.model_dump()
51985198
structures = self.structures
51995199
sim_bounds = self.simulation_bounds
52005200
array_dict = {

tidy3d/components/viz/plot_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def include_kwargs(self, **kwargs) -> AbstractPlotParams:
2121
update_dict = {
2222
key: value
2323
for key, value in kwargs.items()
24-
if key not in ("type",) and value is not None and key in self.__fields__
24+
if key not in ("type",) and value is not None and key in self.model_fields
2525
}
2626
return self.copy(update=update_dict)
2727

@@ -31,7 +31,7 @@ def override_with_viz_spec(self, viz_spec) -> AbstractPlotParams:
3131

3232
def to_kwargs(self) -> dict:
3333
"""Export the plot parameters as kwargs dict that can be supplied to plot function."""
34-
kwarg_dict = self.dict()
34+
kwarg_dict = self.model_dump()
3535
for ignore_key in ("type", "attrs"):
3636
kwarg_dict.pop(ignore_key)
3737
return kwarg_dict

0 commit comments

Comments
 (0)