diff --git a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp index d474ab260194c34ace15057288a1343ed5bd6fc9..d0fcf9fed415a15f4f7f1a18814ef9a91d036e94 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp @@ -21,6 +21,7 @@ using namespace Kernel; * @param inputs : input workspaces vector [including] group workspaces (all must * be on ADS) * @return : the flat vector of the input workspaces +* @throw : std::runtime_error if the input workspaces are neither groups nor MatrixWorkspaces */ std::vector<std::string> RunCombinationHelper::unWrapGroups(const std::vector<std::string> &inputs) { diff --git a/Framework/Algorithms/test/ConjoinXRunsTest.h b/Framework/Algorithms/test/ConjoinXRunsTest.h index fd1e397fdc023c13b3409f3dc3fe9a8e0d96696f..7097b4eea0b3732604f09e369bbb955cf5b281f2 100644 --- a/Framework/Algorithms/test/ConjoinXRunsTest.h +++ b/Framework/Algorithms/test/ConjoinXRunsTest.h @@ -5,9 +5,11 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/WorkspaceFactory.h" #include "MantidAlgorithms/AddSampleLog.h" #include "MantidAlgorithms/AddTimeSeriesLog.h" #include "MantidAlgorithms/ConjoinXRuns.h" +#include "MantidAlgorithms/GroupWorkspaces.h" #include "MantidHistogramData/Counts.h" #include "MantidHistogramData/HistogramDx.h" #include "MantidHistogramData/HistogramE.h" @@ -20,6 +22,7 @@ using Mantid::Algorithms::ConjoinXRuns; using Mantid::Algorithms::AddSampleLog; using Mantid::Algorithms::AddTimeSeriesLog; +using Mantid::Algorithms::GroupWorkspaces; using Mantid::HistogramData::Counts; using Mantid::HistogramData::HistogramDx; using Mantid::HistogramData::HistogramE; @@ -96,6 +99,23 @@ public: TSM_ASSERT_EQUALS("Dx and y values are the same", out->dx(0).rawData(), y); } + void testTableInputWorkspaceInGroup() { + auto table = WorkspaceFactory::Instance().createTable("TableWorkspace"); + storeWS("table", table); + + GroupWorkspaces group; + group.initialize(); + group.setProperty("InputWorkspaces", + std::vector<std::string>{"table", "ws1"}); + group.setProperty("OutputWorkspace", "group"); + group.execute(); + m_testee.setProperty("InputWorkspaces", "group"); + m_testee.setProperty("OutputWorkspace", "out"); + TS_ASSERT_THROWS_EQUALS(m_testee.execute(), const std::runtime_error &e, + std::string(e.what()), + "Some invalid Properties found"); + } + void testWSWithoutDxValues() { // Workspaces have 5 spectra must be point data MatrixWorkspace_sptr ws0 = create2DWorkspace123(5, 3); // 3 points diff --git a/Framework/Algorithms/test/RunCombinationHelperTest.h b/Framework/Algorithms/test/RunCombinationHelperTest.h index 30f1b381d976cb3b287aac2710917eaa39b85ebf..90b94d80718539bbc54f1aa2e175ddc3da5de9db 100644 --- a/Framework/Algorithms/test/RunCombinationHelperTest.h +++ b/Framework/Algorithms/test/RunCombinationHelperTest.h @@ -7,7 +7,9 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/Axis.h" +#include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/WorkspaceFactory.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidHistogramData/HistogramDx.h" #include "MantidAlgorithms/CreateSampleWorkspace.h" @@ -20,10 +22,12 @@ using Mantid::Algorithms::RunCombinationHelper; using Mantid::Algorithms::GroupWorkspaces; using Mantid::Algorithms::CreateSampleWorkspace; using namespace Mantid::API; +using namespace Mantid::DataObjects; using namespace Mantid::HistogramData; using namespace Mantid::Kernel; using namespace WorkspaceCreationHelper; + class RunCombinationHelperTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically @@ -42,14 +46,15 @@ public: void testUnwraping_throws() { - MatrixWorkspace_sptr ws1 = create2DWorkspace(2, 3); + auto ws1 = create2DWorkspace(2, 3); storeWS("ws1", ws1); + auto table = WorkspaceFactory::Instance().createTable("TableWorkspace"); + storeWS("table", table); TS_ASSERT_THROWS_EQUALS( - m_testee.unWrapGroups(std::vector<std::string>{"ws1", "ws?"}), + m_testee.unWrapGroups(std::vector<std::string>{"ws1", "table"}), const std::runtime_error &e, std::string(e.what()), - "Unable to find workspace type with name 'ws?': data service search " - "object ws?"); + "The input table is neither a WorkspaceGroup nor a MatrixWorkspace"); removeWS("ws1"); } diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h index b809b285196480bfad27e427ea4cab8e043d3e03..9db2c01f27a2e83d045340b26ed94185767c4809 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h @@ -106,8 +106,14 @@ struct EPPTableRow { FitStatus fitStatus = FitStatus::SUCCESS; }; -/// Adds a workspace to the ADS -void storeWS(const std::string &name, Mantid::API::Workspace_sptr ws); +/** + * Adds a workspace to the ADS + * @param name :: The name of the workspace + * @param ws :: The workspace object + */ +template <typename WSType> void storeWS(const std::string &name, WSType &ws) { + Mantid::API::AnalysisDataService::Instance().add(name, ws); +} /// Deletes a workspace void removeWS(const std::string &name); /// Returns a workspace of a given type diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index f90803a4cd50029c21fc21f821a9b6073e9b8080..5a8efb136bc5f352a5af9abaca6ebc24b40d166a 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -72,14 +72,6 @@ EPPTableRow::EPPTableRow(const int index, const double peakCentre_, : workspaceIndex(index), peakCentre(peakCentre_), sigma(sigma_), height(height_), fitStatus(fitStatus_) {} -/** - * @param name :: The name of the workspace - * @param ws :: The workspace object - */ -void storeWS(const std::string &name, Mantid::API::Workspace_sptr ws) { - Mantid::API::AnalysisDataService::Instance().add(name, ws); -} - /** * Deletes a workspace * @param name :: The name of the workspace