dask-awkward icon indicating copy to clipboard operation
dask-awkward copied to clipboard

support for dask_awkward.mean() needed

Open green-cabbage opened this issue 10 months ago • 6 comments

Dear Developers.

Hello, I am one of the graduate students working with dask_awkward within coffea 2023 pacakage, and it seems like support for dask_awkward,mean() function is missing. What I need for my workflow is dask_awkward implementation of mean() function onto a 1 dimensional array, which means support for dask_awkward,mean() either in the axis=None or axis=0, such that something like this is possible:

njet_selection = dak.num(jets, axis=1)
qgl_nom = (qgl1*qgl2) # this is 1 dimensional dak array
qgl_mean = dak.mean(qgl_nom[njet_selection])
qgl_nom = qgl_nom/ qgl_mean

Please let me know if you have any questions or issues!

green-cabbage avatar Mar 27 '24 19:03 green-cabbage

https://github.com/dask-contrib/dask-awkward/blob/main/src/dask_awkward/lib/reducers.py#L329

lgray avatar Mar 27 '24 20:03 lgray

and it has been in the top level package for some time.

https://github.com/dask-contrib/dask-awkward/blob/main/src/dask_awkward/init.py#L56

lgray avatar Mar 27 '24 20:03 lgray

https://github.com/dask-contrib/dask-awkward/blob/main/src/dask_awkward/lib/reducers.py#L329

So this only supports axis that is not None or zero. What I am looking for (at least for now) is a mean functionality that that reduces over those axis. Edit: sorry for the weird closing and opening. I am getting used to this github issue gimmick :/

green-cabbage avatar Mar 27 '24 20:03 green-cabbage

To get the mean, you of course need the sum and a count. I believe both of those are supported, so for axis=None/0, it could call those.

martindurant avatar Mar 27 '24 20:03 martindurant

Just confirmed with a small test code that dak.count() and dak.sum() supports axis=None and axis=0, so this issue is solved. I will reopen this issue if further testing leads to issues. Thanks!

Edit: With request from Nick Manganelli. I won't close this issue as others would also come to the same issue and quit, assuming dak.count() and dak.sum() wouldn't support axis=0 or None if dak.mean() doesn't support it

green-cabbage avatar Mar 27 '24 21:03 green-cabbage

Agree, this is a two-line fix when someone has the time.

martindurant avatar Mar 28 '24 01:03 martindurant