Skip to content

Commit

Permalink
hopefully finalize this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrommyd committed Jun 27, 2023
1 parent 7c92981 commit c9dae1b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 69 deletions.
80 changes: 40 additions & 40 deletions binder/packedselection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@
{
"data": {
"text/html": [
"<pre>[{fixedGridRhoFastjetCentralChargedPileUp: 9.14, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 14.9, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 9.47, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 15.3, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 10.9, Muon: [...], ChsMET: ..., ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 22.8, Muon: [{...}], ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 2.38, Muon: [...], ChsMET: ..., ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 13.7, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 10.9, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 9.26, Muon: [], ChsMET: {...}, ...},\n",
"<pre>[{FsrPhoton: [], Electron: [], SoftActivityJetHT5: 63.5, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 64, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [Electron, Electron], SoftActivityJetHT5: 130, ...},\n",
" {FsrPhoton: [], Electron: [Electron, Electron], SoftActivityJetHT5: 25.8, ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 172, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 54.4, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 96.2, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 19, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 9.36, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 115, RawMET: ..., ...},\n",
" ...,\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 9.34, Muon: [{...}], ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 11.1, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 14.1, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 17.3, Muon: [{...}], ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 15.5, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 23.5, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 11, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 14.1, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 13.3, Muon: [], ChsMET: {...}, ...}]\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 49.6, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 14.7, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 22.1, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 33.9, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 16.2, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 28.4, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 16.1, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 28.5, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 7, RawMET: {...}, ...}]\n",
"--------------------------------------------------------------------------------\n",
"type: 40 * event</pre>"
],
"text/plain": [
"<NanoEventsArray [<event 1:13889:3749778>, <event 1:13889:3749762>, <event 1:13889:3749777>, ..., <event 1:13889:3749882>, <event 1:13889:3749892>] type='...'>"
"<NanoEventsArray [<event 1:13889:3749778>, ...] type='40 * event'>"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -1078,31 +1078,31 @@
{
"data": {
"text/html": [
"<pre>[{fixedGridRhoFastjetCentralChargedPileUp: 9.14, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 14.9, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 9.47, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 15.3, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 10.9, Muon: [...], ChsMET: ..., ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 22.8, Muon: [{...}], ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 2.38, Muon: [...], ChsMET: ..., ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 13.7, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 10.9, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 9.26, Muon: [], ChsMET: {...}, ...},\n",
"<pre>[{FsrPhoton: [], Electron: [], SoftActivityJetHT5: 63.5, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 64, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [Electron, Electron], SoftActivityJetHT5: 130, ...},\n",
" {FsrPhoton: [], Electron: [Electron, Electron], SoftActivityJetHT5: 25.8, ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 172, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 54.4, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 96.2, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 19, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 9.36, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 115, RawMET: ..., ...},\n",
" ...,\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 9.34, Muon: [{...}], ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 11.1, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 14.1, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 17.3, Muon: [{...}], ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 15.5, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 23.5, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 11, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 14.1, Muon: [], ChsMET: {...}, ...},\n",
" {fixedGridRhoFastjetCentralChargedPileUp: 13.3, Muon: [], ChsMET: {...}, ...}]\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 49.6, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 14.7, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 22.1, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 33.9, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 16.2, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 28.4, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [{...}], SoftActivityJetHT5: 16.1, RawMET: ..., ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 28.5, RawMET: {...}, ...},\n",
" {FsrPhoton: [], Electron: [], SoftActivityJetHT5: 7, RawMET: {...}, ...}]\n",
"--------------------------------------------------------------------------------\n",
"type: 40 * event</pre>"
],
"text/plain": [
"<NanoEventsArray [<event 1:13889:3749778>, <event 1:13889:3749762>, <event 1:13889:3749777>, ..., <event 1:13889:3749882>, <event 1:13889:3749892>] type='...'>"
"<NanoEventsArray [<event 1:13889:3749778>, ...] type='40 * event'>"
]
},
"execution_count": 26,
Expand Down
15 changes: 3 additions & 12 deletions src/coffea/analysis_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,7 @@ def yieldhist(self):
h = hist.dask.Hist(hist.axis.Integer(0, len(labels), name="N-1"))
for i, weight in enumerate(self._masks, 1):
h.fill(dask_awkward.full_like(weight, i, dtype=int), weight=weight)
h.fill(
dask_awkward.from_awkward(awkward.Array([0]), 1),
weight=dask_awkward.from_awkward(awkward.Array([len(weight)]), 1),
)
h.fill(dask_awkward.zeros_like(weight))

return h, labels

Expand Down Expand Up @@ -871,18 +868,12 @@ def yieldhist(self):
honecut.fill(
dask_awkward.full_like(weight, i, dtype=int), weight=weight
)
honecut.fill(
dask_awkward.from_awkward(awkward.Array([0]), 1),
weight=dask_awkward.from_awkward(awkward.Array([len(weight)]), 1),
)
honecut.fill(dask_awkward.zeros_like(weight))
for i, weight in enumerate(self._maskscutflow, 1):
hcutflow.fill(
dask_awkward.full_like(weight, i, dtype=int), weight=weight
)
hcutflow.fill(
dask_awkward.from_awkward(awkward.Array([0]), 1),
weight=dask_awkward.from_awkward(awkward.Array([len(weight)]), 1),
)
hcutflow.fill(dask_awkward.zeros_like(weight))

return honecut, hcutflow, labels

Expand Down
33 changes: 16 additions & 17 deletions tests/test_analysis_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np
import pytest
import uproot
from dask_awkward.utils import IncompatiblePartitions
from dummy_distributions import dummy_jagged_eta_pt

from coffea.nanoevents import NanoAODSchema, NanoEventsFactory
Expand Down Expand Up @@ -883,10 +882,10 @@ def test_packed_selection_nminusone_dak(optimization_enabled):

assert np.all(h.counts() == list(dask.compute(*nev)))

with pytest.raises(IncompatiblePartitions):
nminusone.plot_vars(
{"Ept": events.Electron.pt, "Ephi": events.Electron.phi[:20]}
)
# with pytest.raises(IncompatiblePartitions):
# nminusone.plot_vars(
# {"Ept": events.Electron.pt, "Ephi": events[:20].Electron.phi}
# )
hs, hslabels = dask.compute(
*nminusone.plot_vars(
{"Ept": events.Electron.pt, "Ephi": events.Electron.phi}
Expand Down Expand Up @@ -1007,10 +1006,10 @@ def test_packed_selection_cutflow_dak(optimization_enabled):
assert np.all(honecut.counts() == list(dask.compute(*nevonecut)))
assert np.all(hcutflow.counts() == list(dask.compute(*nevcutflow)))

with pytest.raises(IncompatiblePartitions):
cutflow.plot_vars(
{"Ept": events.Electron.pt, "Ephi": events.Electron.phi[:20]}
)
# with pytest.raises(IncompatiblePartitions):
# cutflow.plot_vars(
# {"Ept": events.Electron.pt, "Ephi": events[:20].Electron.phi}
# )
honecuts, hcutflows, hslabels = dask.compute(
*cutflow.plot_vars({"ept": events.Electron.pt, "ephi": events.Electron.phi})
)
Expand Down Expand Up @@ -1138,10 +1137,10 @@ def test_packed_selection_nminusone_dak_uproot_only(optimization_enabled):

assert np.all(h.counts() == list(dask.compute(*nev)))

with pytest.raises(IncompatiblePartitions):
nminusone.plot_vars(
{"Ept": events.Electron_pt, "Ephi": events.Electron_phi[:20]}
)
# with pytest.raises(IncompatiblePartitions):
# nminusone.plot_vars(
# {"Ept": events.Electron_pt, "Ephi": events[:20].Electron_phi}
# )
hs, hslabels = dask.compute(
*nminusone.plot_vars(
{"Ept": events.Electron_pt, "Ephi": events.Electron_phi}
Expand Down Expand Up @@ -1262,10 +1261,10 @@ def test_packed_selection_cutflow_dak_uproot_only(optimization_enabled):
assert np.all(honecut.counts() == list(dask.compute(*nevonecut)))
assert np.all(hcutflow.counts() == list(dask.compute(*nevcutflow)))

with pytest.raises(IncompatiblePartitions):
cutflow.plot_vars(
{"Ept": events.Electron_pt, "Ephi": events.Electron_phi[:20]}
)
# with pytest.raises(IncompatiblePartitions):
# cutflow.plot_vars(
# {"Ept": events.Electron_pt, "Ephi": events[:20].Electron_phi}
# )
honecuts, hcutflows, hslabels = dask.compute(
*cutflow.plot_vars({"ept": events.Electron_pt, "ephi": events.Electron_phi})
)
Expand Down

0 comments on commit c9dae1b

Please sign in to comment.