Skip to content

Commit 7d21fe6

Browse files
committed
Fix to DC voltage source units for compatibility
1 parent 738bc75 commit 7d21fe6

File tree

1 file changed

+10
-2
lines changed
  • tidy3d/components/spice/sources

1 file changed

+10
-2
lines changed

tidy3d/components/spice/sources/dc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
"""
2121

22-
from typing import Optional
22+
from typing import Literal, Optional
2323

2424
import pydantic.v1 as pd
2525

@@ -54,6 +54,10 @@ class DCVoltageSource(Tidy3dBaseModel):
5454
units=VOLT,
5555
)
5656

57+
# TODO: This should have always been in the field above but was introduced wrongly as a
58+
# standalone field. Keeping for compatibility, remove in 3.0.
59+
units: Literal[VOLT] = VOLT
60+
5761
@pd.validator("voltage")
5862
def check_voltage(cls, val):
5963
for v in val:
@@ -76,5 +80,9 @@ class DCCurrentSource(Tidy3dBaseModel):
7680
current: pd.FiniteFloat = pd.Field(
7781
title="Current",
7882
description="DC current usually used as source in 'CurrentBC' boundary conditions.",
83+
units=AMP,
7984
)
80-
units: str = AMP
85+
86+
# TODO: This should have always been in the field above but was introduced wrongly as a
87+
# standalone field. Keeping for compatibility, remove in 3.0.
88+
units: Literal[AMP] = AMP

0 commit comments

Comments
 (0)