Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-16 08:48:25

0001 import matplotlib
0002 
0003 matplotlib.use("Agg")
0004 
0005 
0006 def test_plotting(tmp_path):
0007     #! [Plotting an ACTS histogram]
0008     import matplotlib.pyplot as plt
0009     import acts
0010 
0011     # `hist` is a `Histogram1`/`ProfileHistogram1`/`Efficiency1` as returned by
0012     # `.histograms()["some_key"]` on a performance writer (see
0013     # Examples/Scripts/Python/pypi_finding_fitting_demo.py for how to build
0014     # one). `acts._demo_histogram1()` stands in for it here.
0015     hist = acts._demo_histogram1()
0016 
0017     fig, ax = plt.subplots()
0018     hist.plot(ax=ax)
0019     fig.savefig(tmp_path / "demo_histogram.png")
0020     #! [Plotting an ACTS histogram]
0021 
0022     plt.close(fig)
0023 
0024 
0025 def test_boost_histogram_conversion():
0026     #! [Converting to boost-histogram]
0027     import boost_histogram as bh
0028     import acts
0029 
0030     hist = acts._demo_histogram1()
0031     bh_hist = bh.Histogram(
0032         hist
0033     )  # any downstream tool that speaks the PlottableHistogram protocol
0034     #! [Converting to boost-histogram]
0035 
0036     assert bh_hist.ndim == 1