def test_raiseError(self): """Verify that the reader raises an error for unexpected EOF""" badFile = 'bad_branching.coe' with open(self.file) as fObj, open(badFile, 'w') as badObj: for _line in range(5): badObj.write(fObj.readline()) badReader = BranchingReader(badFile) with self.assertRaises(EOFError): badReader.read() os.remove(badFile)
class BranchWithUncsTester(unittest.TestCase): """Tester that just tests a small file with uncertainties""" BRANCH_DATA = { 'nom': { 'infTot': [ [4.92499E-01, 1.01767E+00], # value [0.00074, 0.00072], # uncertainty ], 'infS0': [ [0.466391, 0.0155562, 0.00128821, 0.921487], [0.00072, 0.00148, 0.01793, 0.00091], ], }, 'hot': { 'infTot': [ [4.92806E-1, 1.0168E00], # value [0.00063, 0.00104], # uncertainty ], 'infS0': [ [4.66639E-1, 1.53978E-02, 1.38727E-03, 9.20270E-01], [0.00062, 0.00214, 0.03073, 0.00112], ], }, } BRANCH_UNIVKEY = ("0", 0, 0, None) def setUp(self): fp = getFile('demo_uncs.coe') self.reader = BranchingReader(fp) self.reader.read() def test_valsWithUncs(self): """Test that the branches and the uncertainties are present""" self.assertTrue(self.reader.hasUncs) for expKey, expSubData in self.BRANCH_DATA.items(): self.assertTrue(expKey in self.reader.branches, msg=expKey) actBranch = self.reader.branches[expKey] self.assertTrue(self.BRANCH_UNIVKEY in actBranch, msg=self.BRANCH_UNIVKEY) univ = actBranch[self.BRANCH_UNIVKEY] for gcKey, gcVals in expSubData.items(): actData = univ.get(gcKey, True) for act, exp, what in zip(actData, gcVals, ['val', 'unc']): assert_allclose(act, exp, err_msg='{} {} {}'.format( expKey, gcKey, what))
def setUpClass(cls): cls.file = getFile('ref_branch.coe') cls.expectedBranches = {('nom', 'nom', 'nom')} cls.expectedUniverses = { # universe id, burnup, step (0, 0, 0), } with rc: rc['serpentVersion'] = '2.1.29' rc['xs.variableGroups'] = ['gc-meta', 'xs', 'diffusion'] rc['xs.getInfXS'] = True # only store inf cross sections rc['xs.getB1XS'] = False cls.reader = BranchingReader(cls.file) cls.reader.read()
def setUp(self): fp = getFile('demo_uncs.coe') self.reader = BranchingReader(fp) self.reader.read()