{"record":{"id":"488d46f7a3634d53","repo":"RyanCodrai/turbovec","slug":"invalid-tq-scale-at-coord-i-v-must-be-finit","errorCode":null,"errorMessage":"invalid TQ+ scale at coord {i}: {v} (must be finite and >= {:e} at dim {}; search divides by it and sums across every coordinate, so a smaller value turns every score into Inf/NaN)","messagePattern":"invalid TQ\\+ scale at coord (.+?): (.+?) \\(must be finite and >= (.+?) at dim (.+?); search divides by it and sums across every coordinate, so a smaller value turns every score into Inf/NaN\\)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"turbovec/src/io.rs","lineNumber":595,"sourceCode":"        .enumerate()\n        .find(|(_, v)| !v.is_finite() || v.abs() > max_tqplus_shift(tqplus_shift.len()))\n    {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"invalid TQ+ shift at coord {i}: {v} (must be finite and \\\n                 |shift| <= {:e} at dim {})\",\n                max_tqplus_shift(tqplus_shift.len()),\n                tqplus_shift.len()\n            ),\n        ));\n    }\n    if let Some((i, &v)) = tqplus_scale\n        .iter()\n        .enumerate()\n        .find(|(_, v)| !v.is_finite() || **v < min_tqplus_scale(tqplus_scale.len()))\n    {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"invalid TQ+ scale at coord {i}: {v} (must be finite and \\\n                 >= {:e} at dim {}; search divides by it and sums across \\\n                 every coordinate, so a smaller value turns every score \\\n                 into Inf/NaN)\",\n                min_tqplus_scale(tqplus_scale.len()),\n                tqplus_scale.len()\n            ),\n        ));\n    }\n    Ok(())\n}\n\n\n\n\n","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec/src/io.rs#L577-L613","documentation":"validate_calibration rejects TQ+ scale vectors that are non-finite or below min_tqplus_scale(dim). Because search divides by the scale and sums across every coordinate, too-small (or zero/negative) values turn every score into Inf/NaN, so the library refuses the calibration up front. The message names the offending coordinate, value, minimum, and dimension.","triggerScenarios":"Loading/saving a calibration whose tqplus_scale slice contains NaN, Inf, or a value < min_tqplus_scale(len), typically via calibrate or v7 file load.","commonSituations":"Zero-initialized scale arrays left untrained; numerical underflow in calibration fitting; importing calibrations from external tools without sanity checks.","solutions":["Set every scale coordinate to at least min_tqplus_scale(dim) (e.g. clamp or floor it)","Recompute the calibration if scales underflowed to zero","Reject/repair zero- or NaN-filled scales before persisting","Verify the calibration training converges before exporting"],"exampleFix":"// before\ncal.tqplus_scale = fitted_scales; // some entries 0.0\n// after\nlet floor = min_tqplus_scale(fitted_scales.len());\ncal.tqplus_scale = fitted_scales.iter().map(|&v| v.max(floor)).collect();","handlingStrategy":"validation","validationCode":"let floor = turbovec::min_tqplus_scale(scale.len());\nassert!(scale.iter().all(|&v| v.is_finite() && v >= floor),\n        \"TQ+ scale below {floor:e}\");","typeGuard":"fn scale_valid(s: &[f64]) -> bool {\n    let floor = turbovec::min_tqplus_scale(s.len());\n    s.iter().all(|&v| v.is_finite() && v >= floor)\n}","tryCatchPattern":"match validate_calibration(&cal) {\n    Err(e) if e.to_string().contains(\"invalid TQ+ scale\") => {\n        eprintln!(\"calibration rejected: {e}; flooring scales\");\n        let floor = turbovec::min_tqplus_scale(cal.tqplus_scale.len());\n        for v in &mut cal.tqplus_scale { *v = v.max(floor); }\n    }\n    other => other?,\n}","preventionTips":["Floor scales at min_tqplus_scale(dim) after training","Detect all-zero/untrained scale arrays before persisting","Test calibration round-trips (save/load) with range assertions"],"tags":["validation","calibration","numeric-range"],"backgroundTag":"value-out-of-range","analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}