def test_mergeFailsWithNonIsotxsFiles(self): dummyFileName = "ISOSOMEFILE" with open(dummyFileName, "w") as someFile: someFile.write("hi") try: with mockRunLogs.BufferLog() as log: lib = xsLibraries.IsotxsLibrary() with self.assertRaises(OSError): xsLibraries.mergeXSLibrariesInWorkingDirectory( lib, "ISOTXS", "") self.assertIn(dummyFileName, log.getStdoutValue()) 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.assertIn( f"Ignoring file {dummyFileName} in the merging of ISOXX files", log.getStdoutValue(), ) finally: os.remove(dummyFileName)
def test_mergeFailsWithNonIsotxsFiles(self): dummyFileName = "ISOSOMEFILE" with open(dummyFileName, "w") as someFile: someFile.write("hi") try: with mockRunLogs.BufferLog() as log: lib = xsLibraries.IsotxsLibrary() with self.assertRaises(exceptions.IsotxsError): xsLibraries.mergeXSLibrariesInWorkingDirectory(lib, "ISOTXS", "") self.assertTrue(dummyFileName in log.getStdoutValue()) finally: os.remove(dummyFileName)
def _mergeISOTXS(self): """Merge all the ISOTXS files together so that can be run for global flux.""" # Create an empty ISOTXS library to be filled in with XS data lib = xsLibraries.IsotxsLibrary() neutronVelocities = xsLibraries.mergeXSLibrariesInWorkingDirectory(lib) latticePhysicsInterface.setBlockNeutronVelocities(self.r, neutronVelocities) isotxs.writeBinary(lib, neutronics.ISOTXS)