Skip to content

Commit a915772

Browse files
yaugenst-flexmahlau-flex
authored andcommitted
fix: restore copy(True) compatibility and accept doping lists
1 parent c05f06a commit a915772

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

tidy3d/components/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ def convert_value(value: Any, field_info: FieldInfo) -> Any:
544544

545545
def copy(
546546
self,
547-
*,
548547
deep: bool = True,
548+
*,
549549
validate: bool = True,
550550
update: Optional[Mapping[str, Any]] = None,
551551
) -> Self:

tidy3d/components/material/tcad/charge.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,21 +303,31 @@ class SemiconductorMedium(AbstractChargeMedium):
303303
units=ELECTRON_VOLT,
304304
)
305305

306-
N_a: Union[NonNegativeFloat, SpatialDataArray, tuple[DopingBoxType, ...]] = Field(
306+
N_a: Union[
307+
tuple[DopingBoxType, ...],
308+
list[DopingBoxType],
309+
SpatialDataArray,
310+
NonNegativeFloat,
311+
] = Field(
307312
(),
308313
title="Doping: Acceptor concentration",
309314
description="Concentration of acceptor impurities, which create mobile holes, resulting in p-type material. "
310315
"Can be specified as a single float for uniform doping, a :class:`SpatialDataArray` for a custom profile, "
311-
"or a tuple of geometric shapes to define specific doped regions.",
316+
"or a tuple/list of geometric shapes to define specific doped regions.",
312317
units=PERCMCUBE,
313318
)
314319

315-
N_d: Union[NonNegativeFloat, SpatialDataArray, tuple[DopingBoxType, ...]] = Field(
320+
N_d: Union[
321+
tuple[DopingBoxType, ...],
322+
list[DopingBoxType],
323+
SpatialDataArray,
324+
NonNegativeFloat,
325+
] = Field(
316326
(),
317327
title="Doping: Donor concentration",
318328
description="Concentration of donor impurities, which create mobile electrons, resulting in n-type material. "
319329
"Can be specified as a single float for uniform doping, a :class:`SpatialDataArray` for a custom profile, "
320-
"or a tuple of geometric shapes to define specific doped regions.",
330+
"or a tuple/list of geometric shapes to define specific doped regions.",
321331
units=PERCMCUBE,
322332
)
323333

@@ -363,9 +373,14 @@ def check_eg_uses_model(
363373
@field_validator("N_d")
364374
@classmethod
365375
def check_nd_uses_model(
366-
cls, val: Union[NonNegativeFloat, SpatialDataArray, tuple[DopingBoxType, ...]]
376+
cls,
377+
val: Union[
378+
NonNegativeFloat, SpatialDataArray, tuple[DopingBoxType, ...], list[DopingBoxType]
379+
],
367380
) -> Union[SpatialDataArray, tuple[DopingBoxType, ...]]:
368381
"""Issue deprecation warning if float is provided"""
382+
if isinstance(val, list):
383+
return tuple(val)
369384
if isinstance(val, (float, int)):
370385
log.warning(
371386
"Passing a float to 'N_d' is deprecated and will be removed in future versions. "
@@ -377,9 +392,14 @@ def check_nd_uses_model(
377392
@field_validator("N_a")
378393
@classmethod
379394
def check_na_uses_model(
380-
cls, val: Union[NonNegativeFloat, SpatialDataArray, tuple[DopingBoxType, ...]]
395+
cls,
396+
val: Union[
397+
NonNegativeFloat, SpatialDataArray, tuple[DopingBoxType, ...], list[DopingBoxType]
398+
],
381399
) -> Union[SpatialDataArray, tuple[DopingBoxType, ...]]:
382400
"""Issue deprecation warning if float is provided"""
401+
if isinstance(val, list):
402+
return tuple(val)
383403
if isinstance(val, (float, int)):
384404
log.warning(
385405
"Passing a float to 'N_a' is deprecated and will be removed in future versions. "

0 commit comments

Comments
 (0)