Skip to content

Commit

Permalink
Use math.isclose for _roughlyEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjarrett committed Jan 16, 2025
1 parent b6bd9ed commit ecc7564
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions armi/reactor/grids/hexagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)

0 comments on commit ecc7564

Please sign in to comment.