From a1480b151563cc4113a68cf6a4e353faa49e63f5 Mon Sep 17 00:00:00 2001 From: tylerflex Date: Tue, 19 Apr 2022 10:40:53 -0700 Subject: [PATCH] error message if only one bound is inf --- tidy3d/components/geometry.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tidy3d/components/geometry.py b/tidy3d/components/geometry.py index 338d93faa..150d0585b 100644 --- a/tidy3d/components/geometry.py +++ b/tidy3d/components/geometry.py @@ -734,6 +734,17 @@ def get_center(pt_min: float, pt_max: float) -> float: """Returns center point based on bounds along dimension.""" if np.isneginf(pt_min) and np.isposinf(pt_max): return 0.0 + if np.isneginf(pt_min) or np.isposinf(pt_max): + raise SetupError( + f"Bounds of ({pt_min}, {pt_max}) supplied along one dimension. " + "We currently don't support supplying a single `inf` value in bounds " + "for the construction of semi-infinite `Box`. " + "Instead, to construct a semi-infinite `Box`, " + "please supply a large number instead of `inf`. " + "For example, if the Box represents the geometry of a `Structure` in a " + "`Simulation`, its bound should extend outside of the `Simulation` domain " + "including PML." + ) return (pt_min + pt_max) / 2.0 center = tuple(get_center(pt_min, pt_max) for pt_min, pt_max in zip(rmin, rmax))