-
Notifications
You must be signed in to change notification settings - Fork 10
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
Update the lut linear interpolation to be used by different lookup table files #981
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #981 +/- ##
=======================================
Coverage 97.51% 97.51%
=======================================
Files 152 152
Lines 6346 6347 +1
=======================================
+ Hits 6188 6189 +1
Misses 158 158 ☔ View full report in Codecov by Sentry. |
def linear_interpolation_lut(filename: str) -> Callable[[float], float]: | ||
def parse_lookup_table(filename: str) -> list[Sequence]: | ||
"""Parse a generic lookup table with a number of columns >= 2 and return a list \ | ||
of all the values in it.""" |
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.
Can you reword this - the description makes it sound as though it returns a list in row major order (which is what you'd naively expect) but it actually returns it in column-major order.
) | ||
s_values = list(reversed(s_values)) | ||
t_values = list(reversed(t_values)) | ||
if not np.all(np.diff(s_values) > 0): | ||
raise AssertionError( | ||
f"Configuration file {filename} lookup table does not monotonically increase or decrease." | ||
"Configuration file lookup table does not monotonically increase or decrease." |
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.
It's not a file anymore, it's just a table
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 but I think can you do something to make the error messages nice again - it's a pet hate of mine when something raises an error about a file but then doesn't tell you which file it is!
Perhaps just wrap the outer parse function like:
def lookup_table_from_file(filename: str,
lookup_for_columns: Callable[[Sequence], Callable[[float], float]]) -> Callable[[float], float]:
try:
columns = parse_lookup_table(filename)
except Exception as e:
# log message here
raise
return lookup_for_columns(*columns)
However this may heading down the road of too much boilerplate for some, so I leave it up to you if you want to do this or not.
…ble files (#981) * First idea for beam center, may move compute to plans * Actually make it a plan * Fix the tests * Tidy up docstring * Reword comments
Split the linear_interpolation_lut into two different functions so that it can be used for lookup tables that have more than 2 columns in them (eg. DetDistConverter)
Needed for Mx#708
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}