Skip to content

Commit

Permalink
warn in print() when user is about to compute dask stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrommyd committed Sep 17, 2023
1 parent 2fee783 commit 3bdff8c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/coffea/analysis_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,16 @@ def to_npz(self, file, compressed=False, compute=False):
else:
return out

def print(self):
def print(self, compute=False):
"""Prints the statistics of the N-1 selection"""

if self._delayed_mode:
if self._delayed_mode and not compute:
warnings.warn(
"This will compute dask_awkward arrays. If you really want to do this now, call print(compute=True)"
)
return

if self._delayed_mode and compute:
self._nev = list(dask.compute(*self._nev))

nev = self._nev
Expand Down Expand Up @@ -830,10 +836,16 @@ def to_npz(self, file, compressed=False, compute=False):
else:
return out

def print(self):
def print(self, compute=False):
"""Prints the statistics of the Cutflow"""

if self._delayed_mode:
if self._delayed_mode and not compute:
warnings.warn(
"This will compute dask_awkward arrays. If you really want to do this now, call print(compute=True)"
)
return

if self._delayed_mode and compute:
self._nevonecut, self._nevcutflow = dask.compute(
self._nevonecut, self._nevcutflow
)
Expand Down

0 comments on commit 3bdff8c

Please sign in to comment.