{"record":{"id":"42b05858de686666","repo":"ruvnet/RuView","slug":"smoothing-window-must-be-positive","errorCode":null,"errorMessage":"smoothing_window must be positive","messagePattern":"smoothing_window must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/core/phase_sanitizer.py","lineNumber":75,"sourceCode":"            ValueError: If configuration is invalid\n        \"\"\"\n        required_fields = ['unwrapping_method', 'outlier_threshold', 'smoothing_window']\n        missing_fields = [field for field in required_fields if field not in config]\n        \n        if missing_fields:\n            raise ValueError(f\"Missing required configuration: {missing_fields}\")\n        \n        # Validate unwrapping method\n        valid_methods = ['numpy', 'scipy', 'custom']\n        if config['unwrapping_method'] not in valid_methods:\n            raise ValueError(f\"Invalid unwrapping method: {config['unwrapping_method']}. Must be one of {valid_methods}\")\n        \n        # Validate thresholds\n        if config['outlier_threshold'] <= 0:\n            raise ValueError(\"outlier_threshold must be positive\")\n        \n        if config['smoothing_window'] <= 0:\n            raise ValueError(\"smoothing_window must be positive\")\n    \n    def unwrap_phase(self, phase_data: np.ndarray) -> np.ndarray:\n        \"\"\"Unwrap phase data to remove discontinuities.\n        \n        Args:\n            phase_data: Wrapped phase data (2D array)\n            \n        Returns:\n            Unwrapped phase data\n            \n        Raises:\n            PhaseSanitizationError: If unwrapping fails\n        \"\"\"\n        try:\n            if self.unwrapping_method == 'numpy':\n                return self._unwrap_numpy(phase_data)\n            elif self.unwrapping_method == 'scipy':\n                return self._unwrap_scipy(phase_data)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/core/phase_sanitizer.py#L57-L93","documentation":"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.","triggerScenarios":"Constructing PhaseSanitizer with smoothing_window=0 or negative, e.g. PhaseSanitizer({'unwrapping_method': 'numpy', 'outlier_threshold': 3.0, 'smoothing_window': 0}).","commonSituations":"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.","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."],"exampleFix":"# before\nconfig = {'unwrapping_method': 'numpy', 'outlier_threshold': 3.0, 'smoothing_window': 0}\n\n# after\nconfig = {'unwrapping_method': 'numpy', 'outlier_threshold': 3.0,\n          'smoothing_window': 5, 'enable_smoothing': False}  # if disabling was the intent","handlingStrategy":"validation","validationCode":"window = int(config.get('smoothing_window', 0))\nif window < 1:\n    window = 5 if config.get('enable_smoothing', True) else 5  # keep valid; flag controls behavior\nconfig['smoothing_window'] = window","typeGuard":null,"tryCatchPattern":"try:\n    sanitizer = PhaseSanitizer(config)\nexcept ValueError as e:\n    if 'smoothing_window must be positive' in str(e):\n        config['smoothing_window'] = 5\n        sanitizer = PhaseSanitizer(config)\n    else:\n        raise","preventionTips":["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)."],"tags":["config","validation","phase-sanitizer","smoothing"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}