Commit a3824d25 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #14124. Start fixing up DataHandling.

parent 5d01e8de
......@@ -444,6 +444,8 @@ void LoadMLZ::runLoadInstrument() {
loadInst->setPropertyValue("InstrumentName", m_instrumentName);
g_log.debug() << "InstrumentName" << m_instrumentName << std::endl;
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
loadInst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
loadInst->execute();
} catch (...) {
g_log.information("Cannot load the instrument definition.");
......
......@@ -853,7 +853,8 @@ void LoadMask::intializeMaskWorkspace() {
else
loadInst->setPropertyValue("Filename", m_instrumentPropValue);
loadInst->setProperty("RewriteSpectraMap", false);
loadInst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
loadInst->executeAsChildAlg();
if (!loadInst->isExecuted()) {
......
......@@ -145,7 +145,8 @@ void LoadMuonNexus::runLoadInstrument(
try {
loadInst->setPropertyValue("InstrumentName", m_instrument_name);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
loadInst->setProperty("RewriteSpectraMap", false);
loadInst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
loadInst->execute();
} catch (std::invalid_argument &) {
g_log.information("Invalid argument to LoadInstrument Child Algorithm");
......
......@@ -233,7 +233,7 @@ void LoadPreNexusMonitors::runLoadInstrument(
try {
loadInst->setPropertyValue("InstrumentName", instrument);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
loadInst->setProperty("RewriteSpectraMap",
loadInst->setProperty("OverwriteSpectraMap",
false); // We have a custom mapping
loadInst->execute();
......
......@@ -544,8 +544,10 @@ void LoadRawHelper::runLoadInstrument(
try {
loadInst->setPropertyValue("InstrumentName", instrumentID);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
loadInst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
loadInst->setProperty(
"RewriteSpectraMap",
"OverwriteSpectraMap",
false); // No point as we will load the one from the file
loadInst->execute();
} catch (std::invalid_argument &) {
......
......@@ -436,7 +436,8 @@ void LoadSpice2D::runLoadInstrument(
loadInst->setPropertyValue("InstrumentName", inst_name);
loadInst->setProperty<API::MatrixWorkspace_sptr>("Workspace",
localWorkspace);
loadInst->setProperty("RewriteSpectraMap", false);
loadInst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
loadInst->execute();
} catch (std::invalid_argument &) {
g_log.information("Invalid argument to LoadInstrument Child Algorithm");
......
......@@ -674,7 +674,8 @@ void LoadSpiceXML2DDet::loadInstrument(API::MatrixWorkspace_sptr matrixws,
loadinst->setProperty("Filename", idffilename);
} else
loadinst->setProperty("InstrumentName", "HB3A");
loadinst->setProperty("RewriteSpectraMap", true);
loadinst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
loadinst->execute();
if (loadinst->isExecuted())
matrixws = loadinst->getProperty("Workspace");
......
......@@ -622,7 +622,8 @@ Geometry::Instrument_const_sptr LoadVulcanCalFile::getInstrument() {
MatrixWorkspace_sptr tempWS(new Workspace2D());
childAlg->setProperty<MatrixWorkspace_sptr>("Workspace", tempWS);
childAlg->setPropertyValue("InstrumentName", InstrumentName);
childAlg->setProperty("RewriteSpectraMap", false);
childAlg->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
childAlg->executeAsChildAlg();
inst = tempWS->getInstrument();
......
......@@ -441,6 +441,7 @@ private:
std::string inputFile = "INES_Definition.xml";
loader.setPropertyValue("Filename", inputFile);
loader.setPropertyValue("Workspace", WS_Name);
loader.setProperty("OverwriteSpectraMap", Kernel::OptionalBool(true));
loader.execute();
return inputWS;
......
......@@ -798,6 +798,8 @@ public:
// Path to test input file
loaderGEM.setPropertyValue("Filename", "GEM_Definition.xml");
loaderGEM.setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
// inputFile = loaderIDF2.getPropertyValue("Filename");
loaderGEM.setPropertyValue("Workspace", workspaceName);
TS_ASSERT_THROWS_NOTHING(loaderGEM.execute());
......
......@@ -221,6 +221,8 @@ public:
"Filename", "IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING2.xml");
// inputFile = loaderIDF2.getPropertyValue("Filename");
pLoadInstrument->setPropertyValue("Workspace", wsName);
pLoadInstrument->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
TS_ASSERT_THROWS_NOTHING(pLoadInstrument->execute());
TS_ASSERT(pLoadInstrument->isExecuted());
}
......
......@@ -461,7 +461,8 @@ void ISISHistoDataListener::runLoadInstrument(
try {
loadInst->setPropertyValue("InstrumentName", iName);
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
loadInst->setProperty("RewriteSpectraMap", false);
loadInst->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
loadInst->executeAsChildAlg();
} catch (std::invalid_argument &) {
g_log.information("Invalid argument to LoadInstrument Child Algorithm");
......
......@@ -428,7 +428,8 @@ void ISISLiveEventDataListener::loadInstrument(const std::string &instrName) {
alg->initialize();
alg->setPropertyValue("InstrumentName", instrName);
alg->setProperty("Workspace", m_eventBuffer[0]);
alg->setProperty("RewriteSpectraMap", false);
alg->setProperty("OverwriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
alg->setChild(true);
alg->execute();
// check if the instrument was loaded
......
......@@ -1054,7 +1054,7 @@ createEventWorkspace3(Mantid::DataObjects::EventWorkspace_const_sptr sourceWS,
loadInst->setPropertyValue("InstrumentName",
sourceWS->getInstrument()->getName());
loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", outputWS);
loadInst->setProperty("RewriteSpectraMap", true);
loadInst->setProperty("OverwriteSpectraMap", true);
loadInst->executeAsChildAlg();
// Populate the instrument parameters in this workspace - this works around a
// bug
......
......@@ -195,6 +195,64 @@ public:
TS_ASSERT(Mock::VerifyAndClear(mockMeasurementSource));
}
void test_complex_example_two_groups_of_two() {
// Search result inforation not used in the following since we mock the
// return from the measurementSource
SearchResultMap data;
data.insert(
std::make_pair<std::string, SearchResult>("14913", SearchResult()));
data.insert(
std::make_pair<std::string, SearchResult>("14914", SearchResult()));
data.insert(
std::make_pair<std::string, SearchResult>("14915", SearchResult()));
data.insert(
std::make_pair<std::string, SearchResult>("14916", SearchResult()));
auto mockMeasurementSource = new MockReflMeasurementSource;
// All 3 have same measurment id, but we also have 2 with same sub id.
EXPECT_CALL(*mockMeasurementSource, obtain(_, _))
.Times(Exactly(static_cast<int>(data.size())))
.WillOnce(Return(Measurement("m1", "s1", "l1", "t1", 0.1, "14913")))
.WillOnce(Return(Measurement("m1", "s1", "l1", "t1", 0.1, "14914")))
.WillOnce(Return(Measurement("m2", "s1", "l1", "t1", 0.2, "14915")))
.WillOnce(Return(Measurement("m2", "s1", "l1", "t1", 0.2, "14916")));
auto mockCatInfo = new MockICatalogInfo;
// We expect that every location will be translated/transformed to make it
// os specific
EXPECT_CALL(*mockCatInfo, transformArchivePath(_))
.Times(Exactly(static_cast<int>(data.size())))
.WillRepeatedly(Return(std::string()));
MockProgressBase progress;
// Expect a progress update
EXPECT_CALL(progress, doReport(_))
.Times(Exactly(static_cast<int>(data.size())));
// Make the transfer stragegy
ReflMeasureTransferStrategy strategy(
std::move(std::unique_ptr<MockICatalogInfo>(mockCatInfo)),
std::move(
std::unique_ptr<MockReflMeasurementSource>(mockMeasurementSource)));
// Do the transfer
auto transferResult = strategy.transferRuns(data, progress);
// Check the transfer entries
TSM_ASSERT_EQUALS("Should have two rows", 2, transferResult.size());
TSM_ASSERT_DIFFERS("Runs should be the different for both columns",
transferResult[0][ReflTableSchema::RUNS],
transferResult[1][ReflTableSchema::RUNS]);
TSM_ASSERT_EQUALS("Runs should be summed. Sub ids are the same.",
"14913+14914", transferResult[0][ReflTableSchema::RUNS]);
TSM_ASSERT_EQUALS("Runs should be summed. Sub ids are the same.",
"14915+14916", transferResult[1][ReflTableSchema::RUNS]);
TS_ASSERT(Mock::VerifyAndClear(mockCatInfo));
TS_ASSERT(Mock::VerifyAndClear(mockMeasurementSource));
}
void test_do_not_include_invalid_measurements() {
// Search result inforation not used in the following since we mock the
// return from the measurementSource
......
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