Commit 986f0e44 authored by David Fairbrother's avatar David Fairbrother Committed by Gemma Guest
Browse files

Handle long/int mismatch between scalar and array props

IntArray is actually an array of longs, since we already have a long
type from Python we can preserve this until we try to set a scalar. In
the latter case we need to cast to an int for the underlying assignment
to work.
parent 6e3dc86c
......@@ -20,7 +20,7 @@ namespace Mantid::PythonInterface {
struct PyNativeTypeExtractor {
using PythonOutputT =
boost::make_recursive_variant<bool, int, double, std::string, std::vector<boost::recursive_variant_>>::type;
boost::make_recursive_variant<bool, long, double, std::string, std::vector<boost::recursive_variant_>>::type;
static PythonOutputT convert(const boost::python::object &obj) {
using namespace boost::python;
......@@ -37,7 +37,7 @@ struct PyNativeTypeExtractor {
double val = extract<double>(obj);
out = val;
} else if (PyLong_Check(rawptr)) {
int val = extract<int>(obj);
long val = extract<long>(obj);
out = val;
} else if (PyUnicode_Check(rawptr)) {
std::string val = extract<std::string>(obj);
......
......@@ -109,7 +109,7 @@ public:
: m_alg(alg), m_propName(propName) {}
void operator()(bool value) const { m_alg->setProperty(m_propName, value); }
void operator()(int value) const { m_alg->setProperty(m_propName, value); }
void operator()(long value) const { m_alg->setProperty(m_propName, static_cast<int>(value)); }
void operator()(double value) const { m_alg->setProperty(m_propName, value); }
void operator()(std::string const &value) const { m_alg->setPropertyValue(m_propName, value); }
......@@ -124,8 +124,8 @@ public:
applyVectorProp<bool>(values);
} else if (elemType == typeid(double)) {
applyVectorProp<double>(values);
} else if (elemType == typeid(int)) {
applyVectorProp<int>(values);
} else if (elemType == typeid(long)) {
applyVectorProp<long>(values);
} else if (elemType == typeid(std::string)) {
applyVectorProp<std::string>(values);
} else {
......
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