Commit 33be05de authored by Matt Cumber's avatar Matt Cumber
Browse files

Re #30905 Updated Window Title

Fixed some tests from ALC data loading presenter
parent 9b112dc6
......@@ -237,6 +237,7 @@ void LoadMuonNexus1::exec() {
addToSampleLog("frames_period_requested", nxload.m_framesPeriodsRequested, localWorkspace);
addToSampleLog("frames_period_raw", nxload.m_framesPeriodsRaw, localWorkspace);
addToSampleLog("period_output", nxload.m_periodsOutput, localWorkspace);
addToSampleLog("total_counts_period", nxload.m_periodsCounts, localWorkspace);
size_t counter = 0;
for (auto i = m_spec_min; i < m_spec_max; ++i) {
......
......@@ -164,17 +164,16 @@ void MuonNexusReader::readFromFile(const string &filename) {
* - Total counts per period
*/
void MuonNexusReader::readPeriodInfo(NeXus::File &handle) {
int tempInt;
std::string tempString;
std::vector<int> tempIntVector;
std::vector<float> tempFloatVector;
try {
int tempInt;
handle.readData(PERIOD_SEQUENCES, tempInt);
m_numPeriodSequences = tempInt;
} catch (...) {
g_log.debug("Muon nexus file does not contain " + PERIOD_SEQUENCES);
}
try {
std::string tempString;
handle.readData(PERIOD_LABELS, tempString);
m_periodNames = tempString;
} catch (...) {
......@@ -205,6 +204,7 @@ void MuonNexusReader::readPeriodInfo(NeXus::File &handle) {
g_log.debug("Muon nexus file does not contain " + PERIOD_OUTPUT);
}
try {
std::vector<float> tempFloatVector;
handle.readData(TOTAL_COUNTS_PERIOD, tempFloatVector);
m_periodsCounts = convertVectorToString(tempFloatVector, ";");
} catch (...) {
......
......@@ -204,7 +204,7 @@ public:
EXPECT_CALL(*m_view, getFirstFile()).WillRepeatedly(Return("MUSR00015189.nxs"));
// Test logs
EXPECT_CALL(*m_view, setAvailableLogs(AllOf(Property(&std::vector<std::string>::size, 39), Contains("run_number"),
EXPECT_CALL(*m_view, setAvailableLogs(AllOf(Property(&std::vector<std::string>::size, 46), Contains("run_number"),
Contains("sample_magn_field"), Contains("Field_Danfysik"))))
.Times(1);
// Test periods
......@@ -223,7 +223,7 @@ public:
EXPECT_CALL(*m_view, getFirstFile()).WillRepeatedly(Return("MUSR00015189.nxs"));
// Test logs
EXPECT_CALL(*m_view, setAvailableLogs(AllOf(Property(&std::vector<std::string>::size, 39), Contains("run_number"),
EXPECT_CALL(*m_view, setAvailableLogs(AllOf(Property(&std::vector<std::string>::size, 46), Contains("run_number"),
Contains("sample_magn_field"), Contains("Field_Danfysik"))))
.Times(1);
// Test periods
......
......@@ -35,7 +35,7 @@ class GroupingTabPresenter(object):
def __init__(self, view, model,
grouping_table_widget=None,
pairing_table_widget=None,
diff_table = None):
diff_table=None):
self._view = view
self._model = model
......@@ -296,6 +296,14 @@ class GroupingTabPresenter(object):
self.period_info_widget.show()
def _add_period_info_to_widget(self):
runs = self._model._data.current_runs
runs_string = ""
for run_list in runs:
for run in run_list:
if runs_string:
runs_string += ", "
runs_string += str(run)
self.period_info_widget.set_title_runs(self._model.instrument + runs_string)
period_sequences_log = self._model._data.get_sample_log("period_sequences")
self.period_info_widget.number_of_sequences = str(period_sequences_log.value) if period_sequences_log else None
names_log = self._model._data.get_sample_log("period_labels")
......
......@@ -32,6 +32,7 @@ class GroupingTabView(QtWidgets.QWidget):
self.period_label = None
self.subtracted_period_edit = None
self.minus_label = None
self._parent = parent
self._grouping_table = grouping_table
self._pairing_table = pairing_table
......
......@@ -95,6 +95,9 @@ class MuonPeriodInfoWidget(QtWidgets.QWidget):
for row in reversed(range(self._num_rows())):
self._table.removeRow(row)
def set_title_runs(self, text):
self.setWindowTitle("Period Information for Run(s) " + text)
def _new_text_widget(self, text):
new_widget = table_utils.ValidatedTableItem(lambda text: True)
new_widget.setText(text)
......
......@@ -63,6 +63,10 @@ class MuonPeriodInfoWidgetTest(unittest.TestCase):
self.widget.number_of_sequences = "100"
self.assertEqual("Run contains 100 cycles of periods", str(self.widget._label.text()))
def test_set_title(self):
self.widget.set_title_runs("HIFI110542")
self.assertEqual("Period Information for Run(s) HIFI110542", self.widget.windowTitle())
if __name__ == '__main__':
unittest.main(buffer=False, verbosity=2)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment