mirror of
https://github.com/boostorg/histogram.git
synced 2026-01-28 19:22:12 +00:00
issue 45: use operator() to fill; issue 44: removed sum(), use std::for_each or std::accumulate instead; added support for stl containers as fill and index arguments
This commit is contained in:
21
examples/guide_mixed_cpp_python.cpp
Normal file
21
examples/guide_mixed_cpp_python.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//[ guide_mixed_cpp_python_part_cpp
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/histogram.hpp>
|
||||
|
||||
namespace bh = boost::histogram;
|
||||
namespace bp = boost::python;
|
||||
|
||||
// function that runs in C++ and accepts reference to dynamic histogram
|
||||
void process(bh::dynamic_histogram<>& h) {
|
||||
// fill histogram, in reality this would be arbitrarily complex code
|
||||
for (int i = 0; i < 4; ++i)
|
||||
h(0.25 * i, i);
|
||||
}
|
||||
|
||||
// a minimal Python module, which exposes the process function to Python
|
||||
BOOST_PYTHON_MODULE(cpp_filler) {
|
||||
bp::def("process", process);
|
||||
}
|
||||
|
||||
//]
|
||||
Reference in New Issue
Block a user