-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow selecting raw/proc data in components layer #468
Conversation
self.source_to_modno = {s: (m - first_modno + 1) | ||
for (s, m) in self.source_to_modno.items()} |
Check warning
Code scanning / CodeQL
Overwriting attribute in super-class or sub-class Warning
MultimodDetectorBase
# JUNGFRAU modno is expected (e.g. extra_geom) to start with 1. | ||
self.source_to_modno = {s: (m - first_modno + 1) | ||
for (s, m) in self.source_to_modno.items()} | ||
self.modno_to_source = {m: s for (s, m) in self.source_to_modno.items()} |
Check warning
Code scanning / CodeQL
Overwriting attribute in super-class or sub-class Warning
MultimodDetectorBase
ca4632f
to
f3e861c
Compare
fcc832d
to
ac7240a
Compare
ac7240a
to
26fa54d
Compare
I went over the code changes in
|
Tests all passed. And the major added test |
Good question, I don't know why I did that. I'll put it back.
In this code we only care about the detector data sources - there might be other sources related to detector control, power supply, data processing etc. in the run, which might introduce extra detector names. We don't want to throw an error saying you have to pick from these 3 names if 2 of them won't work. |
c813001
to
6d15a45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM! This looks really neat.
extra_data/components.py
Outdated
source_to_modno = dict(cls._source_matches(data, pat)) | ||
if not all(cls._data_is_raw(data, s) for s in source_to_modno): | ||
# Older corrected data used the same names as raw | ||
raise Exception("Raw data was requested, but only proc data was found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but why no ValueError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I sometimes write Exception as a placeholder when I haven't figured out what the right type is.
In this scenario, what do you think about using SourceNameError
? If we had had distinct source names from the beginning I think this would be a clear choice, but it could be somewhat confusing if the relevant source names are there, just pointing to the wrong thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following discussion, I used SourceNameError
when you want corrected data and only raw is there, because it can point to the new corrected source name, which will definitely be absent.
But when you want raw data and the .../DET/...
source names point to corrected data, it seems confusing to say those sources are missing, so in that case I raise ValueError
. Hopefully the disparity won't matter too much - the error message is probably the important thing in either case.
prnote: |
Preparing for the future when raw & proc data has different names.
You can pass
raw=True
,False
orNone
. The default isNone
, which tries to preserve the legacy behaviour of using proc if possible and raw if not.Opening a draft PR to try the CI.