diff --git a/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceValidators.cpp b/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceValidators.cpp index 898b1032bfd0a414f110e83b1296a5cd85837d87..8618b7d5f75d3de837d98cd3f63c6e32f393edef 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceValidators.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceValidators.cpp @@ -1,5 +1,7 @@ #include "MantidAPI/CommonBinsValidator.h" #include "MantidAPI/HistogramValidator.h" +#include "MantidAPI/IMDWorkspace.h" +#include "MantidAPI/MDFrameValidator.h" #include "MantidAPI/NumericAxisValidator.h" #include "MantidAPI/RawCountValidator.h" #include "MantidAPI/SpectraAxisValidator.h" @@ -7,6 +9,7 @@ #include "MantidPythonInterface/kernel/TypedValidatorExporter.h" #include <boost/python/class.hpp> +using Mantid::API::IMDWorkspace_sptr; using Mantid::Kernel::TypedValidator; using Mantid::PythonInterface::TypedValidatorExporter; using namespace boost::python; @@ -17,9 +20,15 @@ void export_MatrixWorkspaceValidator() { using Mantid::API::MatrixWorkspaceValidator; TypedValidatorExporter<MatrixWorkspace_sptr>::define( "MatrixWorkspaceValidator"); + TypedValidatorExporter<IMDWorkspace_sptr>::define( + "IMDWorkspaceValidator"); class_<MatrixWorkspaceValidator, bases<TypedValidator<MatrixWorkspace_sptr>>, boost::noncopyable>("MatrixWorkspaceValidator", no_init); + + class_<TypedValidator<IMDWorkspace_sptr >, + boost::noncopyable>("IMDWorkspaceValidator", no_init); + } /// Export a validator derived from a MatrixWorkspaceValidator that has a no-arg /// constructor @@ -46,9 +55,10 @@ void export_WorkspaceValidators() { WorkspaceUnitValidator, std::string, "unit", "Checks the workspace has the given unit along the X-axis"); EXPORT_WKSP_VALIDATOR_DEFAULT_ARG(HistogramValidator, bool, "mustBeHistogram", - true, "If mustBeHistogram=True then the " - "workspace must be a histogram " - "otherwise it must be point data."); + true, + "If mustBeHistogram=True then the " + "workspace must be a histogram " + "otherwise it must be point data."); EXPORT_WKSP_VALIDATOR_DEFAULT_ARG( RawCountValidator, bool, "mustNotBeDistribution", true, "If mustNotBeDistribution=True then the workspace must not have been " @@ -62,4 +72,8 @@ void export_WorkspaceValidators() { EXPORT_WKSP_VALIDATOR_DEFAULT_ARG( NumericAxisValidator, int, "axisNumber", 1, "Checks whether the axis specified by axisNumber is a NumericAxis"); + + class_<MDFrameValidator, bases<TypedValidator<IMDWorkspace_sptr>>, + boost::noncopyable>("MDFrameValidator", init<std::string>(arg("frameName"), + "Checks the MD workspace has th given frame along all dimensions")); } diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py index f85d754b4681c794cbc49f4f362c4c7f0bb8694a..128b3f48ddfcc8310219d4063d38703a0e47eded 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py @@ -9,7 +9,7 @@ from mantid.kernel import IValidator from mantid.api import (WorkspaceUnitValidator, HistogramValidator, RawCountValidator, CommonBinsValidator, SpectraAxisValidator, NumericAxisValidator, - InstrumentValidator) + InstrumentValidator, MDFrameValidator) class WorkspaceValidatorsTest(unittest.TestCase): @@ -67,5 +67,10 @@ class WorkspaceValidatorsTest(unittest.TestCase): """ testhelpers.assertRaisesNothing(self, InstrumentValidator) + def test_MDFrameValidator_construction(self): + testhelpers.assertRaisesNothing(self, MDFrameValidator, "HKL") + self.assertRaises(Exception, MDFrameValidator) + + if __name__ == '__main__': unittest.main() diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h index bae677cfd536009f754a2988e163260ca462763a..90de51e405276c62e934b924da4c6d4987b317dc 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h @@ -710,17 +710,11 @@ public: MDHistoWorkspaceTester(MDHistoDimension_sptr dimX, MDHistoDimension_sptr dimY, MDHistoDimension_sptr dimZ) { - - m_dimensions.push_back(dimX); - m_dimensions.push_back(dimY); - m_dimensions.push_back(dimZ); - - initGeometry(m_dimensions); + std::vector<IMDDimension_sptr> dimensions {dimX, dimY, dimZ}; + initGeometry(dimensions); } -protected: private: - std::vector<IMDDimension_sptr> m_dimensions; IMDHistoWorkspace *doClone() const override { throw std::runtime_error("Not Implemented");