16#include <boost/python/class.hpp>
17#include <boost/python/list.hpp>
19#include <boost/python/default_call_policies.hpp>
20#include <boost/python/make_constructor.hpp>
34using return_cloned_numpy = return_value_policy<Policies::VectorRefToNumpy<Converters::Clone>>;
42 std::vector<std::string> values = self();
45 std::vector<size_t> stringSizes;
48 stringSizes.reserve(self.
size());
52 for (
auto val : values) {
53 auto size = val.size();
54 stringSizes.emplace_back(size);
58 size_t max = *std::max_element(std::begin(stringSizes), std::end(stringSizes));
63 std::string retVal = ss.str();
67#define EXPORT_ARRAY_PROP(type, prefix) \
68 class_<ArrayProperty<type>, bases<PropertyWithValue<std::vector<type>>>, boost::noncopyable>( \
69 #prefix "ArrayProperty", no_init) \
70 .def(init<const std::string &, const unsigned int>( \
71 (arg("self"), arg("name"), arg("direction") = Direction::Input), \
72 "Construct an ArrayProperty of type " #type)) \
74 .def(init<const std::string &, IValidator_sptr, const unsigned int>( \
75 (arg("self"), arg("name"), arg("validator"), arg("direction") = Direction::Input), \
76 "Construct an ArrayProperty of type " #type " with a validator")) \
78 .def(init<const std::string &, const std::string &, IValidator_sptr, const unsigned int>( \
79 (arg("self"), arg("name"), arg("values"), arg("validator") = IValidator_sptr(new NullValidator), \
80 arg("direction") = Direction::Input), \
81 "Construct an ArrayProperty of type " #type " with a validator giving the values as a string")) \
83 make_constructor(&createArrayPropertyFromList<type>, default_call_policies(), \
84 (arg("name"), arg("values"), arg("validator") = IValidator_sptr(new NullValidator), \
85 arg("direction") = Direction::Input))) \
87 make_constructor(&createArrayPropertyFromNDArray<type>, default_call_policies(), \
88 (arg("name"), arg("values"), arg("validator") = IValidator_sptr(new NullValidator), \
89 arg("direction") = Direction::Input))) \
90 .def("dtype", &dtype<type>, arg("self")) \
91 .add_property("value", make_function(&ArrayProperty<type>::operator(), return_cloned_numpy()));
102ArrayProperty<T> *createArrayPropertyFromList(
const std::string &name,
const boost::python::list &values,
103 const IValidator_sptr &validator,
const unsigned int direction) {
118 const IValidator_sptr &validator,
const unsigned int direction) {
std::string dtype(Mantid::Kernel::PropertyWithValue< HeldType > &self)
#define EXPORT_ARRAY_PROP(type, prefix)
void export_ArrayProperty()
Support for a property that holds an array of values.
NullValidator is a validator that doesn't.
The concrete, templated class for properties.
int size() const override
Return the size of this property.
Thin object wrapper around a numpy array.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
std::string dtype(const Container< HeldType > &)
Describes the direction (within an algorithm) of a Property.
Converter taking an input numpy array and converting it to a std::vector.
Converts a Python sequence type to a C++ std::vector, where the element type is defined by the templa...