From 1b0e73d90ea67689e1032bc7ce1d5e1591a224a3 Mon Sep 17 00:00:00 2001 From: PMB Date: Thu, 25 Jun 2026 10:02:31 -0500 Subject: [PATCH] Use public hamma.diagnostic_data in NoiseDiag plugin hamma 0.3.0 made diagnostic_data public; switch the plugin and its test patches from the private _diagnostic_data to the top-level re-export. Co-Authored-By: Claude Sonnet 4.6 --- plugins/noise_diag.py | 4 ++-- tests/python/test_noise_diag.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/noise_diag.py b/plugins/noise_diag.py index 21dbc39..bf4c99f 100644 --- a/plugins/noise_diag.py +++ b/plugins/noise_diag.py @@ -6,7 +6,7 @@ from pathlib import Path import hamma -from hamma.header.core import _diagnostic_data +from hamma import diagnostic_data # HAMMA2 fast-channel sample rate. preTriggerSize is a count of fast samples; # the header's sampleRateFast field is not populated, so use the known rate. @@ -92,7 +92,7 @@ def _compute(self, input_data): pretrigger_ms, self.min_pretrigger_ms) return None - offset, vmax, vmin, noise = _diagnostic_data(data.voltFast, self.medsize) + offset, vmax, vmin, noise = diagnostic_data(data.voltFast, self.medsize) vpp = float(vmax) - float(vmin) snr = vpp / noise if noise else float("nan") threshold = float(h.data.threshold.iloc[0]) diff --git a/tests/python/test_noise_diag.py b/tests/python/test_noise_diag.py index 5880e48..bccfb7b 100644 --- a/tests/python/test_noise_diag.py +++ b/tests/python/test_noise_diag.py @@ -26,6 +26,7 @@ def load_module(diag_return=(0.1, 4.7, -4.7, 0.035), volt_fast=object(), thresho mock_brokkr.pipeline.base = mock_base mock_hamma = MagicMock() + mock_hamma.diagnostic_data.return_value = diag_return if times_fast is None: times_fast = np.array(["2026-06-23T21:36:57.000", "2026-06-23T21:36:58.857", "2026-06-23T21:36:59.000"], dtype="datetime64[ms]") @@ -43,7 +44,6 @@ def _col(name): return col header.data.__getitem__.side_effect = _col mock_hamma.Header.return_value = header - mock_core = MagicMock(); mock_core._diagnostic_data.return_value = diag_return with patch.dict("sys.modules", { "brokkr": mock_brokkr, "brokkr.pipeline": mock_pipeline, @@ -53,7 +53,6 @@ def _col(name): "brokkr.config.unit": MagicMock(), "brokkr.config.metadata": MagicMock(), "hamma": mock_hamma, "hamma.header": MagicMock(), - "hamma.header.core": mock_core, "notifiers": MagicMock(), }): spec = importlib.util.spec_from_file_location("noise_diag", str(PLUGIN_PATH)) @@ -135,7 +134,7 @@ def test_compute_skips_short_pretrigger(): step.medsize = 200000 step.min_pretrigger_ms = 50 step.logger = MagicMock() - with patch.object(module, "_diagnostic_data") as mock_diag: + with patch.object(module, "diagnostic_data") as mock_diag: result = step._compute(make_input()) assert result is None mock_diag.assert_not_called()