From 0bc35466aaf814b7f2d7ddaa7c1ca867eaa123a6 Mon Sep 17 00:00:00 2001 From: appel_c Date: Tue, 3 Jun 2025 17:31:30 +0200 Subject: [PATCH] refactor(exafs-scan): improve docstring and logmessage --- superxas_bec/scans/exafs_scan.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/superxas_bec/scans/exafs_scan.py b/superxas_bec/scans/exafs_scan.py index ff70d64..a73e0f2 100644 --- a/superxas_bec/scans/exafs_scan.py +++ b/superxas_bec/scans/exafs_scan.py @@ -65,18 +65,27 @@ class EXAFSScan(ScanBase): def _check_and_upated_input_arguments(self) -> None: """ - If any of xas_rel_range, n_points, k_step or integ_time is None, - this method will compute to a default behaviour for the value. + Input parameters for the EXAFS scan must be of the same length for n_points, k_step, integ_time + and xas_rel_range (-1). This methods checks for this condition, and calculates the integration time + for each point in the scan. If the input parameters are not provided with the correct length, + it raises a ValueError which indicates which parameters are not matching. """ if not all( [ len(self.n_points) == len(self.k_step), len(self.n_points) == len(self.integ_time), - len(self.n_points) == (len(self.xas_rel_range) - 1), # carefule -1 + len(self.n_points) == (len(self.xas_rel_range) - 1), # careful -1 ] ): - raise ValueError("Wrong length for bla") # TODO add better error handling + raise ValueError( + f"Input parameters must have matching lengths:\n" + f"n_points: {len(self.n_points)}, " + f"k_step: {len(self.k_step)}, expected: {len(self.n_points)}, " + f"integ_time: {len(self.integ_time)}, expected: {len(self.n_points)}, " + f"xas_rel_range: {len(self.xas_rel_range)}, expected: {len(self.n_points)-1} " + ) + self.integ_time = np.repeat(np.array(self.integ_time), np.array(self.n_points)) def _set_position_offset(self):