def testAdsFoundWhenAtomsInNeighbouringCells(self): self.cartCoordsA[2] = [5,5,0.5,"H"] self.cartCoordsA[3] = [5,5,9.5,"H"] self.createTestObjs() expAds = [ types.SimpleNamespace(geom=[ [5,5,0.5,"H"], [5,5,-0.5,"H"] ]), types.SimpleNamespace(geom=[ [5,5,9.5,"H"], [5,5,10.5,"H"] ]) ] actAds = self.detectorA( self.testCellA ) for exp,act in it.zip_longest(expAds, actAds): adsRepObjs.adsorbatesSameWithinError(exp,act)
def testExpectedForTopRequiringWrappingIntoCentralCell(self): self.cartCoordsA[0] = [5,5, 11,"X"] #Should appear above if i dont wrap into central cell self.createTestObjs() expAdsObjs = [ types.SimpleNamespace(geom= [[5,5,7,"X"]]) ] actAdsObjs = self.testAdsDetector(self.testCellA) for exp,act in it.zip_longest(expAdsObjs, actAdsObjs): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testExpectedForBottomSimple(self): self.top=False self.createTestObjs() expAdsObjs = [ types.SimpleNamespace(geom= [[5,5,3,"X"]]) ] actAdsObjs = self.testAdsDetector(self.testCellA) for exp,act in it.zip_longest(expAdsObjs, actAdsObjs): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testWithoutCaseSensitivity(self): self.caseSensitive = False self.createTestObjs() expAdsObjs = [ types.SimpleNamespace(geom=[ [5,6,4,self.eleSymbol] ]), types.SimpleNamespace(geom=[ [6,6,6, self.eleSymbol.lower()] ]) ] actAdsObjs = self.testObjA( self.testCellA ) for exp,act in it.zip_longest(expAdsObjs, actAdsObjs): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testWhenOneHInImageCell(self): self.cartCoordsA[1] = [0,5, 9.5,"H"] self.cartCoordsA[4] = [0,4, 0.5,"O"] self.cartCoordsA[2] = [0,5, 1.5,"H"] self.createTestObjs() expAds = [ types.SimpleNamespace(geom=[ self.cartCoordsA[4], self.cartCoordsA[2], [0,5,-0.5,"H"] ]), types.SimpleNamespace(geom=[ self.cartCoordsA[1], [0,4,10.5,"O"], [0,5,11.5,"H"] ]) ] actAds = self.detectorA( self.testCellA ) for exp,act in it.zip_longest(expAds, actAds): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testWhenBothHInImageCell(self): #Shift to separate H and O into different cells self.cartCoordsA[1][1] = 0.9 #H self.cartCoordsA[2][1] = 0.9 #H self.cartCoordsA[4][1] = 9.9 #O self.createTestObjs() expAds = [ types.SimpleNamespace(geom=[ [0, 9.9,6,"O"], [0,10.9,5,"H"], [0,10.9,7,"H"] ]), types.SimpleNamespace(geom=[ [0, 0.9,5,"H"], [0, 0.9,7,"H"], [0,-0.1,6,"O"] ]) ] actAds = self.detectorA( self.testCellA ) for exp,act in it.zip_longest(expAds,actAds): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testUnequalAdsorbateObjsCompareUnequal_diffCoords(self): adsA, adsB = self.adsorbateA, self.adsorbateB expVal = False #Not equal actVal = tCode.adsorbatesSameWithinError(adsA, adsB) self.assertEqual(expVal, actVal)
def testUnequalAdsorbateObjsCompareUnequal_diffEleLists(self): adsA, adsB = self.adsorbateA, self.adsorbateC expVal = False actVal = tCode.adsorbatesSameWithinError(adsA, adsB) self.assertEqual(expVal, actVal)
def testEqualAdsorbateObjsCompareEqual(self): copiedAdsorbate = copy.deepcopy(self.adsorbateA) objsEqual = tCode.adsorbatesSameWithinError(self.adsorbateA, copiedAdsorbate) self.assertTrue(objsEqual)
def testAdsBothInSameCellA_distCriteriaOnly(self): expAds = [types.SimpleNamespace(geom=[ [0,4,6,"O"], [0,5,5,"H"], [0,5,7,"H"] ])] actAds = self.detectorA( self.testCellA ) for exp,act in it.zip_longest(expAds,actAds): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testExpectedForTopSimple(self): expAdsObjs = [ types.SimpleNamespace(geom= [[5,5,7,"X"]]) ] actAdsObjs = self.testAdsDetector(self.testCellA) for exp,act in it.zip_longest(expAdsObjs, actAdsObjs): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testDetectWithCaseSensitivity(self): expAdsObjs = [ types.SimpleNamespace(geom=[[5,6,4,self.eleSymbol]]) ] actAdsObjs = self.testObjA( self.testCellA ) for exp,act in it.zip_longest(expAdsObjs, actAdsObjs): self.assertTrue( adsRepObjs.adsorbatesSameWithinError(exp,act) )
def testAdsFoundWhenBothInSameCellA(self): expAds = [ types.SimpleNamespace(geom =[[5,5,7,"H"], [5,5,8,"H"]]) ] actAds = self.detectorA( self.testCellA ) for exp,act in it.zip_longest(expAds,actAds): adsRepObjs.adsorbatesSameWithinError(exp,act)
def checkExpListMatchesActual(self, expLists, actLists): for expList, actList in it.zip_longest(expLists, actLists): for e, a in it.zip_longest(expList, actList): self.assertTrue(adsRepObjs.adsorbatesSameWithinError(e, a))