XENON1T / hax

Handy Analysis for XENON (reduce processed data)
8 stars 0 forks source link

Bypass lax for applying lichens on empty dataframes #238

Closed JelleAalbers closed 6 years ago

JelleAalbers commented 6 years ago

This changes hax.cuts.apply_lichen to skip the lichen evaluation when the dataframe is empty.

Lax's lichens crash when run on empty dataframes. If you do e.g. lax.lichens.sciencerun1.AllEnergy().process(df.iloc[:0]), where df is any normal dataframe, you will get an error like this: ValueError: cannot set a frame with no defined index and a scalar. The problem seems to come from setting new columns on dataframes (in certain ways?) -- which lax, and individual lichens, do in several places.

Empty dataframes arise in practical usage in two ways:

It might be possible to fix this on lax' end, however:

feigaodm commented 6 years ago

Thanks @JelleAalbers ! It looks nice from my side. I'll merge it unless there is objections or planned change

JelleAalbers commented 6 years ago

Sounds good, thanks! I added a small change earlier today that fixes a similar rare error related to empty dataframes, but if I find more I will make a new PR.