MCPcopy Create free account
hub / github.com/davisking/dlib / array_from_object

Function array_from_object

tools/python/src/basic.cpp:17–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17std::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
34string array__str__ (const std::vector<double>& v)
35{

Callers

nothing calls this directly

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected