Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support interface matrix #47

Merged
merged 18 commits into from
Nov 16, 2024
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ repos:
rev: 'v1.13.0' # Use the sha / tag you want to point at
hooks:
- id: mypy
files: src
additional_dependencies: [uhi, numpy]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ or force yoda use with
import babyyoda.yoda as yoda
```

## Interfaces

| Interface | Status | Examples and Notes |
| ---------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------ |
| [histoprint](https://github.com/scikit-hep/histoprint) | ✅ | [histo1d](examples/interface/histoprint/histo1d.ipynb) |
| [mplhep](https://github.com/scikit-hep/mplhep) | ✅ | [histo1d](examples/interface/mplhep/histo1d.ipynb), [histo2d](examples/interface/mplhep/histo2d.ipynb) |
| [plothist](https://github.com/scikit-hep/plothist) | ❌ | Does not support UHI/PlottableProtocol, only boost-histogram |
| [uproot](https://github.com/scikit-hep/uproot) | ❌ | WIP: [histo1d](examples/interface/uproot/histo1d.ipynb) |
| [hist](https://github.com/scikit-hep/hist) | ✅ | [histo1d](examples/interface/hist/histo1d.ipynb), [histo2d](examples/interface/hist/histo2d.ipynb) |
| [boost-histogram](https://github.com/scikit-hep/boost-histogram) | ✅ | [histo1d](examples/interface/boost-histogram/histo1d.ipynb), [histo2d](examples/interface/boost-histogram/histo2d.ipynb) |
| [cuda-histogram](https://github.com/scikit-hep/cuda-histogram) | ❔ | |
| [ROOT](https://github.com/root-project/root) | ❔ | |

## License

`babyyoda` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
`babyyoda` is distributed under the terms of the [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) license.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

140 changes: 140 additions & 0 deletions examples/interface/boost-histogram/histo1d.ipynb

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions examples/interface/boost-histogram/histo2d.ipynb

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions examples/interface/hist/.ipynb_checkpoints/histo1d-checkpoint.ipynb

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions examples/interface/hist/.ipynb_checkpoints/histo2d-checkpoint.ipynb

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions examples/interface/hist/histo1d.ipynb

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions examples/interface/hist/histo2d.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"id": "615547eb-5c01-4749-9069-e75dbaf24d83",
"metadata": {},
"outputs": [],
"source": [
"from histoprint import print_hist\n",
"import babyyoda"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "556cb6d5-a1e3-472f-854a-ad0ac230a622",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'/': GROGU_HISTO1D_V3(d_annotations={'Path': '/', 'Title': 'test', 'Type': 'Histo1D'}, d_key='/', d_edges=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], d_bins=[GROGU_HISTO1D_V3.Bin(d_sumw=3.0, d_sumw2=3.0, d_sumwx=-5.0, d_sumwx2=9.0, d_numentries=3.0), GROGU_HISTO1D_V3.Bin(d_sumw=0.0, d_sumw2=0.0, d_sumwx=0.0, d_sumwx2=0.0, d_numentries=0.0), GROGU_HISTO1D_V3.Bin(d_sumw=1.0, d_sumw2=1.0, d_sumwx=1.0, d_sumwx2=1.0, d_numentries=1.0), GROGU_HISTO1D_V3.Bin(d_sumw=2.0, d_sumw2=2.0, d_sumwx=4.0, d_sumwx2=8.0, d_numentries=2.0), GROGU_HISTO1D_V3.Bin(d_sumw=3.0, d_sumw2=3.0, d_sumwx=9.0, d_sumwx2=27.0, d_numentries=3.0), GROGU_HISTO1D_V3.Bin(d_sumw=4.0, d_sumw2=4.0, d_sumwx=16.0, d_sumwx2=64.0, d_numentries=4.0), GROGU_HISTO1D_V3.Bin(d_sumw=5.0, d_sumw2=5.0, d_sumwx=25.0, d_sumwx2=125.0, d_numentries=5.0), GROGU_HISTO1D_V3.Bin(d_sumw=6.0, d_sumw2=6.0, d_sumwx=36.0, d_sumwx2=216.0, d_numentries=6.0), GROGU_HISTO1D_V3.Bin(d_sumw=7.0, d_sumw2=7.0, d_sumwx=49.0, d_sumwx2=343.0, d_numentries=7.0), GROGU_HISTO1D_V3.Bin(d_sumw=8.0, d_sumw2=8.0, d_sumwx=64.0, d_sumwx2=512.0, d_numentries=8.0), GROGU_HISTO1D_V3.Bin(d_sumw=9.0, d_sumw2=9.0, d_sumwx=81.0, d_sumwx2=729.0, d_numentries=9.0), GROGU_HISTO1D_V3.Bin(d_sumw=21.0, d_sumw2=21.0, d_sumwx=221.0, d_sumwx2=2331.0, d_numentries=21.0)])}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"h = babyyoda.read(\"../../../tests/test_histo1d_v3.yoda\")\n",
"h"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "8d443f31-3ce2-49ee-ae3f-79d3103cf1d7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" test \n",
" 0.000 _ x 10^+01 9/row ╷\n",
" 0.100 _\n",
" 0.200 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.300 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.400 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.500 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.600 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.700 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.800 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 0.900 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" 1.000 _\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\u001b[90;40m█\u001b[39;49m\n",
" \u001b[90;40m█\u001b[39;49m \n",
" Tot: 4.50e+01 \n",
" Avg: 6.83e-01 \n",
" Std: 2.21e-01 \n"
]
}
],
"source": [
"v=h['/']\n",
"print_hist(v, summary=True, title=v.title())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading