From cf9106d9142a8dda298e6e0c73dc0875233179bf Mon Sep 17 00:00:00 2001 From: Drew Johnson Date: Mon, 3 Feb 2025 11:20:04 -0800 Subject: [PATCH] Loosening tolerance on HexGrid roughly equal check (#2058) --- armi/reactor/grids/hexagonal.py | 4 ++-- armi/reactor/grids/tests/test_grids.py | 11 +++++++++++ doc/release/0.5.rst | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/armi/reactor/grids/hexagonal.py b/armi/reactor/grids/hexagonal.py index 262307826..a8a823d1c 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 isclose, sqrt from typing import List, Optional, Tuple import numpy as np @@ -639,6 +639,6 @@ def _roughlyEqual(self, other) -> bool: return True return ( isinstance(other, HexGrid) - and other.pitch == self.pitch + and isclose(self.pitch, other.pitch, rel_tol=1e-4) and other.cornersUp == self.cornersUp ) diff --git a/armi/reactor/grids/tests/test_grids.py b/armi/reactor/grids/tests/test_grids.py index 8cfa5c492..3f0d10759 100644 --- a/armi/reactor/grids/tests/test_grids.py +++ b/armi/reactor/grids/tests/test_grids.py @@ -772,6 +772,17 @@ def test_rotatedIndexGridAssignment(self): postRotate = base.rotateIndex(loc, rotations=2) self.assertIs(postRotate.grid, loc.grid) + def test_rotatedIndexRoughEqualPitch(self): + """Test indices can be rotated in close but not exactly equal grids.""" + base = grids.HexGrid.fromPitch(1.345) + other = grids.HexGrid.fromPitch(base.pitch * 1.00001) + + for i, j in ((0, 0), (1, 1), (2, 1), (-1, 3)): + loc = grids.IndexLocation(i, j, k=0, grid=base) + fromBase = base.rotateIndex(loc, rotations=2) + fromOther = other.rotateIndex(loc, rotations=2) + self.assertEqual((fromBase.i, fromBase.j), (fromOther.i, fromOther.j)) + class TestBoundsDefinedGrid(unittest.TestCase): def test_positions(self): diff --git a/doc/release/0.5.rst b/doc/release/0.5.rst index f3f5eefd4..33051845a 100644 --- a/doc/release/0.5.rst +++ b/doc/release/0.5.rst @@ -21,7 +21,8 @@ Bug Fixes --------- #. Fixing check for jagged arrays during ``_writeParams``. (`PR#2051 `_) #. Fixing BP-section ignoring tool in ``PassiveDBLoadPlugin``. (`PR#2055 `_) -#. Fixing scaling of volume-integrated parameters on edge assembleis. (`PR#2060 `_) +#. Fixing scaling of volume-integrated parameters on edge assemblies. (`PR#2060 `_) +#. Fixing strictness of ``HexGrid`` rough equality check. (`PR#2058 `_) #. TBD Quality Work