diff --git a/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h b/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h index f01be6edae7cd287dba9df5fce3184e8f9b7dc60..f04d267a7033f08fcfa7d296cb07e46aab1c30ee 100644 --- a/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h @@ -36,6 +36,7 @@ public: private: void init() override; void exec() override; + bool checkGroups() override; // Validation split across several functions due to size std::map<std::string, std::string> validateInputs() override; void validateManualGroups(std::map<std::string, std::string> &errors); diff --git a/Framework/Muon/src/MuonPairingAsymmetry.cpp b/Framework/Muon/src/MuonPairingAsymmetry.cpp index 9800ac71bf53cef904092eabd7c1cfa6729293d3..d098bbd8560fdc2bfaef6dc6e521bc58dc001ac4 100644 --- a/Framework/Muon/src/MuonPairingAsymmetry.cpp +++ b/Framework/Muon/src/MuonPairingAsymmetry.cpp @@ -117,6 +117,11 @@ void MuonPairingAsymmetry::init() { "The workspace which will hold the results of the asymmetry " "calculation."); + // declareProperty(Mantid::Kernel::make_unique<WorkspaceProperty<Workspace>>( + // "OutputWorkspace", emptyString, Direction::Output), + // "The workspace which will hold the results of the asymmetry " + // "calculation."); + declareProperty("PairName", emptyString, "The name of the pair. Must " "contain at least one alphanumeric " @@ -281,6 +286,10 @@ void MuonPairingAsymmetry::validateGroupsWorkspaces( } } +bool MuonPairingAsymmetry::checkGroups(){ + return false; +} + void MuonPairingAsymmetry::exec() { MatrixWorkspace_sptr outWS; @@ -291,8 +300,11 @@ void MuonPairingAsymmetry::exec() { outWS = execGroupWorkspaceInput(); } + // outWS = boost::dynamic_pointer_cast<MatrixWorkspace>(outWS); + setPairAsymmetrySampleLogs(outWS); - setProperty("OutputWorkspace", outWS); + if(!outWS->isGroup()){ + setProperty("OutputWorkspace", outWS);} } MatrixWorkspace_sptr MuonPairingAsymmetry::execGroupWorkspaceInput() { diff --git a/Framework/Muon/test/MuonPairingAsymmetryTest.h b/Framework/Muon/test/MuonPairingAsymmetryTest.h index 0cd5bf3c87b7b36c4f2e9e6428876b2431eca889..b4a624895d9ed8d91745c81bdf2e8ae52b6c7c43 100644 --- a/Framework/Muon/test/MuonPairingAsymmetryTest.h +++ b/Framework/Muon/test/MuonPairingAsymmetryTest.h @@ -98,6 +98,7 @@ IAlgorithm_sptr setUpAlgorithmWithGroupWorkspaceGroups(WorkspaceGroup_sptr groupedWS1, WorkspaceGroup_sptr groupedWS2) { auto alg = boost::make_shared<MuonPairingAsymmetry>(); + alg->setRethrows(true); alg->initialize(); alg->setProperty("SpecifyGroupsManually", false); alg->setProperty("OutputWorkspace", "__notUsed"); @@ -348,29 +349,29 @@ public: // Correct Output : Single Period // -------------------------------------------------------------------------- - // void - // test_that_single_period_data_combines_detectors_correctly_for_manually_specified_detectors() { - // // 4 spectra per period, 10 bins - // auto ws = createMultiPeriodAsymmetryData(1, 4, 10, "pairWS"); - // std::vector<int> group1 = {1, 2}; - // std::vector<int> group2 = {3, 4}; + void + test_that_single_period_data_combines_detectors_correctly_for_manually_specified_detectors() { + // 4 spectra per period, 10 bins + auto ws = createMultiPeriodAsymmetryData(1, 4, 10, "pairWS"); + std::vector<int> group1 = {1, 2}; + std::vector<int> group2 = {3, 4}; - // auto alg = setUpAlgorithmWithGroups(ws, group1, group2); - // alg->execute(); - // auto wsOut = getOutputWorkspace(alg); + auto alg = setUpAlgorithmWithGroups(ws, group1, group2); + alg->execute(); + auto wsOut = getOutputWorkspace(alg); - // TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.000, 0.001); - // TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.400, 0.001); - // TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.900, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.050, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.450, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.950, 0.001); - // TS_ASSERT_DELTA(wsOut->readY(0)[0], -0.3889, 0.001); - // TS_ASSERT_DELTA(wsOut->readY(0)[4], 0.000, 0.001); - // TS_ASSERT_DELTA(wsOut->readY(0)[9], -0.8211, 0.001); + TS_ASSERT_DELTA(wsOut->readY(0)[0], -0.3889, 0.001); + TS_ASSERT_DELTA(wsOut->readY(0)[4], 0.000, 0.001); + TS_ASSERT_DELTA(wsOut->readY(0)[9], -0.8211, 0.001); - // TS_ASSERT_DELTA(wsOut->readE(0)[0], 0.04641, 0.0001); - // TS_ASSERT_DELTA(wsOut->readE(0)[4], 1.00000, 0.0001); - // TS_ASSERT_DELTA(wsOut->readE(0)[9], 0.19818, 0.0001); - // } + TS_ASSERT_DELTA(wsOut->readE(0)[0], 0.04641, 0.0001); + TS_ASSERT_DELTA(wsOut->readE(0)[4], 1.00000, 0.0001); + TS_ASSERT_DELTA(wsOut->readE(0)[9], 0.19818, 0.0001); + } void test_that_single_period_data_combines_detectors_correctly_for_two_group_workspaces() { @@ -398,9 +399,9 @@ public: TS_ASSERT_DELTA(wsOut->readE(0)[9], 0.19818, 0.0001); } - // -------------------------------------------------------------------------- - // Correct Output : Multi Period - // -------------------------------------------------------------------------- + // // -------------------------------------------------------------------------- + // // Correct Output : Multi Period + // // -------------------------------------------------------------------------- void test_that_multi_period_data_combines_detectors_correctly_for_manually_specified_detectors_and_summed_periods() { @@ -442,9 +443,9 @@ public: auto wsOut = getOutputWorkspace(alg); - TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.000, 0.001); - TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.400, 0.001); - TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.900, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.050, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.450, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.950, 0.001); TS_ASSERT_DELTA(wsOut->readY(0)[0], -0.00630986, 0.001); TS_ASSERT_DELTA(wsOut->readY(0)[4], 0.000, 0.001); @@ -469,9 +470,9 @@ public: auto wsOut = getOutputWorkspace(alg); - TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.000, 0.001); - TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.400, 0.001); - TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.900, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.050, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.450, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.950, 0.001); TS_ASSERT_DELTA(wsOut->readY(0)[0], -0.00879057, 0.001); TS_ASSERT_DELTA(wsOut->readY(0)[4], 0.0, 0.001); @@ -498,9 +499,9 @@ public: auto wsOut = getOutputWorkspace(alg); - TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.000, 0.001); - TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.400, 0.001); - TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.900, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[0], 0.050, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[4], 0.450, 0.001); + TS_ASSERT_DELTA(wsOut->readX(0)[9], 0.950, 0.001); TS_ASSERT_DELTA(wsOut->readY(0)[0], -0.00879057, 0.001); TS_ASSERT_DELTA(wsOut->readY(0)[4], 0.0, 0.001);