From 6b3a23199427e4e71892b78cce495ab012b9f863 Mon Sep 17 00:00:00 2001 From: Ethan Peterson Date: Tue, 11 Feb 2020 12:34:31 -0500 Subject: [PATCH] fixed issue related to finding all surface subclasses --- openmc/surface.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/openmc/surface.py b/openmc/surface.py index 44178f6bc6..24b21cf288 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -188,17 +188,6 @@ class Surface(IDManagerMixin, metaclass=ABCMeta): def translate(self, vector): pass - @classmethod - def get_subclasses(cls): - """Recursively find all subclasses of this class""" - return set(cls.__subclasses__()).union([s for c in cls.__subclasses__() - for s in get_subclasses(c)]) - - @classmethod - def get_subclass_map(cls): - """Generate mapping of class _type attributes to classes""" - return {c._type: c for c in cls.get_subclasses()} - def to_xml_element(self): """Return XML representation of the surface @@ -279,9 +268,6 @@ class Surface(IDManagerMixin, metaclass=ABCMeta): return cls(*coeffs, **kwargs) -_SURFACE_CLASSES = Surface.get_subclass_map() - - class PlaneMixin(metaclass=ABCMeta): """A Plane Meta class for all operations on order 1 surfaces""" @@ -1844,7 +1830,7 @@ class Cone(QuadricMixin, Surface): """ - _type = 'cylinder' + _type = 'cone' _coeff_keys = ('x0', 'y0', 'z0', 'r2', 'dx', 'dy', 'dz') def __init__(self, x0=0., y0=0., z0=0., r2=1., dx=0., dy=0., dz=1., **kwargs): @@ -2712,3 +2698,18 @@ class Halfspace(Region): # Return translated surface return type(self)(memo[key], self.side) + +def get_subclasses(cls): + """Recursively find all subclasses of this class""" + return set(cls.__subclasses__()).union([s for c in cls.__subclasses__() + for s in get_subclasses(c)]) + + +def get_subclass_map(cls): + """Generate mapping of class _type attributes to classes""" + return {c._type: c for c in get_subclasses(cls)} + + +_SURFACE_CLASSES = get_subclass_map(Surface) + +