Mantid
Loading...
Searching...
No Matches
DataProcessorAlgorithm.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10#include <boost/python/class.hpp>
11#include <boost/python/overloads.hpp>
12
13using namespace Mantid::API;
15using namespace boost::python;
16
17namespace {
18template <class Base>
19using loadOverload = Workspace_sptr (DataProcessorAdapter<Base>::*)(const std::string &, const bool);
20
21template <class Base> void do_export(const std::string &name) {
22 // for strings will actually create a list
24 using Adapter = DataProcessorAdapter<Base>;
25
26 class_<GenericDataProcessorAlgorithm<Base>, bases<Base>, std::shared_ptr<Adapter>, boost::noncopyable>(
27 name.c_str(), "Base class workflow-type algorithms")
28
29 .def("setLoadAlg", &Adapter::setLoadAlgProxy, (arg("self"), arg("alg")),
30 "Set the name of the algorithm called using the load() method "
31 "[Default=Load]")
32
33 .def("setLoadAlgFileProp", &Adapter::setLoadAlgFilePropProxy, (arg("self"), arg("file_prop_name")),
34 "Set the name of the file property for the load algorithm when "
35 "using "
36 "the load() method [Default=Filename]")
37
38 .def("setAccumAlg", &Adapter::setAccumAlgProxy, (arg("self"), arg("alg")),
39 "Set the name of the algorithm called to accumulate a chunk of "
40 "processed data [Default=Plus]")
41
42 .def("copyProperties", &Adapter::copyPropertiesProxy,
43 (arg("self"), arg("alg"), arg("properties") = boost::python::object(), arg("version") = -1),
44 "Copy properties from another algorithm")
45
46 .def("determineChunk", &Adapter::determineChunkProxy, (arg("self"), arg("file_name")),
47 "Return a TableWorkspace containing the information on how to split "
48 "the "
49 "input file when processing in chunks")
50
51 .def("loadChunk", &Adapter::loadChunkProxy, (arg("self"), arg("row_index")), "Load a chunk of data")
52
53 .def("load", (loadOverload<Base>)&Adapter::loadProxy, (arg("self"), arg("input_data"), arg("load_quiet") = false),
54 "Loads the given file or workspace data and returns the workspace. "
55 "If loadQuiet=True then output is not stored in the "
56 "AnalysisDataService.")
57
58 .def("splitInput", &Adapter::splitInputProxy, (arg("self"), arg("input")), return_value_policy<VectorToNumpy>())
59
60 .def("forwardProperties", &Adapter::forwardPropertiesProxy, arg("self"))
61
62 .def("getProcessProperties", &Adapter::getProcessPropertiesProxy, (arg("self"), arg("property_manager")),
63 "Returns the named property manager from the service or creates "
64 "a new one if it does not exist")
65
66 .def("assemble", &Adapter::assembleProxy, (arg("self"), arg("partial_wsname"), arg("output_wsname")),
67 "If an MPI build, assemble the partial workspaces from all MPI "
68 "processes. "
69 "Otherwise, simply returns the input workspace")
70
71 .def("saveNexus", &Adapter::saveNexusProxy, (arg("self"), arg("output_wsname"), arg("output_filename")),
72 "Save a workspace as a nexus file. If this is an MPI build then "
73 "saving only "
74 "happens for the main thread.")
75
76 .def("isMainThread", &Adapter::isMainThreadProxy, arg("self"),
77 "Returns true if this algorithm is the main thread for an MPI "
78 "build. For "
79 "non-MPI build it always returns true")
80
81 .def("getNThreads", &Adapter::getNThreadsProxy, arg("self"),
82 "Returns the number of running MPI processes in an MPI build or 1 "
83 "for "
84 "a non-MPI build");
85}
86} // namespace
87
88void export_DataProcessorAlgorithm() { do_export<Algorithm>("DataProcessorAlgorithm"); }
89void export_SerialDataProcessorAlgorithm() { do_export<SerialAlgorithm>("SerialDataProcessorAlgorithm"); }
90void export_ParallelDataProcessorAlgorithm() { do_export<ParallelAlgorithm>("ParallelDataProcessorAlgorithm"); }
92 do_export<DistributedAlgorithm>("DistributedDataProcessorAlgorithm");
93}
void export_SerialDataProcessorAlgorithm()
void export_DataProcessorAlgorithm()
void export_DistributedDataProcessorAlgorithm()
void export_ParallelDataProcessorAlgorithm()
Provides a layer class for boost::python to allow C++ virtual functions to be overridden in a Python ...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
Implements a return value policy that returns a numpy array from a function returning a std::vector b...