xgcm / xhistogram

Fast, flexible, label-aware histograms for numpy and xarray
https://xhistogram.readthedocs.io
MIT License
89 stars 19 forks source link

error in keep_coords option in xarray histogram? #78

Closed sgyeager closed 1 year ago

sgyeager commented 1 year ago

Thanks to the developers of this fabulous tool! I'm getting the following error when using histogram from xhistogram.xarray with keep_coords==True:

TypeError: can only concatenate tuple (not "list") to tuple

I'm sending in a single xarray as args and want to retain the coordinates from my weights xarray. The error occurs at line 122 of xarray.py--since args is not a list, the += fails. I'm still a python newbie and don't know what the fix should be (maybe args=[args] in the line above?), but thought I'd bring it to your attention. Thanks again.

dougiesquire commented 1 year ago

Hi @sgyeager. Welcome to xhistogram and thanks very much for reporting this bug!

I've managed to reproduce the bug and I agree with your diagnosis. A (very simple) fix is implemented in the PR above. Unfortunately, I don't think there's a simple work-around, so hopefully we can get this PR merged soon. If you need the fix more urgently, you could try installing the version in the PR for the time being.