diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt index 542362879e66069153d546acd9adfadee0adc1e9..ec251747d76bdfe336d120059eeed86f3663ceee 100644 --- a/Framework/Algorithms/CMakeLists.txt +++ b/Framework/Algorithms/CMakeLists.txt @@ -280,7 +280,7 @@ set ( SRC_FILES src/SofQWPolygon.cpp src/SolidAngle.cpp src/SortEvents.cpp - src/SortXAxis2.cpp + src/SortXAxis.cpp src/SpatialGrouping.cpp src/SpectrumAlgorithm.cpp src/SpecularReflectionAlgorithm.cpp @@ -610,7 +610,7 @@ set ( INC_FILES inc/MantidAlgorithms/SofQWPolygon.h inc/MantidAlgorithms/SolidAngle.h inc/MantidAlgorithms/SortEvents.h - inc/MantidAlgorithms/SortXAxis2.h + inc/MantidAlgorithms/SortXAxis.h inc/MantidAlgorithms/SpatialGrouping.h inc/MantidAlgorithms/SpectrumAlgorithm.h inc/MantidAlgorithms/SpecularReflectionAlgorithm.h diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis2.h b/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h similarity index 100% rename from Framework/Algorithms/inc/MantidAlgorithms/SortXAxis2.h rename to Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h diff --git a/Framework/Algorithms/src/SortXAxis2.cpp b/Framework/Algorithms/src/SortXAxis.cpp similarity index 99% rename from Framework/Algorithms/src/SortXAxis2.cpp rename to Framework/Algorithms/src/SortXAxis.cpp index 6dd81d7afd301f04c93d1173289242aaebfedc6a..49c436c7cf7328c5ecdc2c8af222179fb00dadb6 100644 --- a/Framework/Algorithms/src/SortXAxis2.cpp +++ b/Framework/Algorithms/src/SortXAxis.cpp @@ -1,4 +1,4 @@ -#include "MantidAlgorithms/SortXAxis2.h" +#include "MantidAlgorithms/SortXAxis.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceProperty.h" @@ -16,7 +16,7 @@ DECLARE_ALGORITHM(SortXAxis) const std::string SortXAxis::name() const { return "SortXAxis"; } -int SortXAxis::version() const { return 2; } +int SortXAxis::version() const { return 1; } const std::string SortXAxis::category() const { return "Transforms\\Axes;Utility\\Sorting"; diff --git a/Framework/Algorithms/test/SortXAxisTest.h b/Framework/Algorithms/test/SortXAxisTest.h new file mode 100644 index 0000000000000000000000000000000000000000..f4bd883c12be326685927ae6d297692c14979c5b --- /dev/null +++ b/Framework/Algorithms/test/SortXAxisTest.h @@ -0,0 +1,67 @@ +#ifndef MANTID_ALGORITHMS_SORTXAXISTEST_H_ +#define MANTID_ALGORITHMS_SORTXAXISTEST_H_ + +#include "MantidAlgorithms/SortXAxis.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidKernel/Workspace.h" +#include <cxxtest/TestSuite.h> + +namespace { +MatrixWorkspace_sptr createWorkspace(const HistogramX &xData, + const HistogramY &yData, + const HistogramE &eData, + const int nSpec = 1) { + + Workspace2D_sptr outWS = boost::make_shared<Workspace2D>(); + outWS->initialize(nSpec, xData.size(), yData.size()); + for (int i = 0; i < nSpec; ++i) { + outWS->mutableY(i) = yData; + outWS->mutableE(i) = eData; + outWS->mutableX(i) = xData; + } + + outWS->getAxis(0)->unit() = UnitFactory::Instance().create("Wavelength"); + + return outWS; +} + +class SortXAxisTest : public CxxTest::TestSuite { + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static SortXAxisTest *createSuite() { return new SortXAxisTest(); } + static void destroySuite(SortXAxisTest *suite) { delete suite; } + + void testXAscending(){ + std::vector<double> xData = {1,2,3}; + std::vector<double> yData = {1,2,3}; + std::vector<double> eData = {1,2,3}; + + MatrixWorkspace_sptr unsortedws = createWorkspace(xData, yData, eData); + + SortXAxis alg; + alg.setProperty("InputWorkspacd", "unsortedws"); + alg.setProperty("OutputWorkspace", "sortedws"); + alg.execute(); + MatrixWorkspace_sptr sortedws = + + } + + void testXDescending(){} + + void testOnMultipleSpectrum(){} + + void testSortsXHistogramAscending(){} + + void testSortsXHistogramDescending(){} + + void testSortXWorksChild(){} + + void testDxMultipleSpectrum(){} + + void testDxHistogramAscending(){} + + void testSortDescending(){} +}; + + +#endif /*MANTID_ALGORITHMS_SORTXAXISTEST_H_*/