Skip to content

Commit

Permalink
ISOXX parsing (#559)
Browse files Browse the repository at this point in the history
* Fix a bug where if a file named ISOtopes.txt was in the working the directory that the ISOTXS merging would fail.
  • Loading branch information
keckler committed Feb 9, 2022
1 parent dfd6c9c commit 1c7b3ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
18 changes: 18 additions & 0 deletions armi/nuclearDataIO/tests/test_xsLibraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ def test_mergeFailsWithNonIsotxsFiles(self):
finally:
os.remove(dummyFileName)

dummyFileName = "ISOtopics.txt"
with open(dummyFileName, "w") as file:
file.write(
"This is a file that starts with the letters 'ISO' but will"
" break the regular expression search."
)

try:
with mockRunLogs.BufferLog() as log:
lib = xsLibraries.IsotxsLibrary()
xsLibraries.mergeXSLibrariesInWorkingDirectory(lib)
self.assertTrue(
f"Ignoring file {dummyFileName} in the merging of ISOXX files"
in log.getStdoutValue()
)
finally:
os.remove(dummyFileName)

def _xsLibraryAttributeHelper(
self,
lib,
Expand Down
13 changes: 10 additions & 3 deletions armi/nuclearDataIO/xsLibraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ def mergeXSLibrariesInWorkingDirectory(lib, xsLibrarySuffix="", mergeGammaLibs=F
librariesToMerge = []
neutronVelocities = {} # Dictionary of neutron velocities from each ISOTXS file
for xsLibFilePath in sorted(xsLibFiles):
xsID = re.search("ISO([A-Z0-9]{2})", xsLibFilePath).group(
1
) # get XS ID from the cross section library name
try:
xsID = re.search("ISO([A-Z0-9]{2})", xsLibFilePath).group(
1
) # get XS ID from the cross section library name
except AttributeError:
# if glob has matched something that is not actually an ISOXX file,
# the .group() call will fail
runLog.debug(f"Ignoring file {xsLibFilePath} in the merging of ISOXX files")
continue

xsFileTypes = "ISOTXS" if not mergeGammaLibs else "ISOTXS, GAMISO, and PMATRX"
runLog.info(
"Retrieving {} data for XS ID {}{}".format(
Expand Down

0 comments on commit 1c7b3ea

Please sign in to comment.