From d5d7d1f613e0eaee1dc673131510a6b81f6690ca Mon Sep 17 00:00:00 2001 From: Jan Wyzula <133381102+wyzula-jan@users.noreply.github.com> Date: Tue, 16 Jun 2026 18:01:56 +0200 Subject: [PATCH] fix(sim): mixed_mon zero division guard Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- ophyd_devices/sim/sim_monitor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ophyd_devices/sim/sim_monitor.py b/ophyd_devices/sim/sim_monitor.py index 7e79692..aa0eaf3 100644 --- a/ophyd_devices/sim/sim_monitor.py +++ b/ophyd_devices/sim/sim_monitor.py @@ -408,6 +408,8 @@ class SimMonitorMixedSignals(PSIDeviceBase, SimMonitorMixedSignalsControl): def _generate_spectrum(self) -> np.ndarray: """Generate a noisy 1D spectrum whose peak drifts with the trigger counter.""" size = int(self.spectrum_size.get()) + if size <= 0: + raise ValueError(f"{self.name}: spectrum_size must be > 0, got {size}") x = np.arange(size) center = (self._counter * max(size // 20, 1)) % size spectrum = 100 * np.exp(-((x - center) ** 2) / (2 * (size / 20) ** 2))