def test_find_neighbors(self): m = Microstructure.from_h5( os.path.join(PYMICRO_EXAMPLES_DATA_DIR, 't5_dct_slice.h5')) neighbors = m.find_neighbors(grain_id=5, distance=3) self.assertEqual(len(neighbors), 9) for gid in [0, 1, 3, 14, 17, 18, 25, 51, 115]: self.assertTrue(gid in neighbors)
def test_to_h5(self): self.micro.to_h5() # read the file we have just written m = Microstructure.from_h5('%s.h5' % self.micro.name, grain_centroid=None) self.assertEqual(len(m.grains), len(self.test_eulers)) os.remove('%s.h5' % self.micro.name)
def test_from_h5(self): # read a test microstructure m = Microstructure.from_h5( os.path.join(PYMICRO_EXAMPLES_DATA_DIR, 't5_dct_slice.h5')) self.assertEqual(len(m.grains), 21) self.assertEqual(m.voxel_size, 0.0014) self.assertEqual(hasattr(m, 'grain_map'), True) self.assertEqual(hasattr(m, 'mask'), True)