Skip to content

Commit

Permalink
Fix KeyError in asciiMapFromGeomAndSym (#273)
Browse files Browse the repository at this point in the history
Use the geometry.GeomType.fromAny() method to input a string or
enumeration representation of a geomType and return the enumeration.

Symmetry does not have enumeration at the moment, so we'll continue to
use the string representation for now. Defining a single enumeration
for symmetry would be complicated by the different types of options
(full/third/quarter, reflective/periodic, etc.) that can appear in
combination with one another.
  • Loading branch information
mgjarrett authored Mar 30, 2021
1 parent 58cc18c commit b709d34
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions armi/utils/asciimaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,15 @@ def asciiMapFromGeomAndSym(geomType: str, symmetry: str):
symmetry = symmetry.replace(geometry.REFLECTIVE, "")
symmetry = symmetry.replace(geometry.THROUGH_CENTER_ASSEMBLY, "")

if str(geomType) == geometry.HEX_CORNERS_UP and symmetry == geometry.FULL_CORE:
return AsciiMapHexFullTipsUp

MAP_FROM_GEOM = {
(geometry.HEX, geometry.THIRD_CORE): AsciiMapHexThirdFlatsUp,
(geometry.HEX, geometry.FULL_CORE): AsciiMapHexFullFlatsUp,
(geometry.HEX_CORNERS_UP, geometry.FULL_CORE): AsciiMapHexFullTipsUp,
(geometry.CARTESIAN, None): AsciiMapCartesian,
(geometry.CARTESIAN, geometry.FULL_CORE): AsciiMapCartesian,
(geometry.CARTESIAN, geometry.QUARTER_CORE): AsciiMapCartesian,
(geometry.GeomType.HEX, geometry.THIRD_CORE): AsciiMapHexThirdFlatsUp,
(geometry.GeomType.HEX, geometry.FULL_CORE): AsciiMapHexFullFlatsUp,
(geometry.GeomType.CARTESIAN, None): AsciiMapCartesian,
(geometry.GeomType.CARTESIAN, geometry.FULL_CORE): AsciiMapCartesian,
(geometry.GeomType.CARTESIAN, geometry.QUARTER_CORE): AsciiMapCartesian,
}

return MAP_FROM_GEOM[(geomType, symmetry)]
return MAP_FROM_GEOM[(geometry.GeomType.fromAny(geomType), symmetry)]

0 comments on commit b709d34

Please sign in to comment.