Unverified Commit 82bb8941 authored by DavidFair's avatar DavidFair Committed by GitHub
Browse files

Merge pull request #32496 from martyngigg/cppcheck-batch

Use const& over plain & in Python export wrappers
parents 9c31ef8d 2c2b62d8
......@@ -93,7 +93,7 @@ public:
const CrystalStructure &getCrystalStructure() const;
HKLFilter_const_sptr getDRangeFilter(double dMin, double dMax) const;
HKLFilter_const_sptr getReflectionConditionFilter(ReflectionConditionFilter filter);
HKLFilter_const_sptr getReflectionConditionFilter(ReflectionConditionFilter filter) const;
std::vector<Kernel::V3D> getHKLs(double dMin, double dMax) const;
std::vector<Kernel::V3D> getHKLs(double dMin, double dMax,
......
......@@ -42,7 +42,7 @@ HKLFilter_const_sptr ReflectionGenerator::getDRangeFilter(double dMin, double dM
}
/// Returns a reflection condition HKLFilter based on the supplied enum.
HKLFilter_const_sptr ReflectionGenerator::getReflectionConditionFilter(ReflectionConditionFilter filter) {
HKLFilter_const_sptr ReflectionGenerator::getReflectionConditionFilter(ReflectionConditionFilter filter) const {
switch (filter) {
case ReflectionConditionFilter::Centering:
return std::make_shared<const HKLFilterCentering>(m_crystalStructure.centering());
......
......@@ -151,10 +151,10 @@ template <typename SvcType, typename SvcPtrType> struct DataServiceExporter {
* contain this string
* @returns A python list created from the set of strings
*/
static boost::python::list getObjectNamesAsList(SvcType &self, const std::string &contain) {
static boost::python::list getObjectNamesAsList(SvcType const *const self, const std::string &contain) {
boost::python::list names;
const auto keys = self.getObjectNames(Mantid::Kernel::DataServiceSort::Unsorted,
Mantid::Kernel::DataServiceHidden::Auto, contain);
const auto keys = self->getObjectNames(Mantid::Kernel::DataServiceSort::Unsorted,
Mantid::Kernel::DataServiceHidden::Auto, contain);
for (auto itr = keys.begin(); itr != keys.end(); ++itr) {
names.append(*itr);
}
......
......@@ -19,13 +19,13 @@ namespace PythonInterface {
//** @name Numpy clones of data*/
///{
/// Create a numpy array from the X values of the given workspace reference
PyObject *cloneX(API::MatrixWorkspace &self);
PyObject *cloneX(const API::MatrixWorkspace &self);
/// Create a numpy array from the Y values of the given workspace reference
PyObject *cloneY(API::MatrixWorkspace &self);
PyObject *cloneY(const API::MatrixWorkspace &self);
/// Create a numpy array from the E values of the given workspace reference
PyObject *cloneE(API::MatrixWorkspace &self);
PyObject *cloneE(const API::MatrixWorkspace &self);
/// Create a numpy array from the E values of the given workspace reference
PyObject *cloneDx(API::MatrixWorkspace &self);
PyObject *cloneDx(const API::MatrixWorkspace &self);
///@}
} // namespace PythonInterface
} // namespace Mantid
......@@ -41,15 +41,15 @@ public:
/// Declare an attribute with an initial value
void declareAttribute(const std::string &name, const boost::python::object &defaultValue);
/// Get a named attribute value
static PyObject *getAttributeValue(IFunction &self, const std::string &name);
static PyObject *getAttributeValue(const IFunction &self, const std::string &name);
/// Returns the attribute's value as a Python object
static PyObject *getAttributeValue(IFunction &self, const API::IFunction::Attribute &attr);
static PyObject *getAttributeValue(const IFunction &self, const API::IFunction::Attribute &attr);
/// Set the attribute's value
static void setAttributePythonValue(IFunction &self, const std::string &name, const boost::python::object &value);
/// Called by the framework when an attribute has been set
void setAttribute(const std::string &attName, const API::IFunction::Attribute &attr) override;
/// Split this function (if needed) into a list of independent functions
static boost::python::list createPythonEquivalentFunctions(IFunction &self);
static boost::python::list createPythonEquivalentFunctions(const IFunction &self);
// Each overload of declareParameter requires a different name as we
// can't use a function pointer with a virtual base class
......
......@@ -37,7 +37,7 @@ enum DataField { XValues = 0, YValues = 1, EValues = 2, DxValues = 3 };
*reading the data (similar to .end() for STL)
*
*/
PyArrayObject *cloneArray(MatrixWorkspace &workspace, DataField field, const size_t start, const size_t endp1) {
PyArrayObject *cloneArray(const MatrixWorkspace &workspace, DataField field, const size_t start, const size_t endp1) {
const npy_intp numHist(endp1 - start);
npy_intp stride{0};
......@@ -85,7 +85,7 @@ PyArrayObject *cloneArray(MatrixWorkspace &workspace, DataField field, const siz
* @param self :: A pointer to a PyObject representing the calling object
* @return A 2D numpy array created from the X values
*/
PyObject *cloneX(MatrixWorkspace &self) {
PyObject *cloneX(const MatrixWorkspace &self) {
return reinterpret_cast<PyObject *>(cloneArray(self, XValues, 0, self.getNumberHistograms()));
}
/* Create a numpy array from the Y values of the given workspace reference
......@@ -93,7 +93,7 @@ PyObject *cloneX(MatrixWorkspace &self) {
* @param self :: A pointer to a PyObject representing the calling object
* @return A 2D numpy array created from the Y values
*/
PyObject *cloneY(MatrixWorkspace &self) {
PyObject *cloneY(const MatrixWorkspace &self) {
return reinterpret_cast<PyObject *>(cloneArray(self, YValues, 0, self.getNumberHistograms()));
}
......@@ -102,7 +102,7 @@ PyObject *cloneY(MatrixWorkspace &self) {
* @param self :: A pointer to a PyObject representing the calling object
* @return A 2D numpy array created from the E values
*/
PyObject *cloneE(MatrixWorkspace &self) {
PyObject *cloneE(const MatrixWorkspace &self) {
return reinterpret_cast<PyObject *>(cloneArray(self, EValues, 0, self.getNumberHistograms()));
}
......@@ -111,7 +111,7 @@ PyObject *cloneE(MatrixWorkspace &self) {
* @param self :: A pointer to a PyObject representing the calling object
* @return A 2D numpy array created from the E values
*/
PyObject *cloneDx(MatrixWorkspace &self) {
PyObject *cloneDx(const MatrixWorkspace &self) {
return reinterpret_cast<PyObject *>(cloneArray(self, DxValues, 0, self.getNumberHistograms()));
}
} // namespace Mantid::PythonInterface
......@@ -44,12 +44,11 @@ namespace {
* AlgorithmFactory class
* @param includeHidden :: If true hidden algorithms are included
*/
dict getRegisteredAlgorithms(AlgorithmFactoryImpl &self, bool includeHidden) {
std::vector<std::string> keys = self.getKeys(includeHidden);
const size_t nkeys = keys.size();
dict getRegisteredAlgorithms(AlgorithmFactoryImpl const *const self, bool includeHidden) {
const auto keys = self->getKeys(includeHidden);
dict inventory;
for (size_t i = 0; i < nkeys; ++i) {
auto algInfo = self.decodeName(keys[i]);
for (const auto &key : keys) {
auto algInfo = self->decodeName(key);
object name(handle<>(to_python_value<const std::string &>()(algInfo.first)));
object ver(handle<>(to_python_value<const int &>()(algInfo.second)));
// There seems to be no way to "promote" the return of .get to a list
......@@ -71,12 +70,11 @@ dict getRegisteredAlgorithms(AlgorithmFactoryImpl &self, bool includeHidden) {
* @param self :: An instance of AlgorithmFactory.
* @param includeHidden :: If true hidden algorithms are included.
*/
list getDescriptors(AlgorithmFactoryImpl &self, bool includeHidden = false, bool includeAlias = false) {
auto descriptors = self.getDescriptors(includeHidden, includeAlias);
list getDescriptors(AlgorithmFactoryImpl const *const self, bool includeHidden = false, bool includeAlias = false) {
const auto descriptors = self->getDescriptors(includeHidden, includeAlias);
list pyDescriptors;
for (auto &descr : descriptors) {
boost::python::object d(descr);
pyDescriptors.append(d);
for (const auto &descr : descriptors) {
pyDescriptors.append(boost::python::object(descr));
}
return pyDescriptors;
}
......@@ -90,8 +88,8 @@ list getDescriptors(AlgorithmFactoryImpl &self, bool includeHidden = false, bool
* @returns The map of the categories, together with a true false value
* defining if they are hidden
*/
dict getCategoriesandState(AlgorithmFactoryImpl &self) {
std::map<std::string, bool> categories = self.getCategoriesWithState();
dict getCategoriesandState(AlgorithmFactoryImpl const *const self) {
const auto categories = self->getCategoriesWithState();
dict pythonCategories;
for (auto &it : categories) {
object categoryName(handle<>(to_python_value<const std::string &>()(it.first)));
......
......@@ -41,7 +41,7 @@ boost::python::list getChildrenAsList(const std::shared_ptr<AlgorithmHistory> &s
* @param self :: A reference to the AlgorithmHistory that called this method
* @returns A python list created from the set of property histories
*/
boost::python::list getPropertiesAsList(AlgorithmHistory &self) {
boost::python::list getPropertiesAsList(const AlgorithmHistory &self) {
boost::python::list names;
const auto &histories = self.getProperties();
for (const auto &history : histories) {
......
......@@ -45,8 +45,8 @@ AlgorithmManagerImpl &instance() {
* @param self The calling object
* @param id An algorithm ID
*/
IAlgorithm_sptr getAlgorithm(AlgorithmManagerImpl &self, AlgorithmIDProxy idHolder) {
return self.getAlgorithm(idHolder.id);
IAlgorithm_sptr getAlgorithm(AlgorithmManagerImpl const *const self, AlgorithmIDProxy idHolder) {
return self->getAlgorithm(idHolder.id);
}
/**
......@@ -63,14 +63,11 @@ void removeById(AlgorithmManagerImpl &self, AlgorithmIDProxy idHolder) { return
* @param algName The name of the algorithm
* @return A python list of managed algorithms that are currently running
*/
boost::python::list runningInstancesOf(AlgorithmManagerImpl &self, const std::string &algName) {
boost::python::list runningInstancesOf(AlgorithmManagerImpl const *const self, const std::string &algName) {
boost::python::list algs;
auto mgrAlgs = self.runningInstancesOf(algName);
auto mgrAlgs = self->runningInstancesOf(algName);
for (auto &mgrAlg : mgrAlgs) {
// boost 1.41 (RHEL6) can't handle registering IAlgorithm_const_sptr so we
// have to cast to IAlgorithm_sptr and then convert to Python
// The constness is pretty-irrelevant by this point anyway
algs.append(std::const_pointer_cast<IAlgorithm>(mgrAlg));
algs.append(mgrAlg);
}
return algs;
......
......@@ -49,9 +49,9 @@ AnalysisDataServiceImpl &instance() {
* @param unrollGroups If true unroll the workspace groups
* @return a python list of the workspaces in the ADS
*/
list retrieveWorkspaces(AnalysisDataServiceImpl &self, const list &names, bool unrollGroups = false) {
list retrieveWorkspaces(AnalysisDataServiceImpl const *const self, const list &names, bool unrollGroups = false) {
return Converters::ToPyList<Workspace_sptr>()(
self.retrieveWorkspaces(Converters::PySequenceToVector<std::string>(names)(), unrollGroups));
self->retrieveWorkspaces(Converters::PySequenceToVector<std::string>(names)(), unrollGroups));
}
GNU_DIAG_OFF("unused-local-typedef")
......
......@@ -34,6 +34,7 @@ namespace {
* @param on bool; whether to turn on or off the observer for the specific method
* @param method ObserverMethod; the method to call with the on parameter.
*/
// cppcheck-suppress constParameterCallback
void callReleasingGIL(AnalysisDataServiceObserver &self, bool on, ObserverMethod method) {
ReleaseGlobalInterpreterLock releaseGil;
(self.*method)(on);
......
......@@ -8,29 +8,29 @@
#include "MantidKernel/WarningSuppressions.h"
#include <boost/python/class.hpp>
#include <boost/python/copy_const_reference.hpp>
#include <boost/python/operators.hpp>
#include <boost/python/overloads.hpp>
using namespace Mantid::API;
using namespace boost::python;
std::string description(Citation &self) { return self.description(); }
std::string url(Citation &self) { return self.url(); }
std::string doi(Citation &self) { return self.doi(); }
std::string bibtex(Citation &self) { return self.bibtex(); }
std::string endnote(Citation &self) { return self.endnote(); }
void export_Citation() {
using return_copy = return_value_policy<copy_const_reference>;
class_<Citation, boost::noncopyable>("Citation",
init<optional<const std::string &, const std::string &, const std::string &,
const std::string &, const std::string &>>())
.def(init<NeXus::File *, const std::string &>())
.def("description", &description, arg("self"), "Returns the description on the citation object")
.def("url", &url, arg("self"), "Returns the url on the citation object")
.def("doi", &doi, arg("self"), "Returns the doi on the citation object")
.def("bibtex", &bibtex, arg("self"), "Returns the bibtex formatted citation from the citation object")
.def("endnote", &endnote, arg("self"), "Returns the endnote formatted citation from the citation object")
.def("saveNexus", &Citation::saveNexus, (arg("self"), arg("file"), arg("group")),
.def("description", &Citation::description, arg("self"), return_copy(),
"Returns the description on the citation object")
.def("url", &Citation::url, arg("self"), return_copy(), "Returns the url on the citation object")
.def("doi", &Citation::doi, arg("self"), return_copy(), "Returns the doi on the citation object")
.def("bibtex", &Citation::bibtex, arg("self"), return_copy(),
"Returns the bibtex formatted citation from the citation object")
.def("endnote", &Citation::endnote, arg("self"), return_copy(),
"Returns the endnote formatted citation from the citation object")
.def("saveNexus", &Citation::saveNexus, (arg("self"), arg("file"), arg("group")), return_copy(),
"Save data from this object to a NeXus file")
.def("__eq__", &Citation::operator==);
}
......@@ -38,7 +38,7 @@ GNU_DIAG_ON("unused-local-typedef")
* @param useExtsOnly :: bool. If true, use exts_list only. If false, use
* combination of exts_list and facility_exts.
*/
std::vector<std::string> runFinderProxy(FileFinderImpl &self, const std::string &hintstr, list exts_list,
std::vector<std::string> runFinderProxy(const FileFinderImpl &self, const std::string &hintstr, list exts_list,
const bool useExtsOnly) {
// Convert python list to c++ vector
std::vector<std::string> exts;
......
......@@ -79,8 +79,8 @@ namespace {
* @param self :: Enables it to be called as a member function on the
* FunctionFactory class
*/
PyObject *getFunctionNames(FunctionFactoryImpl &self) {
const std::vector<std::string> &names = self.getFunctionNames<Mantid::API::IFunction>();
PyObject *getFunctionNames(FunctionFactoryImpl const *const self) {
const auto &names = self->getFunctionNames<Mantid::API::IFunction>();
PyObject *registered = PyList_New(0);
for (const auto &name : names) {
......@@ -98,12 +98,12 @@ PyObject *getFunctionNames(FunctionFactoryImpl &self) {
* @param self :: Enables it to be called as a member function on the
* FunctionFactory class
*/
PyObject *getBackgroundFunctionNames(FunctionFactoryImpl &self) {
const std::vector<std::string> &names = self.getFunctionNames<Mantid::API::IFunction>();
PyObject *getBackgroundFunctionNames(FunctionFactoryImpl const *const self) {
const auto &names = self->getFunctionNames<Mantid::API::IFunction>();
PyObject *registered = PyList_New(0);
for (const auto &name : names) {
auto fun = self.createFunction(name);
auto fun = self->createFunction(name);
if (dynamic_cast<IBackgroundFunction *>(fun.get())) {
PyObject *bkg_function = to_python_value<const std::string &>()(name);
if (PyList_Append(registered, bkg_function))
......@@ -120,12 +120,12 @@ PyObject *getBackgroundFunctionNames(FunctionFactoryImpl &self) {
* @param self :: Enables it to be called as a member function on the
* FunctionFactory class
*/
PyObject *getPeakFunctionNames(FunctionFactoryImpl &self) {
const std::vector<std::string> &names = self.getFunctionNames<Mantid::API::IFunction>();
PyObject *getPeakFunctionNames(FunctionFactoryImpl const *const self) {
const auto &names = self->getFunctionNames<Mantid::API::IFunction>();
PyObject *registered = PyList_New(0);
for (const auto &name : names) {
auto fun = self.createFunction(name);
auto fun = self->createFunction(name);
if (dynamic_cast<IPeakFunction *>(fun.get())) {
PyObject *peak_function = to_python_value<const std::string &>()(name);
if (PyList_Append(registered, peak_function))
......@@ -143,9 +143,8 @@ PyObject *getPeakFunctionNames(FunctionFactoryImpl &self) {
* FunctionFactory class
* @param name :: Peak function name
*/
Mantid::API::IPeakFunction_sptr createPeakFunction(FunctionFactoryImpl &self, const std::string &name) {
auto fun = self.createFunction(name);
Mantid::API::IPeakFunction_sptr createPeakFunction(FunctionFactoryImpl const *const self, const std::string &name) {
auto fun = self->createFunction(name);
auto peakFun = std::dynamic_pointer_cast<Mantid::API::IPeakFunction>(fun);
if (!peakFun) {
throw std::invalid_argument(name + " is not a PeakFunction");
......@@ -163,8 +162,9 @@ Mantid::API::IPeakFunction_sptr createPeakFunction(FunctionFactoryImpl &self, co
* @param name :: Name of the superclass of composite function,
* e.g. "ProductFunction".
*/
Mantid::API::CompositeFunction_sptr createCompositeFunction(FunctionFactoryImpl &self, const std::string &name) {
auto fun = self.createFunction(name);
Mantid::API::CompositeFunction_sptr createCompositeFunction(FunctionFactoryImpl const *const self,
const std::string &name) {
auto fun = self->createFunction(name);
auto composite = std::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun);
if (composite) {
return composite;
......
......@@ -128,7 +128,7 @@ PropertyVector apiOrderedProperties(const IAlgorithm &propMgr) {
* @return A Python list of strings
*/
list getInputPropertiesWithMandatoryFirst(IAlgorithm &self) {
list getInputPropertiesWithMandatoryFirst(const IAlgorithm &self) {
PropertyVector properties(apiOrderedProperties(self));
GlobalInterpreterLock gil;
......@@ -149,7 +149,7 @@ list getInputPropertiesWithMandatoryFirst(IAlgorithm &self) {
* @param self :: A pointer to the python object wrapping and Algorithm.
* @return A Python list of strings
*/
list getAlgorithmPropertiesOrdered(IAlgorithm &self) {
list getAlgorithmPropertiesOrdered(const IAlgorithm &self) {
PropertyVector properties(apiOrderedProperties(self));
GlobalInterpreterLock gil;
......@@ -166,7 +166,7 @@ list getAlgorithmPropertiesOrdered(IAlgorithm &self) {
* @param self :: A pointer to the python object wrapping and Algorithm.
* @return A Python list of strings
*/
list getOutputProperties(IAlgorithm &self) {
list getOutputProperties(const IAlgorithm &self) {
const PropertyVector &properties(self.getProperties()); // No copy
GlobalInterpreterLock gil;
......@@ -185,7 +185,7 @@ list getOutputProperties(IAlgorithm &self) {
* @param self :: A pointer to the python object wrapping and Algorithm.
* @return A Python list of strings
*/
list getInOutProperties(IAlgorithm &self) {
list getInOutProperties(const IAlgorithm &self) {
const PropertyVector &properties(self.getProperties()); // No copy
GlobalInterpreterLock gil;
......@@ -204,7 +204,7 @@ list getInOutProperties(IAlgorithm &self) {
* @param self :: A pointer to the python object wrapping and Algorithm
* @return A string that documents an algorithm
*/
std::string createDocString(IAlgorithm &self) {
std::string createDocString(const IAlgorithm &self) {
const std::string EOL = "\n";
// Put in the quick overview message
......@@ -301,7 +301,7 @@ bool executeProxy(object &self) {
* Execute the algorithm asynchronously
* @param self :: A reference to the calling object
*/
void executeAsync(object &self) {
void executeAsync(const object &self) {
auto &calg = extract<IAlgorithm &>(self)();
calg.executeAsync();
}
......@@ -311,7 +311,7 @@ void executeAsync(object &self) {
* @return An AlgorithmID wrapped in a AlgorithmIDProxy container or None if
* there is no ID
*/
PyObject *getAlgorithmID(IAlgorithm &self) {
PyObject *getAlgorithmID(const IAlgorithm &self) {
AlgorithmID id = self.getAlgorithmID();
if (id)
return to_python_value<AlgorithmIDProxy>()(AlgorithmIDProxy(id));
......@@ -326,7 +326,7 @@ PyObject *getAlgorithmID(IAlgorithm &self) {
* @param self Reference to the calling object
* @return Algorithm summary
*/
std::string getOptionalMessage(IAlgorithm &self) {
std::string getOptionalMessage(const IAlgorithm &self) {
PyErr_Warn(PyExc_DeprecationWarning, ".getOptionalMessage() is deprecated. Use .summary() instead.");
return self.summary();
}
......@@ -335,7 +335,7 @@ std::string getOptionalMessage(IAlgorithm &self) {
* @param self Reference to the calling object
* @return Algorithm summary
*/
std::string getWikiSummary(IAlgorithm &self) {
std::string getWikiSummary(const IAlgorithm &self) {
PyErr_Warn(PyExc_DeprecationWarning, ".getWikiSummary() is deprecated. Use .summary() instead.");
return self.summary();
}
......@@ -361,6 +361,7 @@ void export_ialgorithm() {
class_<AlgorithmIDProxy>("AlgorithmID", no_init).def(self == self);
register_ptr_to_python<std::shared_ptr<IAlgorithm>>();
register_ptr_to_python<std::shared_ptr<const IAlgorithm>>();
class_<IAlgorithm, bases<IPropertyManager>, boost::noncopyable>("IAlgorithm", "Interface for all algorithms", no_init)
.def("name", &IAlgorithm::name, arg("self"), "Returns the name of the algorithm")
......
......@@ -39,8 +39,8 @@ namespace {
* @param self :: Enables it to be called as a member function on the
* FunctionFactory class
*/
PyObject *getCategories(IFunction &self) {
std::vector<std::string> categories = self.categories();
PyObject *getCategories(const IFunction &self) {
const auto categories = self.categories();
PyObject *registered = PyList_New(0);
for (const auto &category : categories) {
......@@ -180,7 +180,8 @@ void export_IFunction() {
.def("declareAttribute", &IFunctionAdapter::declareAttribute, (arg("self"), arg("name"), arg("default_value")),
"Declare an attribute with an initial value")
.def("getAttributeValue", (PyObject * (*)(IFunction &, const std::string &)) IFunctionAdapter::getAttributeValue,
.def("getAttributeValue",
(PyObject * (*)(const IFunction &, const std::string &)) IFunctionAdapter::getAttributeValue,
(arg("self"), arg("name")), "Return the value of the named attribute")
.def("setAttributeValue", &IFunctionAdapter::setAttributePythonValue, (arg("self"), arg("name"), arg("value")),
......
......@@ -85,7 +85,7 @@ std::vector<Py_intptr_t> countDimensions(const IMDHistoWorkspace &self) {
* Returns the signal array from the workspace as a numpy array
* @param self :: A reference to the calling object
*/
PyObject *getSignalArrayAsNumpyArray(IMDHistoWorkspace &self) {
PyObject *getSignalArrayAsNumpyArray(const IMDHistoWorkspace &self) {
auto dims = countDimensions(self);
return WrapReadOnlyNumpyFArray(self.getSignalArray(), dims);
}
......@@ -94,7 +94,7 @@ PyObject *getSignalArrayAsNumpyArray(IMDHistoWorkspace &self) {
* Returns the error squared array from the workspace as a numpy array
* @param self :: A reference to the calling object
*/
PyObject *getErrorSquaredArrayAsNumpyArray(IMDHistoWorkspace &self) {
PyObject *getErrorSquaredArrayAsNumpyArray(const IMDHistoWorkspace &self) {
auto dims = countDimensions(self);
return WrapReadOnlyNumpyFArray(self.getErrorSquaredArray(), dims);
}
......@@ -103,7 +103,7 @@ PyObject *getErrorSquaredArrayAsNumpyArray(IMDHistoWorkspace &self) {
* Returns the number of events array from the workspace as a numpy array
* @param self :: A reference to the calling object
*/
PyObject *getNumEventsArrayAsNumpyArray(IMDHistoWorkspace &self) {
PyObject *getNumEventsArrayAsNumpyArray(const IMDHistoWorkspace &self) {
auto dims = countDimensions(self);
return WrapReadOnlyNumpyFArray(self.getNumEventsArray(), dims);
}
......@@ -115,7 +115,7 @@ PyObject *getNumEventsArrayAsNumpyArray(IMDHistoWorkspace &self) {
* @param signal :: The new values
* @param fnLabel :: A message prefix to pass if the sizes are incorrect
*/
void throwIfSizeIncorrect(IMDHistoWorkspace &self, const NDArray &signal, const std::string &fnLabel) {
void throwIfSizeIncorrect(const IMDHistoWorkspace &self, const NDArray &signal, const std::string &fnLabel) {
auto wsShape = countDimensions(self);
const size_t ndims = wsShape.size();
auto arrShape = signal.attr("shape");
......
......@@ -25,7 +25,7 @@ GET_POINTER_SPECIALIZATION(IPeak)
namespace {
using namespace Mantid::PythonInterface;
Mantid::Geometry::PeakShape_sptr getPeakShape(IPeak &peak) {
Mantid::Geometry::PeakShape_sptr getPeakShape(const IPeak &peak) {
// Use clone to make a copy of the PeakShape.
return Mantid::Geometry::PeakShape_sptr(peak.getPeakShape().clone());
}
......
......@@ -32,28 +32,28 @@ GET_POINTER_SPECIALIZATION(IPeaksWorkspace)
namespace {
/// Create a peak via it's HKL value from a list or numpy array
IPeak *createPeakHKL(IPeaksWorkspace &self, const object &data) {
IPeak *createPeakHKL(const IPeaksWorkspace &self, const object &data) {
auto peak = self.createPeakHKL(Mantid::PythonInterface::Converters::PyObjectToV3D(data)());
// Python will manage it
return peak.release();
}
/// Create a peak via it's QLab value from a list or numpy array
IPeak *createPeakQLab(IPeaksWorkspace &self, const object &data) {
IPeak *createPeakQLab(const IPeaksWorkspace &self, const object &data) {
auto peak = self.createPeak(Mantid::PythonInterface::Converters::PyObjectToV3D(data)(), boost::none);
// Python will manage it
return peak.release();
}
/// Create a peak via it's QLab value from a list or numpy array
IPeak *createPeakQLabWithDistance(IPeaksWorkspace &self, const object &data, double detectorDistance) {
IPeak *createPeakQLabWithDistance(const IPeaksWorkspace &self, const object &data, double detectorDistance) {
auto peak = self.createPeak(Mantid::PythonInterface::Converters::PyObjectToV3D(data)(), detectorDistance);
// Python will manage the object
return peak.release();
}
/// Create a peak via it's QSample value from a list or numpy array
IPeak *createPeakQSample(IPeaksWorkspace &self, const object &data) {
IPeak *createPeakQSample(const IPeaksWorkspace &self, const object &data) {
auto peak = self.createPeakQSample(Mantid::PythonInterface::Converters::PyObjectToV3D(data)());
// Python will manage it
return peak.release();
......
......@@ -32,7 +32,7 @@ using HeldType = std::vector<std::vector<std::string>>;
* @returns A string is there is only a single string in the Property's value,
* and a list if there are multiple ones
*/
boost::python::list valueAsPyObject(MultipleFileProperty &self) {
boost::python::list valueAsPyObject(const MultipleFileProperty &self) {
const HeldType &propValue = self();
// Build a list of lists to mimic the behaviour of MultipleFileProperty
......
Markdown is supported
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