MCPcopy Create free account
hub / github.com/boostorg/histogram / array_interface

Method array_interface

src/python/histogram.cpp:95–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 };
94
95 static bp::object array_interface(const pyhistogram& self) {
96 bp::dict d;
97 bp::list shapes;
98 bp::list strides;
99 auto& b = self.storage_.buffer_;
100 d["typestr"] = bh::detail::apply(dtype_visitor(), b, shapes, strides);
101 for (std::size_t i = 0; i < self.dim(); ++i) {
102 if (i > 0) strides.append(strides[-1] * shapes[-1]);
103 shapes.append(self.axis(i).shape());
104 }
105 if (self.dim() == 0) shapes.append(0);
106 d["shape"] = bp::tuple(shapes);
107 d["strides"] = bp::tuple(strides);
108 d["data"] = bh::detail::apply(data_visitor(), b, shapes, strides);
109 return d;
110 }
111};
112} // namespace histogram
113} // namespace boost

Callers

nothing calls this directly

Calls 6

applyFunction · 0.85
dtype_visitorClass · 0.85
data_visitorClass · 0.85
axisMethod · 0.80
dimMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected