Commit 7f9d1ab5 authored by Zhang, Chen's avatar Zhang, Chen
Browse files

classmaker assisted setup

parent ec0a13fb
......@@ -29,6 +29,7 @@ set(SRC_FILES
src/CalculateFlatBackground.cpp
src/CalculateIqt.cpp
src/CalculateMultipleScattering.cpp
src/CalculatePlaczek.cpp
src/CalculatePlaczekSelfScattering.cpp
src/CalculatePolynomialBackground.cpp
src/CalculateTransmission.cpp
......@@ -368,6 +369,7 @@ set(INC_FILES
inc/MantidAlgorithms/CalculateFlatBackground.h
inc/MantidAlgorithms/CalculateIqt.h
inc/MantidAlgorithms/CalculateMultipleScattering.h
inc/MantidAlgorithms/CalculatePlaczek.h
inc/MantidAlgorithms/CalculatePlaczekSelfScattering.h
inc/MantidAlgorithms/CalculatePolynomialBackground.h
inc/MantidAlgorithms/CalculateTransmission.h
......@@ -726,6 +728,7 @@ set(TEST_FILES
CalculateIqtTest.h
CalculateMultipleScatteringTest.h
CalculatePlaczekSelfScatteringTest.h
CalculatePlaczekTest.h
CalculatePolynomialBackgroundTest.h
CalculateTransmissionBeamSpreaderTest.h
CalculateTransmissionTest.h
......
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidAlgorithms/DllConfig.h"
namespace Mantid {
namespace Algorithms {
/** CalculatePlaczek : TODO: DESCRIPTION
*/
class MANTID_ALGORITHMS_DLL CalculatePlaczek : public API::Algorithm {
public:
const std::string name() const override;
int version() const override;
const std::string category() const override;
const std::string summary() const override;
private:
void init() override;
void exec() override;
};
} // namespace Algorithms
} // namespace Mantid
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAlgorithms/CalculatePlaczek.h"
namespace Mantid {
namespace Algorithms {
using Mantid::API::WorkspaceProperty;
using Mantid::Kernel::Direction;
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(CalculatePlaczek)
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const std::string CalculatePlaczek::name() const { return "CalculatePlaczek"; }
/// Algorithm's version for identification. @see Algorithm::version
int CalculatePlaczek::version() const { return 1; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string CalculatePlaczek::category() const { return "TODO: FILL IN A CATEGORY"; }
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string CalculatePlaczek::summary() const { return "TODO: FILL IN A SUMMARY"; }
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void CalculatePlaczek::init() {
declareProperty(std::make_unique<WorkspaceProperty<API::Workspace>>("InputWorkspace", "", Direction::Input),
"An input workspace.");
declareProperty(std::make_unique<WorkspaceProperty<API::Workspace>>("OutputWorkspace", "", Direction::Output),
"An output workspace.");
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void CalculatePlaczek::exec() {
// TODO Auto-generated execute stub
}
} // namespace Algorithms
} // namespace Mantid
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include <cxxtest/TestSuite.h>
#include "MantidAlgorithms/CalculatePlaczek.h"
using Mantid::Algorithms::CalculatePlaczek;
class CalculatePlaczekTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static CalculatePlaczekTest *createSuite() { return new CalculatePlaczekTest(); }
static void destroySuite(CalculatePlaczekTest *suite) { delete suite; }
void test_Init() {
CalculatePlaczek alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
}
void test_exec() {
// Create test input if necessary
MatrixWorkspace_sptr
inputWS = //-- Fill in appropriate code. Consider using TestHelpers/WorkspaceCreationHelpers.h --
CalculatePlaczek alg;
// Don't put output in ADS by default
alg.setChild(true);
TS_ASSERT_THROWS_NOTHING(alg.initialize())
TS_ASSERT(alg.isInitialized())
TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", inputWS));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", "_unused_for_child"));
TS_ASSERT_THROWS_NOTHING(alg.execute(););
TS_ASSERT(alg.isExecuted());
// Retrieve the workspace from the algorithm. The type here will probably need to change. It should
// be the type using in declareProperty for the "OutputWorkspace" type.
// We can't use auto as it's an implicit conversion.
Workspace_sptr outputWS = alg.getProperty("OutputWorkspace");
TS_ASSERT(outputWS);
TS_FAIL("TODO: Check the results and remove this line");
}
void test_Something() { TS_FAIL("You forgot to write a test!"); }
};
.. algorithm::
.. summary::
.. relatedalgorithms::
.. properties::
Description
-----------
TODO: Enter a full rst-markup description of your algorithm here.
Usage
-----
.. Try not to use files in your examples,
but if you cannot avoid it then the (small) files must be added to
autotestdata\UsageData and the following tag unindented
.. include:: ../usagedata-note.txt
**Example - CalculatePlaczek**
.. testcode:: CalculatePlaczekExample
# Create a host workspace
ws = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
or
ws = CreateSampleWorkspace()
wsOut = CalculatePlaczek()
# Print the result
print "The output workspace has %%i spectra" %% wsOut.getNumberHistograms()
Output:
.. testoutput:: CalculatePlaczekExample
The output workspace has ?? spectra
.. categories::
.. sourcelink::
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