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

Function histogram_reduce_to

src/python/histogram.cpp:313–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313bp::object histogram_reduce_to(bp::tuple args, bp::dict kwargs) {
314 if (kwargs) { throw std::invalid_argument("no keyword arguments allowed"); }
315 const pyhistogram& self = bp::extract<const pyhistogram&>(args[0]);
316
317 const auto nargs = bp::len(args) - 1;
318 if (nargs == 0) { throw std::invalid_argument("at least one argument required"); }
319
320 if (nargs > BOOST_HISTOGRAM_AXIS_LIMIT) {
321 throw std::invalid_argument(
322 bh::detail::cat("too many arguments, maximum is ", BOOST_HISTOGRAM_AXIS_LIMIT)
323 .c_str());
324 }
325
326 int idx[BOOST_HISTOGRAM_AXIS_LIMIT];
327 for (auto i = 0u; i < nargs; ++i) {
328 idx[i] = bp::extract<int>(args[1 + i]);
329 if (i > 0 && idx[i] <= idx[i - 1])
330 throw std::invalid_argument("indices must be strictly ascending");
331 }
332
333 return bp::object(self.reduce_to(idx, idx + nargs));
334}
335
336std::string histogram_repr(const pyhistogram& h) { return bh::detail::cat(h); }
337

Callers

nothing calls this directly

Calls 2

catFunction · 0.85
reduce_toMethod · 0.80

Tested by

no test coverage detected