From dd4ad4688b9b82f746a93f58df2a3d06326c8f8e Mon Sep 17 00:00:00 2001 From: JonasViehweger Date: Thu, 12 Feb 2026 10:36:48 +0100 Subject: [PATCH 1/2] Matplotlib 3.9.1 was yanked on windows --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5621c54..5f99127 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ docs = [ "sphinx==7.4.7", "dask", "sphinx_rtd_theme==2.0.0", - "matplotlib==3.9.1", + "matplotlib==3.9.2", "sphinx-gallery==0.17.0" ] From 0019742c913389539b7c6ed53ab25a4bb9d53236 Mon Sep 17 00:00:00 2001 From: JonasViehweger Date: Thu, 12 Feb 2026 10:43:38 +0100 Subject: [PATCH 2/2] IQR sensitivity tuple example --- nrt/monitor/iqr.py | 16 +++++++++++----- tests/integration_tests/test_monitor.py | 5 +++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/nrt/monitor/iqr.py b/nrt/monitor/iqr.py index 8036f20..3a311d4 100644 --- a/nrt/monitor/iqr.py +++ b/nrt/monitor/iqr.py @@ -56,8 +56,10 @@ class IQR(BaseNrt): trend (bool): Indicate whether stable period fit is performed with trend or not harmonic_order (int): The harmonic order of the time-series regression - sensitivity (float): sensitivity of the monitoring. Lower numbers are - high sensitivity. Value can't be zero. + sensitivity (float, float) | (float): sensitivity of the monitoring. Lower numbers are + high sensitivity. Value can't be zero. Sensitivity for deviations of the residuals + in the negative and positive direction can be passed as a tuple (lower, upper). + If a single value is passed, the same sensitivity will be used for upper and lower deviations boundary (int): Number of consecutive observations identified as outliers to signal as disturbance **kwargs: Used to set internal attributes when initializing with @@ -70,7 +72,11 @@ def __init__(self, trend=True, harmonic_order=3, sensitivity=1.5, mask=None, harmonic_order=harmonic_order, boundary=boundary, **kwargs) - self.sensitivity = sensitivity + self.sensitivity = ( + sensitivity + if isinstance(sensitivity, tuple) + else (sensitivity, sensitivity) + ) self.q25 = kwargs.get('q25') self.q75 = kwargs.get('q75') self.monitoring_strategy = 'IQR' @@ -89,8 +95,8 @@ def fit(self, dataarray, method='OLS', **kwargs): def _update_process(self, residuals, is_valid): # Compute upper and lower thresholds iqr = self.q75 - self.q25 - lower_limit = self.q25 - self.sensitivity * iqr - upper_limit = self.q75 + self.sensitivity * iqr + lower_limit = self.q25 - self.sensitivity[0] * iqr + upper_limit = self.q75 + self.sensitivity[1] * iqr # compare residuals to thresholds is_outlier = np.logical_or(residuals > upper_limit, residuals < lower_limit) diff --git a/tests/integration_tests/test_monitor.py b/tests/integration_tests/test_monitor.py index 890c01f..0435c00 100644 --- a/tests/integration_tests/test_monitor.py +++ b/tests/integration_tests/test_monitor.py @@ -24,6 +24,11 @@ marks=pytest.mark.ewma), 'IQR': pytest.param(iqr.IQR, {'trend': False, 'harmonic_order': 1}, 3, marks=pytest.mark.iqr), + 'IQR_sensitivity_tuple': pytest.param( + iqr.IQR, + {'trend': False, 'harmonic_order': 1, 'sensitivity': (1,3)}, 3, + marks=pytest.mark.iqr_sens + ), 'CUSUM': pytest.param(cusum.CuSum, {}, 6, marks=pytest.mark.cusum), 'MOSUM': pytest.param(mosum.MoSum, {}, 6,