| 15 | |
| 16 | |
| 17 | std::shared_ptr<std::vector<double> > array_from_object(py::object obj) |
| 18 | { |
| 19 | try { |
| 20 | long nr = obj.cast<long>(); |
| 21 | return std::make_shared<std::vector<double>>(nr); |
| 22 | } catch (py::cast_error&) { |
| 23 | py::list li = obj.cast<py::list>(); |
| 24 | const long nr = len(li); |
| 25 | auto temp = std::make_shared<std::vector<double>>(nr); |
| 26 | for ( long r = 0; r < nr; ++r) |
| 27 | { |
| 28 | (*temp)[r] = li[r].cast<double>(); |
| 29 | } |
| 30 | return temp; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | string array__str__ (const std::vector<double>& v) |
| 35 | { |