Skip to content

Commit

Permalink
inelastic correction column is now checked. This refs #134
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Apr 16, 2019
1 parent e47494b commit cb06295
Showing 1 changed file with 59 additions and 10 deletions.
69 changes: 59 additions & 10 deletions addie/processing/mantid/master_table/column_highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def check(self):
elif column in INDEX_OF_COLUMNS_WITH_GEOMETRY_INFOS:
are_all_the_same = self.are_geometry_identical()

elif (column in INDEX_OF_ABS_CORRECTION) or \
(column in INDEX_OF_MULTI_SCATTERING_CORRECTION):
are_all_the_same = self.are_abs_or_multi_correction_identical()
elif column in INDEX_OF_ABS_CORRECTION:
are_all_the_same = self.are_abs_correction_identical()

elif column in INDEX_OF_MULTI_SCATTERING_CORRECTION:
are_all_the_same = self.are_multi_correction_identical()

elif column in INDEX_OF_INELASTIC_CORRECTION:
are_all_the_same = self.are_inelastic_correction_identical()
Expand All @@ -75,16 +77,16 @@ def check(self):

def apply_cell_background(self, are_all_the_same=False):
if are_all_the_same:
background_color = QtGui.QColor(COLUMNS_IDENTICAL_VALUES_COLOR[0],
COLUMNS_IDENTICAL_VALUES_COLOR[1],
COLUMNS_IDENTICAL_VALUES_COLOR[2])
# background_color = QtGui.QColor(COLUMNS_IDENTICAL_VALUES_COLOR[0],
# COLUMNS_IDENTICAL_VALUES_COLOR[1],
# COLUMNS_IDENTICAL_VALUES_COLOR[2])
background_color_stylesheet = "rgb({}, {}, {})".format(COLUMNS_IDENTICAL_VALUES_COLOR[0],
COLUMNS_IDENTICAL_VALUES_COLOR[1],
COLUMNS_IDENTICAL_VALUES_COLOR[2])
else:
background_color = QtGui.QColor(COLUMNS_SAME_VALUES_COLOR[0],
COLUMNS_SAME_VALUES_COLOR[1],
COLUMNS_SAME_VALUES_COLOR[2])
# background_color = QtGui.QColor(COLUMNS_SAME_VALUES_COLOR[0],
# COLUMNS_SAME_VALUES_COLOR[1],
# COLUMNS_SAME_VALUES_COLOR[2])
background_color_stylesheet = "rgb({}, {}, {})".format(COLUMNS_SAME_VALUES_COLOR[0],
COLUMNS_SAME_VALUES_COLOR[1],
COLUMNS_SAME_VALUES_COLOR[2])
Expand Down Expand Up @@ -179,10 +181,37 @@ def are_geometry_identical(self):

return True

def are_abs_or_multi_correction_identical(self):
def are_abs_correction_identical(self):
ref_value = self._get_abs_correction_widget_value(row=0)
for _row in np.arange(1, self.nbr_row):
_value = self._get_abs_correction_widget_value(row=_row)
if _value != ref_value:
return False
return True

def are_multi_correction_identical(self):
ref_value = self._get_multi_correction_widget_value(row=0)
for _row in np.arange(1, self.nbr_row):
_value = self._get_multi_correction_widget_value(row=_row)
if _value != ref_value:
return False
return True

def are_inelastic_correction_identical(self):
ref_value = self._get_inelastic_correction_widget_value(row=0)
for _row in np.arange(1, self.nbr_row):
_value = self._get_inelastic_correction_widget_value(row=_row)
if _value != ref_value:
return False

# if placzek selected,
if ref_value.lower() == 'placzek':
ref_dict = self._get_placzek_infos(row=0)
for _row in np.arange(1, self.nbr_row):
_dict = self._get_placzek_infos(row=_row)
if _dict != ref_dict:
return False

return True

def are_align_and_focus_args_identical(self):
Expand Down Expand Up @@ -237,3 +266,23 @@ def _are_geometry_value_identical(self, variable_name='radius'):
if _value != ref_radius:
return False
return True

def _get_abs_correction_widget_value(self, row=-1):
master_table_list_ui_for_row = self._get_master_table_list_ui_for_row(row=row)
widget_ui = master_table_list_ui_for_row[self.data_type]['abs_correction']
return str(widget_ui.currentText())

def _get_multi_correction_widget_value(self, row=-1):
master_table_list_ui_for_row = self._get_master_table_list_ui_for_row(row=row)
widget_ui = master_table_list_ui_for_row[self.data_type]['mult_scat_correction']
return str(widget_ui.currentText())

def _get_inelastic_correction_widget_value(self, row=-1):
master_table_list_ui_for_row = self._get_master_table_list_ui_for_row(row=row)
widget_ui = master_table_list_ui_for_row[self.data_type]['inelastic_correction']
return str(widget_ui.currentText())

def _get_placzek_infos(self, row=-1):
master_table_list_ui_for_row = self._get_master_table_list_ui_for_row(row=row)
dict = master_table_list_ui_for_row[self.data_type]['placzek_infos']
return dict

0 comments on commit cb06295

Please sign in to comment.