Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Paul Romano <[email protected]>
  • Loading branch information
eepeterson and paulromano committed Feb 25, 2020
1 parent ac5bb40 commit 378856d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions openmc/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _get_base_coeffs(self):

def _get_normal(self):
a, b, c = self._get_base_coeffs()[0:3]
return np.array((a, b, c)) / np.sqrt(a*a + b*b + c*c)
return np.array((a, b, c)) / math.sqrt(a*a + b*b + c*c)

def bounding_box(self, side):
# Compute the bounding box based on the normal vector to the plane
Expand All @@ -375,12 +375,12 @@ def bounding_box(self, side):
ub = np.array([np.inf, np.inf, np.inf])
# If the plane is axis aligned, find the proper bounding box
if np.any(np.isclose(np.abs(nhat), 1., rtol=0., atol=self._atol)):
sign = np.dot(np.array([1., 1., 1.]), nhat)
sign = nhat.sum()
a, b, c, d = self._get_base_coeffs()
vals = tuple(d/i if round(i) != 0 else np.nan for i in (a, b, c))
vals = [d/val if round(val) != 0 else np.nan for val in (a, b, c)]
if side == '-':
if sign > 0:
ub = np.array([v if ~np.isnan(v) else np.inf for v in vals])
ub = np.array([v if not np.isnan(v) else np.inf for v in vals])
else:
lb = np.array([v if ~np.isnan(v) else -np.inf for v in vals])
elif side == '+':
Expand Down Expand Up @@ -946,7 +946,7 @@ def translate(self, vector, inplace=False):

surf = self if inplace else self.clone()

if any((isinstance(self, cls) for cls in (Cylinder, Sphere, Cone))):
if hasattr(self, 'x0'):
for vi, xi in zip(vector, ('x0', 'y0', 'z0')):
val = getattr(surf, xi)
try:
Expand All @@ -955,7 +955,7 @@ def translate(self, vector, inplace=False):
# That attribute is read only i.e x0 for XCylinder
pass

elif isinstance(self, Quadric):
else:
A, bvec, cnst = self.get_Abc()

g, h, j = bvec - 2*vector.T @ A
Expand Down

0 comments on commit 378856d

Please sign in to comment.