def testUpdate(self): t = output_handler.readOutput('../test/test.out') t.update(force=True) #these values for the COM's are hard coded, unfortunately. But they are correct. self.assertTrue(len(t.centerOfMass) == 3) print(t.centerOfMass) self.assertTrue( round( abs(t.centerOfMass[0] - 0.7835947518080879) + abs(t.centerOfMass[1] - 0.2947546230649471) + abs(t.centerOfMass[2] + 0.1318053758650839), prec) == 0) self.assertTrue(len(t.centerOfMomentum) == 3) self.assertTrue( round( abs(t.centerOfMomentum[0] - 6.001115213580641) + abs(t.centerOfMomentum[1] + 65.29652414026405) + abs(t.centerOfMomentum[2] + 26.462554427407223), prec) == 0) self.assertTrue(len(t.distFromCOM) == len(t)) self.assertTrue( round( abs(t.distFromCOM[0] - ((t.centerOfMass[0] - t.x[0])**2 + (t.centerOfMass[1] - t.y[0])**2 + (t.centerOfMass[2] - t.z[0])**2)**0.5), prec) == 0)
def testSubsetRect(self): t = output_handler.readOutput('../test/test.out') tc = t.copy() tc.subsetRect(('x', ), ((-1, 1), )) self.assertTrue(len(tc) == 7)
def testCopy(self): d = output_handler.readOutput('../test/test.out') d2 = d.copy() d.x[0] = 0 self.assertTrue(d.x[0] != d2.x[0])
def testAppendPoint(self): t = output_handler.readOutput('../test/test.out') t2 = t.copy() t2.appendPoint(t, 5) self.assertTrue(t.x[5] == t2.x[-1]) self.assertTrue(len(t2) == len(t) + 1)
def testCopy(self): t = output_handler.readOutput('../test/test.out') t2 = t.copy() test = t.x[0] t.x[0] = 0 self.assertTrue(t.x[0] != t2.x[0]) self.assertTrue(t2.x[0] == test)
def testAppendPoint(self): d = output_handler.readOutput('../test/test.out') d2 = d.copy() d2.appendPoint(d, 5) self.assertTrue(d.x[5] == d2.x[-1]) self.assertTrue(len(d2) == len(d)+1)
def testCalcs(self): #this just makes sure that the values that #are not initially calculated on instantiation then run when the user #tries to get those values t = output_handler.readOutput('../test/test.out') print(len(t.pmra)) self.assertTrue(len(t.pmra) == len(t)) self.assertTrue(len(t.energy) == len(t))
def testTimestepIter(self): t = output_handler.readOutput('../test/test.out') for key, k in zip(t, t.indexList): self.assertTrue(t[key][0] == t[k][0]) t[key][0] = 1 self.assertTrue(t.x[0] == t['x'][0] == 1) for key in t: t[key] = np.append(t[key], 0) self.assertTrue(t.x[-1] == t['x'][-1] == 0)
def testDataIter(self): d = output_handler.readOutput('../test/test.out') for key, k in zip(d, d.indexList): self.assertTrue(d[key][0] == d[k][0]) d[key][0] = 1 self.assertTrue(d.x[0] == d['x'][0] == 1) for key in d: d[key] = np.append(d[key], 0) self.assertTrue(d.x[-1] == d['x'][-1] == 0)
def testSplit(self): t = output_handler.readOutput('../test/test.out') t1, t2 = t.split(5) self.assertTrue(t1.x[0] == t.x[0]) self.assertTrue(t2.x[0] == t.x[5])
def testTimestepDict(self): t = output_handler.readOutput('../test/test.out') self.assertTrue(t.x[0] == t['x'][0]) t.x[0] = 1 self.assertTrue(t['x'][0] == 1)
def testTimestepInitialize(self): t = Timestep() #check default initialization t = output_handler.readOutput( '../test/test.out') #check loading from a file
def testSplit(self): d = output_handler.readOutput('../test/test.out') d1, d2 = d.split(5) self.assertTrue(d1.x[0] == d.x[0]) self.assertTrue(d2.x[0] == d.x[5])
def testDataDict(self): d = output_handler.readOutput('../test/test.out') self.assertTrue(d.x[0] == d['x'][0]) d.x[0] = 1 self.assertTrue(d['x'][0] == 1)
def testDataInitialize(self): d = Data() #check default initialization d = output_handler.readOutput('../test/test.out') #check loading from a file