ruvnet/RuView · error · ValueError
smoothing_window must be positive
Error message
smoothing_window must be positive
What it means
Raised by PhaseSanitizer._validate_config when smoothing_window is present but <= 0. The window is the length (in samples) of the smoothing filter applied to phase; zero or negative lengths are rejected because convolution with such kernels is undefined. Validation happens in __init__, before any data is touched.
Source
Thrown at archive/v1/src/core/phase_sanitizer.py:75
ValueError: If configuration is invalid
"""
required_fields = ['unwrapping_method', 'outlier_threshold', 'smoothing_window']
missing_fields = [field for field in required_fields if field not in config]
if missing_fields:
raise ValueError(f"Missing required configuration: {missing_fields}")
# Validate unwrapping method
valid_methods = ['numpy', 'scipy', 'custom']
if config['unwrapping_method'] not in valid_methods:
raise ValueError(f"Invalid unwrapping method: {config['unwrapping_method']}. Must be one of {valid_methods}")
# Validate thresholds
if config['outlier_threshold'] <= 0:
raise ValueError("outlier_threshold must be positive")
if config['smoothing_window'] <= 0:
raise ValueError("smoothing_window must be positive")
def unwrap_phase(self, phase_data: np.ndarray) -> np.ndarray:
"""Unwrap phase data to remove discontinuities.
Args:
phase_data: Wrapped phase data (2D array)
Returns:
Unwrapped phase data
Raises:
PhaseSanitizationError: If unwrapping fails
"""
try:
if self.unwrapping_method == 'numpy':
return self._unwrap_numpy(phase_data)
elif self.unwrapping_method == 'scipy':
return self._unwrap_scipy(phase_data)View on GitHub (pinned to 4685618388)
Solutions
- Set smoothing_window to a positive odd integer such as 5 or 7 (odd lengths avoid phase shift in symmetric filters).
- To disable smoothing, set enable_smoothing=False and keep a positive window value.
- Guard computed windows: `smoothing_window = max(1, computed)` or skip sanitization until enough samples exist.
- Verify the units: it is a sample count, not seconds.
Example fix
# before
config = {'unwrapping_method': 'numpy', 'outlier_threshold': 3.0, 'smoothing_window': 0}
# after
config = {'unwrapping_method': 'numpy', 'outlier_threshold': 3.0,
'smoothing_window': 5, 'enable_smoothing': False} # if disabling was the intent Defensive patterns
Strategy: validation
Validate before calling
window = int(config.get('smoothing_window', 0))
if window < 1:
window = 5 if config.get('enable_smoothing', True) else 5 # keep valid; flag controls behavior
config['smoothing_window'] = window Try / catch
try:
sanitizer = PhaseSanitizer(config)
except ValueError as e:
if 'smoothing_window must be positive' in str(e):
config['smoothing_window'] = 5
sanitizer = PhaseSanitizer(config)
else:
raise Prevention
- Use enable_smoothing=False to disable smoothing; the window value must stay >= 1.
- Prefer odd window lengths (5, 7) for symmetric filters.
- Guard computed windows with max(1, computed_value).
When it happens
Trigger: Constructing PhaseSanitizer with smoothing_window=0 or negative, e.g. PhaseSanitizer({'unwrapping_method': 'numpy', 'outlier_threshold': 3.0, 'smoothing_window': 0}).
Common situations: 0 placeholder never replaced; window derived as `int(duration * rate)` with a zero factor; disabling intent (use enable_smoothing=False instead); config sweeps that include 0; window computed from buffer length on cold start when the buffer is empty.
Related errors
- Missing required configuration: {missing_fields}
- Invalid unwrapping method: {config['unwrapping_method']}. Mu
- outlier_threshold must be positive
- Threshold must be between 0.0 and 1.0
- FPS must be between 1 and 60
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/42b05858de686666.
Report an issue: GitHub.