-
Notifications
You must be signed in to change notification settings - Fork 1
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
Raise errors if we are trying to access values outside of the distance and pulse range of the time-of-flight lookup table #211
base: main
Are you sure you want to change the base?
Conversation
ltotal: sc.Variable, | ||
event_time_offset: sc.Variable, | ||
) -> sc.Variable: | ||
if pulse_index.unit != sc.units.dimensionless: |
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.
Shouldn't it have unit == None
?
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.
We could... it comes from (event_time_zero - reference) // pulse_period
. So it's kind of dimensionless, but it's true that it doesn't represent a physical quantity.
It would add some code like manually setting pulse_index.unit = None
, which currently is not needed.
I don't mind either way.
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.
We had a similar discussion at some point in ESSreflectometry. If the index is used in mathematical operations with non-index quantities, then it is easiest to stick with dimensionless. Otherwise, I'd switch to unit=None
.
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.
How about having if pulse_index.unit not in ('', None):
so that we can decide to change it to None
later and it won't break here?
Currently, we are using numpy/scipy to perform the interpolation, so the unit doesn't really matter.
But we may decide to change to using Scipp in the future.
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.
Sure
f"pulse_index must be dimensionless, but got unit: {pulse_index.unit}." | ||
) | ||
if ltotal.unit != self._distance_unit: | ||
raise 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.
raise ValueError( | |
raise sc.UnitError( |
?
And the same for the other cases.
Errors are now raised if we attempt to compute tof outside of the
distance
andpulse
range of the lookup table.We do not raise for the
event_time_offset
range (even though it should all wrap around 71ms) because histogrammed monitors often have binning which can be anything (does not necessarily stop at 71ms).Raising an error here would be too restrictive, and warnings would add noise to the workflows.