fixed typos and other python warnings

This commit is contained in:
Vitesh Shah 2023-05-04 11:07:26 +02:00
parent 8de19f0c3b
commit b5b6c2d695
2 changed files with 36 additions and 42 deletions

View File

@ -1960,13 +1960,12 @@ class Result:
---------- ----------
target_dir : str or pathlib.Path, optional target_dir : str or pathlib.Path, optional
Directory to save DREAM3D files. Will be created if non-existent. Directory to save DREAM3D files. Will be created if non-existent.
""" """
Crystal_structures = {'fcc': 1, Phase_types = {'Primary': 0}
'bcc': 1, #further additions to these can be done by looking at 'Create Ensemble Info' filter
'hcp': 0, # other options could be 'Precipitate' and so on.
'bct': 7, # also crystal structures be added in a similar way
'ort': 6} #TODO: is bct Tetragonal low/Tetragonal high?
Phase_types = {'Primary': 0} #further additions to these can be done by looking at 'Create Ensemble Info' filter, other options could be 'Precipitate' and so on.
dx = self.size/self.cells dx = self.size/self.cells
@ -1986,7 +1985,7 @@ class Result:
cell_orientation_array[at_cell_ph[c][label],:] = \ cell_orientation_array[at_cell_ph[c][label],:] = \
Rotation(data[in_data_ph[c][label],:]).as_Euler_angles() Rotation(data[in_data_ph[c][label],:]).as_Euler_angles()
# Dream3D handles euler angles better # Dream3D handles euler angles better
except ValueError: #check if the exception is correct except ValueError:
print("Orientation data is not present") print("Orientation data is not present")
exit() # need to check if such a statement would really work. exit() # need to check if such a statement would really work.
@ -2036,8 +2035,10 @@ class Result:
# Data CrystalStructures # Data CrystalStructures
o[ensemble_label + '/CrystalStructures'] = np.uint32(np.array([999] + [1]*len(self.phases))) o[ensemble_label + '/CrystalStructures'] = np.uint32(np.array([999] + [1]*len(self.phases)))
# assuming only cubic crystal structures # assuming only cubic crystal structures
# Damask can give the crystal structure info but need to look into dream3d which crystal structure corresponds to which number # Damask can give the crystal structure info
o[ensemble_label + '/PhaseTypes'] = np.uint32(np.array([999] + [Phase_types['Primary']]*len(self.phases))).reshape((len(self.phases)+1,1)) # but need to look into dream3d which crystal structure corresponds to which number
o[ensemble_label + '/PhaseTypes'] = np.uint32(np.array([999] + [Phase_types['Primary']]*len(self.phases)))\
.reshape((len(self.phases)+1,1))
# also assuming Primary phases # also assuming Primary phases
# there can be precipitates etc as well # there can be precipitates etc as well
# Attributes Ensemble Matrix # Attributes Ensemble Matrix
@ -2065,13 +2066,6 @@ class Result:
o[geom_label].attrs['SpatialDimensionality'] = np.array([3],np.uint32) o[geom_label].attrs['SpatialDimensionality'] = np.array([3],np.uint32)
o[geom_label].attrs['UnitDimensionality'] = np.array([3],np.uint32) o[geom_label].attrs['UnitDimensionality'] = np.array([3],np.uint32)
def export_DADF5(self, def export_DADF5(self,
fname, fname,
output: Union[str, List[str]] = '*'): output: Union[str, List[str]] = '*'):

View File

@ -499,13 +499,13 @@ class TestResult:
for dataset in ['DIMENSIONS','ORIGIN','SPACING']: for dataset in ['DIMENSIONS','ORIGIN','SPACING']:
results_val = np.array(results_file[geom_label + '/' + dataset]) results_val = np.array(results_file[geom_label + '/' + dataset])
ref_val = np.array(ref_file[geom_label + '/' + dataset]) ref_val = np.array(ref_file[geom_label + '/' + dataset])
if not np.array_equal(ref_val,actual_val): if not np.array_equal(ref_val,results_val):
error_messages.append(f'The {dataset} values are incorrect') error_messages.append(f'The {dataset} values are incorrect')
for attrs in ['GeometryName','GeometryTypeName','GeometryType','SpatialDimensionality','UnitDimensionality']: for attrs in ['GeometryName','GeometryTypeName','GeometryType','SpatialDimensionality','UnitDimensionality']:
ref_value = ref_file[geom_label].attrs[attrs] ref_value = ref_file[geom_label].attrs[attrs]
actual_val = results_file[geom_label].attrs[attrs] actual_val = results_file[geom_label].attrs[attrs]
if not np.array_equal(ref_val,actual_val): if not np.array_equal(ref_value,actual_val):
error_messages.append("Geometry attributes do not match") error_messages.append("Geometry attributes do not match")
assert not error_messages assert not error_messages