def createTestObjs(self): self.trajStepA = trajCoreHelp.TrajStepBase(unitCell=self.uCells[0], step=self.steps[0]) self.trajStepB = trajCoreHelp.TrajStepBase(unitCell=self.uCells[1], step=self.steps[1]) self.trajObjA = trajCoreHelp.TrajectoryInMemory( [self.trajStepA, self.trajStepB])
def _getExpectedValsA(self): expTrajA = trajHelp.TrajectoryInMemory( [trajHelp.TrajStepBase(step=step) for step in [0, 1]]) expTrajB = trajHelp.TrajectoryInMemory( [trajHelp.TrajStepBase(step=step) for step in [2, 3]]) expTrajC = trajHelp.TrajectoryInMemory( [trajHelp.TrajStepBase(step=step) for step in [4, 5]]) return [expTrajA, expTrajB, expTrajC]
def createTestObjs(self): self.trajStepA = tCode.TrajStepBase(time=self.timeA, step=self.stepA, unitCell=self.unitCellA) self.trajStepB = tCode.TrajStepBase(time=self.timeB, step=self.stepB, unitCell=self.unitCellA) self.testObjA = tCode.TrajectoryInMemory( [self.trajStepA, self.trajStepB])
def createTestObjs(self): self._createCells() self.trajStepA = trajHelp.TrajStepBase(unitCell=self.cellA, step=self.stepA, time=self.timeA) self.trajStepB = trajHelp.TrajStepBase(unitCell=self.cellB, step=self.stepB, time=self.timeB) trajSteps = [self.trajStepA, self.trajStepB] self.testObjA = trajHelp.TrajectoryInMemory(trajSteps)
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellB = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords, self.cellB.cartCoords = self.coordsA, self.coordsB self.trajStepA = trajHelp.TrajStepBase(unitCell=self.cellA) self.trajStepB = trajHelp.TrajStepBase(unitCell=self.cellB) self.fullTrajA = trajHelp.TrajectoryInMemory( [self.trajStepA, self.trajStepB])
def createTestObjs(self): self.trajA = tCode.TrajectoryInMemory( [tCode.TrajStepBase(step=x) for x in self.stepsA]) self.trajB = tCode.TrajectoryInMemory( [tCode.TrajStepBase(step=x) for x in self.stepsB]) self.trajC = tCode.TrajectoryInMemory( [tCode.TrajStepBase(step=x) for x in self.stepsC]) self.trajListA = [self.trajA, self.trajB, self.trajC] allSteps = self.stepsA + self.stepsB + self.stepsC self.expTrajStd = tCode.TrajectoryInMemory( [tCode.TrajStepBase(step=x) for x in allSteps])
def createTestObjs(self): self.trajStepA = trajHelp.TrajStepBase(unitCell=self.unitCellA, step=self.stepA, time=self.timeA) self.trajStepB = trajHelp.TrajStepBase(unitCell=self.unitCellB, step=self.stepB, time=self.timeB) self.testTrajA = trajHelp.TrajectoryInMemory( [self.trajStepA, self.trajStepB]) self.testRecord = { self.folderKeyA: self.folderPathA, self.fileKeyA: self.fileNameA }
def testExpVals_step0InXyz(self, mockedParseCpout, mockedParseXyz): #Modify the xyz output stepZeroXyz = {"coords": self.initCoords, "step": 0, "time": 0} self.parsedXyz.insert(0, stepZeroXyz) #modify the expected dict trajStepZero = trajHelp.TrajStepBase(unitCell=copy.deepcopy( self.initMdCell), step=0, time=0) self.expDict["trajectory"].trajSteps = [ trajStepZero ] + self.expDict["trajectory"].trajSteps self.expDict["trajectory"].trajSteps[ 0].unitCell.cartCoords = self.initCoords for key in self.expDict["thermo_data"].dataDict.keys(): currVal = self.initThermoDict[key] self.expDict["thermo_data"].dataDict[key].insert(0, currVal) #Set mocks expCpoutPath, expXyzPath = "fake_cpout_path", "fake_xyz_path" mockedParseCpout.side_effect = lambda *args, **kwargs: self.parsedCpout mockedParseXyz.side_effect = lambda *args, **kwargs: self.parsedXyz #Run + test actDict = tCode.parseFullMdInfoFromCpoutAndXyzFilePaths( expCpoutPath, expXyzPath) mockedParseCpout.assert_called_with(expCpoutPath) mockedParseXyz.assert_called_with(expXyzPath) self.assertEqual(self.expDict, actDict)
def createTestObjs(self): kwargDict = { "step": self.step, "unitCell": self.unitCell, "time": self.time } self.testObjA = tCode.TrajStepBase(**kwargDict)
def createTestObjs(self): #Create thermo arrays + thermoDataObj self.thermalArraysA = { "step": self.steps, "time": self.times, "eKinetic": self.eKinetic } self.thermoDataA = thermoHelp.ThermoDataStandard(self.thermalArraysA) #thngs to help mocking trajSteps = [ trajHelp.TrajStepBase(unitCell=self.emptyCellA, step=self.steps[0], time=self.times[0]), trajHelp.TrajStepBase(unitCell=self.emptyCellB, step=self.steps[1], time=self.times[1]) ] self.outTrajA = trajHelp.TrajectoryInMemory(trajSteps) self.parsedCpout = { "trajectory": self.outTrajA, "thermo_data": self.thermoDataA, "init_thermo_dict": self.initThermoDict, "init_md_cell": self.initMdCell } self.parsedXyz = [{ "coords": self.coordsA, "step": self.steps[0], "time": self.times[0] }, { "coords": self.coordsB, "step": self.steps[1], "time": self.times[1] }] #Expected output self.expCellA, self.expCellB = copy.deepcopy( self.emptyCellA), copy.deepcopy(self.emptyCellB) self.expCellA.cartCoords = self.coordsA self.expCellB.cartCoords = self.coordsB expTrajSteps = copy.deepcopy(trajSteps) expTrajSteps[0].unitCell.cartCoords = self.coordsA expTrajSteps[1].unitCell.cartCoords = self.coordsB self.expDict = dict() self.expDict["trajectory"] = trajHelp.TrajectoryInMemory(expTrajSteps) self.expDict["thermo_data"] = copy.deepcopy(self.thermoDataA)
def testInPlaceExpected(self): self.inPlace = True self.createView = False expSteps = [trajHelp.TrajStepBase(step=s) for s in [0, 2, 4, 6]] expTraj = trajHelp.TrajectoryInMemory(expSteps) self._runTestFunct() actTraj = self.inpTrajA self.assertEqual(expTraj, actTraj)
def testExpectedStepsWithUnitOverlap_overlapStratSimple(self): self.stepsA.append(4) self.createTestObjs() expSteps = [1, 2, 3, 4, 5, 6, 7, 8, 9] expTraj = tCode.TrajectoryInMemory( [tCode.TrajStepBase(step=x) for x in expSteps]) actTraj = tCode.getMergedTrajInMemory(self.trajListA, overlapStrat="simple") self.assertEqual(expTraj, actTraj)
def testExpectedTrajReturnedA(self, mockGetFileList): #Set out mock mockGetFileList.side_effect = lambda *args,**kwargs: self.fileListA #Figure out expected trajectory cellA = uCellHelp.UnitCell.fromLattVects([[6.06,0,0],[-3, 5.2, 0], [0, 0, 9.8]]) cellB = uCellHelp.UnitCell.fromLattVects([[5,0,0], [0,6,0], [0,0,7]]) coordsA = [ [1,1,1,"Mg"], [3,3,3,"X"] ] coordsB = [ [2,3,4,"Mg"], [4,5,6,"X"] ] cellA.cartCoords, cellB.cartCoords = coordsA, coordsB stepA = trajHelp.TrajStepBase(unitCell=cellA) stepB = trajHelp.TrajStepBase(unitCell=cellB) expTraj = trajHelp.TrajectoryInMemory([stepA,stepB]) #Run + test actTraj = tCode.readTrajFromSimpleExtendedXyzFormat(self.inpPathA) mockGetFileList.assert_called_with(self.inpPathA) self.assertEqual(expTraj,actTraj)
def _loadExpectedObjsForFullStrA(self): lattVectsBoth = [ [9.63 , 0 , 0 ], [-4.81018, 8.33982, 0 ], [0 , 0 , 17.87895] ] cartCoordsA = [ [0.40125, 2.08496, 1.11743, "1"], [0.0226 , 3.0105 , 1.11743, "2"], [1.39212, 2.21981, 1.11743, "2"], [3.61125, 2.08496, 1.11743, "1"], [3.2326 , 3.0105 , 1.11743, "2"], [4.60212, 2.21981, 1.11743, "2"] ] cartCoordsB = [ [-0.426578, 1.73786, 0.96724 ,"1"], [0.148568 , 2.48075, 1.30372 ,"2"], [-1.43515 , 1.8717 , 1.23895 ,"2"], [4.47632 , 2.423 , 0.945189,"1"], [3.6439 , 2.54601, 1.57979 ,"2"], [4.44324 , 1.45043, 0.686697,"2"] ] if self.typeIdxToEle is not None: for idx,vals in enumerate(cartCoordsA): cartCoordsA[idx][-1] = self.typeIdxToEle[ cartCoordsA[idx][-1] ] for idx,vals in enumerate(cartCoordsB): cartCoordsB[idx][-1] = self.typeIdxToEle[ cartCoordsB[idx][-1] ] self.cellA = uCellHelp.UnitCell.fromLattVects(lattVectsBoth) self.cellB = uCellHelp.UnitCell.fromLattVects(lattVectsBoth) self.cellA.cartCoords = cartCoordsA self.cellB.cartCoords = cartCoordsB if self.timeStep is None: self.trajStepA = trajObjHelp.TrajStepBase(unitCell=self.cellA, step=0 , time=None) self.trajStepB = trajObjHelp.TrajStepBase(unitCell=self.cellB, step=50, time=None) else: self.trajStepA = trajObjHelp.TrajStepBase(unitCell=self.cellA, step=0 , time=0) self.trajStepB = trajObjHelp.TrajStepBase(unitCell=self.cellB, step=50, time=50*self.timeStep) self.expTrajObjA = trajObjHelp.TrajectoryInMemory([self.trajStepA, self.trajStepB])
def _loadTrajInMemoryA(): outStepVals = [0, 1, 2, 3] outTimeVals = [2, 4, 6, 8] outGeomVals = [mock.Mock() for x in outStepVals] outIter = [[ a, b, c ] for a, b, c in it.zip_longest(outGeomVals, outStepVals, outTimeVals)] outTrajSteps = [ tCode.TrajStepBase(unitCell=cell, step=step, time=time) for cell, step, time in outIter ] return tCode.TrajectoryInMemory(outTrajSteps)
def testExpectedStepsWithOverhang_trimStratSimple(self): self.stepsA = [1, 2, 3, 4, 5] self.stepsB = [ 4, 6 ] #Deleting step 5 makes it more likely we really are taking the step 4 from this set of trajs self.stepsC = [7, 8, 9] self.createTestObjs() expSteps = [1, 2, 3, 4, 6, 7, 8, 9] expTraj = tCode.TrajectoryInMemory( [tCode.TrajStepBase(step=x) for x in expSteps]) actTraj = tCode.getMergedTrajInMemory(self.trajListA, overlapStrat="simple", trimStrat="simple") self.assertEqual(expTraj, actTraj)
def createTestObjs(self): self.thermoDataA = thermoHelp.ThermoDataStandard({"step": self.stepsA}) self.thermoDataB = thermoHelp.ThermoDataStandard({"step": self.stepsB}) self.trajA = trajHelp.TrajectoryInMemory( [trajHelp.TrajStepBase(step=x) for x in self.stepsA]) self.trajB = trajHelp.TrajectoryInMemory( [trajHelp.TrajStepBase(step=x) for x in self.stepsB]) self.retDictA = { "trajectory": self.trajA, "thermo_data": self.thermoDataA } self.retDictB = { "trajectory": self.trajB, "thermo_data": self.thermoDataB } self.expThermoData = thermoHelp.ThermoDataStandard( {"step": self.stepsA + self.stepsB}) self.expTraj = trajHelp.TrajectoryInMemory( [trajHelp.TrajStepBase(step=x) for x in self.stepsA + self.stepsB]) self.expDictA = { "trajectory": self.expTraj, "thermo_data": self.expThermoData }
def createTestObjs(self): self.cellA = _getWaterDimerCellFromOxygenOxygenSep(self.oxyDistA) self.cellB = _getWaterDimerCellFromOxygenOxygenSep(self.oxyDistB) trajA = trajHelp.TrajStepBase(unitCell=self.cellA, step=0) trajB = trajHelp.TrajStepBase(unitCell=self.cellB, step=50) self.trajObj = trajHelp.TrajectoryInMemory([trajA,trajB])
def testExpValsA(self): expSteps = [trajHelp.TrajStepBase(step=s) for s in [0, 2, 4, 6]] expTraj = trajHelp.TrajectoryInMemory(expSteps) actTraj = self._runTestFunct() self.assertEqual(expTraj, actTraj)
def createTestObjs(self): self.trajSteps = [ trajHelp.TrajStepBase(step=step) for step in self.steps ] self.inpTrajA = trajHelp.TrajectoryInMemory(self.trajSteps)
def createTestObjs(self): self.cellA.cartCoords = self.coordsA self.cellB.cartCoords = self.coordsB self.trajStepA = trajHelp.TrajStepBase(unitCell=self.cellA, step=self.stepA, time=self.timeA) self.trajStepB = trajHelp.TrajStepBase(unitCell=self.cellB, step=self.stepB, time=self.timeB) self.testTrajA = trajHelp.TrajectoryInMemory([self.trajStepA, self.trajStepB])