From 9a21eabd55d1353ca8241abbd91578b4ede84502 Mon Sep 17 00:00:00 2001 From: Ethan Peterson Date: Wed, 19 Feb 2020 08:46:50 -0500 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Paul Romano --- openmc/surface.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/openmc/surface.py b/openmc/surface.py index c73ce6fc87..6d08507d69 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -19,7 +19,7 @@ _WARNING_UPPER = """\ will not accept the capitalized version.\ """ -_WARNING_KWARGS = """ +_WARNING_KWARGS = """\ "{}(...) accepts keyword arguments only for '{}'. Future versions of OpenMC \ will not accept positional parameters for superclass arguments.\ """ @@ -219,7 +219,7 @@ class Surface(IDManagerMixin, metaclass=ABCMeta): coeffs1 = self.normalize(self._get_base_coeffs()) coeffs2 = self.normalize(other._get_base_coeffs()) - return np.all(np.isclose(coeffs1, coeffs2, rtol=0., atol=self._atol)) + return np.allclose(coeffs1, coeffs2, rtol=0., atol=self._atol) @abstractmethod def evaluate(self, point): @@ -599,10 +599,10 @@ class XPlane(PlaneMixin, Surface): _coeff_keys = ('x0',) def __init__(self, x0=0., *args, **kwargs): - # work around for accepting Surface kwargs as positional parameters + # work around for accepting Surface kwargs as positional parameters # until they are deprecated argsdict = dict(zip(('boundary_type', 'name', 'surface_id'), args)) - for k, v in argsdict.items(): + for k in argsdict: warn(_WARNING_KWARGS.format(type(self).__name__, k), FutureWarning) kwargs.update(argsdict) @@ -679,10 +679,10 @@ class YPlane(PlaneMixin, Surface): _coeff_keys = ('y0',) def __init__(self, y0=0., *args, **kwargs): - # work around for accepting Surface kwargs as positional parameters + # work around for accepting Surface kwargs as positional parameters # until they are deprecated argsdict = dict(zip(('boundary_type', 'name', 'surface_id'), args)) - for k in argsdict.keys(): + for k in argsdict: warn(_WARNING_KWARGS.format(type(self).__name__, k), FutureWarning) kwargs.update(argsdict) @@ -759,10 +759,10 @@ class ZPlane(PlaneMixin, Surface): _coeff_keys = ('z0',) def __init__(self, z0=0., *args, **kwargs): - # work around for accepting Surface kwargs as positional parameters + # work around for accepting Surface kwargs as positional parameters # until they are deprecated argsdict = dict(zip(('boundary_type', 'name', 'surface_id'), args)) - for k in argsdict.keys(): + for k in argsdict: warn(_WARNING_KWARGS.format(type(self).__name__, k), FutureWarning) kwargs.update(argsdict) @@ -825,8 +825,8 @@ class QuadricMixin(metaclass=ABCMeta): else: a, b, c, d, e, f, g, h, j, k = coeffs - A = np.asarray([[a, d/2, f/2], [d/2, b, e/2], [f/2, e/2, c]]) - bvec = np.asarray([g, h, j]) + A = np.array([[a, d/2, f/2], [d/2, b, e/2], [f/2, e/2, c]]) + bvec = np.array([g, h, j]) return A, bvec, k @@ -979,7 +979,7 @@ class Cylinder(QuadricMixin, Surface): """ _type = 'cylinder' - _coeff_keys = ('x0', 'y0', 'z0', 'r', 'dx', 'dy','dz') + _coeff_keys = ('x0', 'y0', 'z0', 'r', 'dx', 'dy', 'dz') def __init__(self, x0=0., y0=0., z0=0., r=1., dx=0., dy=0., dz=1., **kwargs): @@ -2405,4 +2405,3 @@ class Halfspace(Region): _SURFACE_CLASSES = {cls._type: cls for cls in Surface.__subclasses__()} -