ruvnet/RuView · error · ValueError
sampling_rate must be positive
Error message
sampling_rate must be positive
What it means
Raised by CSIProcessor._validate_config during __init__ when the config dict contains sampling_rate but its value is <= 0. The processor divides time axes and FFT frequencies by sampling_rate, so a zero or negative rate would corrupt every downstream computation, hence the fail-fast check.
Source
Thrown at archive/v1/src/core/csi_processor.py:111
self._human_detections = 0
def _validate_config(self, config: Dict[str, Any]) -> None:
"""Validate configuration parameters.
Args:
config: Configuration to validate
Raises:
ValueError: If configuration is invalid
"""
required_fields = ['sampling_rate', 'window_size', 'overlap', 'noise_threshold']
missing_fields = [field for field in required_fields if field not in config]
if missing_fields:
raise ValueError(f"Missing required configuration: {missing_fields}")
if config['sampling_rate'] <= 0:
raise ValueError("sampling_rate must be positive")
if config['window_size'] <= 0:
raise ValueError("window_size must be positive")
if not 0 <= config['overlap'] < 1:
raise ValueError("overlap must be between 0 and 1")
def preprocess_csi_data(self, csi_data: CSIData) -> CSIData:
"""Preprocess CSI data for feature extraction.
Args:
csi_data: Raw CSI data
Returns:
Preprocessed CSI data
Raises:
CSIProcessingError: If preprocessing failsView on GitHub (pinned to 4685618388)
Solutions
- Set sampling_rate to the true CSI sample rate in Hz (e.g. 100 for 100 packets/sec capture, or your hardware's rate such as 1000 for high-rate ESP32 captures).
- If the rate is computed, guard it before construction: `rate = max(rate, 1)` or assert it derives from a positive duration.
- Log the resolved config right before constructing CSIProcessor to catch defaults leaking in as 0.
- For hardware-driven rates, ensure the extractor reports a positive measured rate before instantiating the processor.
Example fix
# before
config = {'sampling_rate': 0, 'window_size': 64, 'overlap': 0.5, 'noise_threshold': 0.1}
processor = CSIProcessor(config) # ValueError
# after
config = {'sampling_rate': 100, 'window_size': 64, 'overlap': 0.5, 'noise_threshold': 0.1}
processor = CSIProcessor(config) Defensive patterns
Strategy: validation
Validate before calling
def is_valid_csi_config(config: dict) -> bool:
return (
{'sampling_rate', 'window_size', 'overlap', 'noise_threshold'} <= config.keys()
and config['sampling_rate'] > 0
) Try / catch
try:
processor = CSIProcessor(config)
except ValueError as e:
if 'sampling_rate must be positive' in str(e):
config['sampling_rate'] = measured_rate # from hardware/extractor
processor = CSIProcessor(config)
else:
raise Prevention
- Derive sampling_rate from the capture device settings, never hardcode a placeholder 0.
- Assert measured_rate > 0 in the extractor before handing config to the processor.
- Unit-test the config builder so 0 rates cannot be emitted.
When it happens
Trigger: Constructing CSIProcessor with sampling_rate=0, a negative number, or a value that coerces to <= 0 (e.g. 0.0, -100). Typical call: CSIProcessor({'sampling_rate': 0, 'window_size': 64, 'overlap': 0.5, 'noise_threshold': 0.1}).
Common situations: Placeholder 0 in a config template never replaced; computing rate as `n_samples / duration` when duration is misparsed; ESP32 firmware subcarrier rate config injected as 0 before hardware init; YAML that parses an empty value into 0; unit tests probing boundary values.
Related errors
- window_size must be positive
- Missing required configuration: {missing_fields}
- overlap must be between 0 and 1
- 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/e30ee527b13afe35.
Report an issue: GitHub.