def test_setGet(self): infKey = 'infTestData' infVal = arange(2) univ = HomogUniv('setGetTest', None, None, None) self.assertEqual(0, len(univ.infExp), msg='Before set') self.assertEqual(0, len(univ.infUnc), msg='Before set') univ[infKey] = infVal self.assertEqual(1, len(univ.infExp), msg='After set') self.assertTrue(infKey in univ.infExp) self.assertEqual(0, len(univ.infUnc), msg='After set') self.assertIs(univ[infKey], infVal) with self.assertRaises(KeyError): univ['this should not exist']
def _storeUnivData(self, varNameSer, varVals): """Process universes' data""" brState = self._getBUstate() # obtain the branching tuple values = str2vec(varVals) # convert the string to float numbers if brState not in self.universes: self.universes[brState] = \ HomogUniv(brState[0], brState[1], brState[2], brState[3]) if varNameSer == self._keysVersion['univ']: return if varNameSer not in self._keysVersion['varsUnc']: vals, uncs = splitValsUncs(values) self.universes[brState].addData(varNameSer, uncs, True) self.universes[brState].addData(varNameSer, vals, False) else: self.universes[brState].addData(varNameSer, array(values), False)
def _storeUnivData(self, varNameSer, varVals): """Process universes data""" brState = self._getBUstate() # obtain the branching tuple if brState not in self.universes: self.universes[brState] = HomogUniv(*brState) if varNameSer == self._keysVersion['univ']: return # Get variable specificy type converter if varNameSer not in self._varTypeLookup: self._varTypeLookup[varNameSer] = varTypeFactory(varNameSer) converter = self._varTypeLookup[varNameSer] values, uncertainties = converter(varVals) # Values without uncertainties self.universes[brState].addData(varNameSer, values, False) if uncertainties is not None: self.universes[brState].addData(varNameSer, uncertainties, True)
def setUp(self): self.univ = HomogUniv('intGroups', 0, 0, 0) self.numGroups = 2 self.numMicroGroups = 4
def getUniv(): return HomogUniv('truth', 0, 0, 0)
def getParams(): """Return the universe, vector, and matrix for testing.""" univ = HomogUniv(300, 0, 0, 0) vec = arange(NUM_GROUPS) mat = arange(NUM_GROUPS**2) return univ, vec, mat
def test_badinit(self): """Verify that a HomogUniv cannot be constructed with negative time""" self._wrapBadInit(-1, 0, None) self._wrapBadInit(None, None, -10.0) # good init HomogUniv('good', None, None, None)
def _wrapBadInit(self, *initArgs): msg = "Args: {}".format(initArgs) with self.assertRaises(SerpentToolsException, msg=msg): HomogUniv('badInit', *initArgs)