Closed philsmt closed 5 months ago
I separated the changes to FileAccess
and SourceData
in separate commits for easier review.
Other than that one comment, LGTM.
I agree that it makes sense to throw an error for a non-existent index group. :+1:
I added two additional minor changes for FileAccess
:
None
identity rather than boolean False
Will merge later today unless something comes up.
During the offline data reduction trials, calls to
SourceData._get_index_group_sample()
ended up being a significant performance problem, as the current implementation triggers a call to the fairly expensiveSourceData.keys()
.Initially this was fixed by overwriting this method only within
exdf-tools
, this MR means to upstream these changes now.Since the improved implementation is based on
SourceData.one_key()
, I decided to augment this method by an optional keyword argumentindex_group
and entirely replace the usage of_get_index_group_sample()
.Something I noticed in the implementation is that
FileAccess.get_one_key()
(and in extensionSourceData.one_key()
) may technically returnNone
if a source has no keys. While the selection mechanism prevents no keys to be selected, it does not seem to prevent files with key-less sources. I would not expect the current DAQ or calibration to create such files, but it's not impossible for someone external to prepare them. For now I decided to not change any behaviour, but preserve the one from_get_index_group_sample()
and raise an exception if asking for a non-existing index group.