Commit fb47e270 authored by Alexander Dielen's avatar Alexander Dielen

store 1d arrays as scalar properties

parent b3189504
Pipeline #7300 passed with stages
in 5 minutes and 51 seconds
......@@ -157,11 +157,13 @@ public:
throw py::error_already_set();
}
// reshape to (n, 1) if necessary
if (_arr.ndim() == 1) {
_arr.resize({n, size_t(1)});
// special case: use scalar properties
for (size_t i = 0; i < n; ++i) {
Mesh::property(prop, Handle(i)) = py::float_(_arr.at(i));
}
}
else {
// copy one array at a time
const size_t size = _arr.strides(0) / sizeof(double);
for (size_t i = 0; i < n; ++i) {
......@@ -174,6 +176,7 @@ public:
Mesh::property(prop, Handle(i)) = tmp;
}
}
}
template <class Handle, class PropHandle>
void py_copy_property(const std::string& _name, Handle _from, Handle _to) {
......
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