From c4232c6dacfe15300d092c826cf5c1773b39d287 Mon Sep 17 00:00:00 2001 From: Troy Tamas Date: Wed, 23 Dec 2020 20:25:29 +0900 Subject: [PATCH] returning a copy of the cached bounding box --- gdspy/library.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gdspy/library.py b/gdspy/library.py index 2c7c099..1e197bd 100644 --- a/gdspy/library.py +++ b/gdspy/library.py @@ -578,11 +578,16 @@ def get_bounding_box(self): bb[0, 1] = min(bb[0, 1], all_points[1].min()) bb[1, 0] = max(bb[1, 0], all_points[0].max()) bb[1, 1] = max(bb[1, 1], all_points[1].max()) - self._bounding_box = numpy.asarray(bb) + self._bounding_box = bb else: self._bounding_box = None self._bb_valid = True - return self._bounding_box + + if self._bounding_box is None: + return None + else: + # return a *copy* of the cached bounding box to ensure it doesn't get inadvertently modified + return numpy.array(self._bounding_box) def get_polygons(self, by_spec=False, depth=None): """