Skip to content

Commit

Permalink
use autolock_determine_offset isntead of method arguments for autolock
Browse files Browse the repository at this point in the history
  • Loading branch information
bleykauf committed Sep 25, 2024
1 parent 8e5ff97 commit 618a033
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion linien-gui/linien_gui/ui/locking_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def start_manual_lock(self):
)

def auto_offset_changed(self):
self.parameters.autolock_determine_offset.value = int(
self.parameters.autolock_determine_offset.value = bool(
self.autoOffsetCheckbox.checkState()
)

Expand Down
3 changes: 1 addition & 2 deletions linien-server/linien_server/autolock/autolock.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def run(
x0: float,
x1: float,
spectrum: np.ndarray, # array of int
auto_offset: bool = True,
additional_spectra: Optional[list[np.ndarray]] = None,
) -> None:
self.parameters.autolock_status.value = AutolockStatus.LOCKING
Expand All @@ -86,7 +85,7 @@ def run(
) = get_lock_point(self.spectrum, int(x0), int(x1))
self.central_y = int(mean_signal)

if auto_offset:
if self.parameters.autolock_determine_offset.value:
self.control.exposed_pause_acquisition()
self.parameters.combined_offset.value = -1 * self.central_y
self.spectrum -= self.central_y
Expand Down
2 changes: 0 additions & 2 deletions linien-server/linien_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,13 @@ def exposed_start_autolock(
additional_spectra: Optional[bytes] = None,
) -> None:
logger.info(f"Start autolock {x0=} {x1=}")
auto_offset = self.parameters.autolock_determine_offset.value

if self.parameters.task.value is None:
self.parameters.task.value = Autolock(self, self.parameters)
self.parameters.task.value.run(
x0,
x1,
pickle.loads(spectrum),
auto_offset=auto_offset,
additional_spectra=(
pickle.loads(additional_spectra)
if additional_spectra is not None
Expand Down
4 changes: 2 additions & 2 deletions tests/test_algorithm_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_forced_algorithm_selection():
parameters = control.parameters
parameters.autolock_mode_preference.value = mode_preference
autolock = Autolock(control, parameters)
autolock.run(x0, x1, reference_signal, auto_offset=True)
autolock.run(x0, x1, reference_signal)

parameters.to_plot.value = pickle.dumps(
{"error_signal_1": next_signal, "error_signal_2": []}
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_automatic_algorithm_selection():
parameters.autolock_mode_preference.value = AutolockMode.AUTO_DETECT

autolock = Autolock(control, parameters)
autolock.run(x0, x1, reference_signal, auto_offset=True)
autolock.run(x0, x1, reference_signal)

assert autolock.algorithm_selector.mode == AutolockMode.AUTO_DETECT

Expand Down
1 change: 0 additions & 1 deletion tests/test_simple_autolock_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def test_autolock():
int(new_center_point - (0.01 * N)),
int(new_center_point + (0.01 * N)),
reference_signal,
auto_offset=True,
)

parameters.to_plot.value = pickle.dumps(
Expand Down

0 comments on commit 618a033

Please sign in to comment.