def test_compare(self): test1 = PFData(('press.init.pfb')) test1.loadHeader() test1.loadData() test2 = PFData(('press.init.pfb')) test2.loadHeader() test2.loadData() self.assertEqual(PFData.differenceType_none, test1.compare(test2)[0], "test1 and test2 are the same") test1.setX(test1.getX() + 1.0) self.assertEqual(PFData.differenceType_x, test1.compare(test2)[0], "The x values differ") test1.setX(test1.getX() - 1.0) arr = test1.getDataAsArray() arr[1][2][3] += 1.0 ret, zyx = test1.compare(test2) self.assertEqual(PFData.differenceType_data, ret, "The data values differ") self.assertEqual((1, 2, 3), zyx, "The differing data's coordinates are correct") arr[1][2][3] -= 1.0 test1.close() test2.close()
def test_load_data_threaded(self): base = PFData(('press.init.pfb')) base.loadHeader() base.loadData() # 1 thread test1 = PFData(('press.init.pfb')) test1.loadHeader() test1.loadPQR() test1.loadDataThreaded(1) self.assertEqual(PFData.differenceType_none, base.compare(test1)[0], "base and test1 are the same") # 8 threads test8 = PFData(('press.init.pfb')) test8.loadHeader() test8.loadPQR() test8.loadDataThreaded(8) self.assertEqual(PFData.differenceType_none, base.compare(test8)[0], "base and test8 are the same") # 40 threads (more than the number of subgrids) test40 = PFData(('press.init.pfb')) test40.loadHeader() test40.loadPQR() test40.loadDataThreaded(40) self.assertEqual(PFData.differenceType_none, base.compare(test40)[0], "base and test40 are the same") base.close() test1.close() test8.close() test40.close()