RNO-G / mattak

RNO-G dataformats
1 stars 1 forks source link

Implement sanity checks that files are available. #34

Closed fschlueter closed 4 months ago

fschlueter commented 4 months ago

Currently with the pyroot backend it is not checked in every case whether a file is present. I get the following error when a file is not present:

  File "/Users/felix/software/rnog/mattak/py/mattak/backends/pyroot/dataset.py", line 72, in __init__
    self.setEntries(0)
  File "/Users/felix/software/rnog/mattak/py/mattak/Dataset.py", line 58, in setEntries
    raise ValueError(f"The entry you specified \"{i}\" does not exist.")
ValueError: The entry you specified "0" does not exist.

That can be misleading for unexperienced users.

In general I am not sure that I like the theme "try to load something, and if that fails fall back to something else". Because in the end I want to know that things failed and also why.

cozzyd commented 4 months ago

I was confused until I saw that this would only happen on your branch (because you added an bounds check on setEntries.)

I have added changes that will raise an IOError if the headers can't be found (and also warn if you load an apparently empty run).