From ecc7564ee46490fb28c18f6c91a2c8561eabfe18 Mon Sep 17 00:00:00 2001 From: Michael Jarrett Date: Thu, 16 Jan 2025 23:43:53 +0000 Subject: [PATCH] Use math.isclose for _roughlyEqual --- armi/reactor/grids/hexagonal.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/armi/reactor/grids/hexagonal.py b/armi/reactor/grids/hexagonal.py index df44d19ef..96f6c63e5 100644 --- a/armi/reactor/grids/hexagonal.py +++ b/armi/reactor/grids/hexagonal.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from collections import deque -from math import sqrt +from math import sqrt, isclose from typing import Tuple, List, Optional import numpy as np @@ -631,14 +631,15 @@ def rotateIndex(self, loc: IndexLocation, rotations: int) -> IndexLocation: ) def _roughlyEqual(self, other) -> bool: - """Check that two hex grids are nearly identical. + """Check that two hex grids are similar - Would the same ``(i, j, k)`` index in ``self`` be the same location in ``other``? + - Would the same ``(i, j, k)`` index in ``self`` be the same location in ``other``? + - Are the pin pitches roughly the same? """ if other is self: return True return ( isinstance(other, HexGrid) - and other.pitch == self.pitch + and isclose(other.pitch, self.pitch, rel_tol=1.0e-3) and other.cornersUp == self.cornersUp )