def test_mirror(self,default,update,reference_dir,directions,reflect): modified = copy.deepcopy(default) modified.mirror(directions,reflect) tag = 'directions={}_reflect={}'.format('-'.join(directions),reflect) reference = os.path.join(reference_dir,'mirror_{}.geom'.format(tag)) if update: modified.to_file(reference) assert geom_equal(modified,Geom.from_file(reference))
def test_clean(self,default,update,reference_dir,stencil): modified = copy.deepcopy(default) modified.clean(stencil) tag = 'stencil={}'.format(stencil) reference = os.path.join(reference_dir,'clean_{}.geom'.format(tag)) if update: modified.to_file(reference) assert geom_equal(modified,Geom.from_file(reference))
def test_rotate(self,default,update,reference_dir,Eulers): modified = copy.deepcopy(default) modified.rotate(Rotation.from_Eulers(Eulers,degrees=True)) tag = 'Eulers={}-{}-{}'.format(*Eulers) reference = os.path.join(reference_dir,'rotate_{}.geom'.format(tag)) if update: modified.to_file(reference) assert geom_equal(modified,Geom.from_file(reference))
def test_scale(self,default,update,reference_dir,grid): modified = copy.deepcopy(default) modified.scale(grid) tag = 'grid={}'.format('-'.join([str(x) for x in grid])) reference = os.path.join(reference_dir,'scale_{}.geom'.format(tag)) if update: modified.to_file(reference) assert geom_equal(modified,Geom.from_file(reference))
def visualise_volume_element(volume_element): try: from damask import Geom geom_obj = Geom.from_file('geom.geom') geom_obj.to_vtr('geom.vtr') except ImportError: from damask import Grid grid_obj = Grid.load_ASCII('geom.geom') grid_obj.save('geom.vtr')
def test_pack(self,default,tmpdir,pack): default.to_file(tmpdir.join('default.geom'),pack=pack) new = Geom.from_file(tmpdir.join('default.geom')) assert geom_equal(new,default)
def test_write_read_file(self,default,tmpdir): with open(tmpdir.join('default.geom'),'w') as f: default.to_file(f) with open(tmpdir.join('default.geom')) as f: new = Geom.from_file(f) assert geom_equal(new,default)
def test_write_read_str(self,default,tmpdir): default.to_file(str(tmpdir.join('default.geom'))) new = Geom.from_file(str(tmpdir.join('default.geom'))) assert geom_equal(new,default)