From c26cf2943de7f261951e891bc6325d82f79ef865 Mon Sep 17 00:00:00 2001 From: Sam Scholten Date: Thu, 30 Oct 2025 11:28:58 +1000 Subject: fix: remove warning when no data in view during zooming - Remove RuntimeWarning that appeared during normal zoom operations - This warning occurred when zooming into very small ranges where no data points were visible - The behavior is now silent, returning empty arrays without warning as this is expected during zooming - Simplified code logic by removing early return for empty mask and checking array length after filtering - Bump version to 1.0.3 --- src/scopekit/decimation.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/scopekit/decimation.py b/src/scopekit/decimation.py index 107054d..a8add3b 100644 --- a/src/scopekit/decimation.py +++ b/src/scopekit/decimation.py @@ -555,10 +555,11 @@ class DecimationManager: # Find indices for current view in raw time mask = (t_raw_full >= xlim_raw[0]) & (t_raw_full <= xlim_raw[1]) - if not np.any(mask): - warnings.warn( - f"No data in view for xlim_raw: {xlim_raw}. Returning empty arrays.", RuntimeWarning - ) + t_view = t_raw_full[mask] + x_view = x_raw_full[mask] + + # If no data in view, return empty arrays (normal during zooming) + if len(t_view) == 0: empty_result = ( np.array([], dtype=np.float32), np.array([], dtype=np.float32), @@ -570,9 +571,6 @@ class DecimationManager: self._cache[cache_key] = empty_result return empty_result - t_view = t_raw_full[mask] - x_view = x_raw_full[mask] - # Add warning for large number of points in detail mode if not use_envelope and len(t_view) > self.DETAIL_MODE_POINT_WARNING_THRESHOLD: warnings.warn( -- cgit v1.2.3