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

Function axis_array_interface

src/python/axis.cpp:161–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159#ifdef HAVE_NUMPY
160template <typename Axis>
161bp::object axis_array_interface(const Axis& axis) {
162 using T = typename std::decay<typename Axis::value_type>::type;
163 bp::dict d;
164 auto shape = bp::make_tuple(axis.size() + 1);
165 d["shape"] = shape;
166 d["typestr"] = bp::dtype_typestr<T>();
167 // make new array, and pass it to Python
168 auto a = np::empty(shape, np::dtype::get_builtin<T>());
169 auto buf = reinterpret_cast<T*>(a.get_data());
170 for (auto i = 0; i < axis.size() + 1; ++i) buf[i] = axis.lower(i);
171 d["data"] = a;
172 d["version"] = 3;
173 return d;
174}
175
176template <>
177bp::object axis_array_interface<bha::category<>>(const bha::category<>& axis) {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected