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:
23
examples/guide_mixed_cpp_python.py
Normal file
23
examples/guide_mixed_cpp_python.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#[ guide_mixed_cpp_python_part_py
|
||||
|
||||
from __future__ import print_function
|
||||
import histogram as bh
|
||||
import cpp_filler
|
||||
|
||||
h = bh.histogram(bh.axis.regular(4, 0, 1),
|
||||
bh.axis.integer(0, 4))
|
||||
|
||||
cpp_filler.process(h) # histogram is filled with input values in C++
|
||||
|
||||
for iy, y in enumerate(h.axis(1)):
|
||||
for ix, x in enumerate(h.axis(0)):
|
||||
print(h(ix, iy).value, end=' ')
|
||||
print()
|
||||
|
||||
# prints:
|
||||
# 1.0 0.0 0.0 0.0
|
||||
# 0.0 1.0 0.0 0.0
|
||||
# 0.0 0.0 1.0 0.0
|
||||
# 0.0 0.0 0.0 1.0
|
||||
|
||||
#]
|
||||
Reference in New Issue
Block a user