Skip to content

Commit

Permalink
feat[frontend]: add angle validator to specify expected angle in radians
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Roberts committed Jan 15, 2025
1 parent 405aef2 commit eda6972
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tidy3d/components/geometry/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,6 @@ class Planar(SimplePlaneIntersection, Geometry, ABC):
"along the ``axis`` direction; "
"and ``-np.pi/2<sidewall_angle<0`` specifies an expanding cross section "
"along the ``axis`` direction.",
gt=-np.pi / 2,
lt=np.pi / 2,
units=RADIAN,
)

Expand All @@ -1712,6 +1710,18 @@ class Planar(SimplePlaneIntersection, Geometry, ABC):
"``top`` refers to the positive side of the y-axis.",
)

@pydantic.validator("sidewall_angle", always=True)
def validate_angle(cls, value: float) -> float:
lower_bound = -np.pi / 2
upper_bound = np.pi / 2
if (value <= lower_bound) or (value >= upper_bound):
# u03C0 is unicode for pi
raise ValidationError(
f"Sidewall angle ({value}) must be between -\u03c0/2 and \u03c0/2 rad."
)

return value

@property
@abstractmethod
def center_axis(self) -> float:
Expand Down

0 comments on commit eda6972

Please sign in to comment.