From e8d4dbd5f419ce52ff14355b9dbf59ef0a0e26b8 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 18 May 2016 16:39:35 -0500 Subject: [PATCH] Add Intersection.__iter__ and Union.__iter__ methods --- openmc/region.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openmc/region.py b/openmc/region.py index 95f59546c..9e1011271 100644 --- a/openmc/region.py +++ b/openmc/region.py @@ -223,7 +223,7 @@ class Intersection(Region): Attributes ---------- - nodes : tuple of openmc.Region + nodes : list of openmc.Region Regions to take the intersection of bounding_box : tuple of numpy.array Lower-left and upper-right coordinates of an axis-aligned bounding box @@ -233,6 +233,10 @@ class Intersection(Region): def __init__(self, *nodes): self.nodes = list(nodes) + def __iter__(self): + for n in self.nodes: + yield n + def __contains__(self, point): """Check whether a point is contained in the region. @@ -301,6 +305,10 @@ class Union(Region): def __init__(self, *nodes): self.nodes = list(nodes) + def __iter__(self): + for n in self.nodes: + yield n + def __contains__(self, point): """Check whether a point is contained in the region.