fix(sim): mixed_mon zero division guard

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jan Wyzula
2026-06-17 10:14:40 +02:00
committed by wyzula_j
co-authored by Copilot Autofix powered by AI
parent 5a604b02d1
commit d5d7d1f613
+2
View File
@@ -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))