Update the lut linear interpolation to be used by different lookup table files#981
Update the lut linear interpolation to be used by different lookup table files#981noemifrisina merged 6 commits intomainfrom
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.
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.
| 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.
It's not a file anymore, it's just a table
rtuck99
left a comment
There was a problem hiding this comment.
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}