Emit floats an f32 can hold, and drop the format! that formats nothing
CI runs cargo fmt --check and clippy -D warnings, and this branch had never been through either. Both would have failed it. The bulk was the generated colour tables: eight significant figures where an f32 carries about 7.2, so the eighth is noise that rounds away at compile time and clippy's excessive_precision says so 109 times over. Fixed in the generator rather than only in the file, so it stays fixed -- and the file is trimmed in place rather than re-derived, because regenerating it needs a colour-science stack that has nothing to do with the defect. The format! in the composer is mine too, from extracting the rendering tail: the braces in it were escaped because the text used to live inside a larger template, and once extracted the escapes are noise and the call formats nothing. Also here, and clearly not mine: an unused import and a shadowed binding in dr-gpu, and an unused import in a test. They are pre-existing -- clippy has been failing on master before this branch existed, on lints like is_multiple_of that arrived with a toolchain rather than with anyone's code. Fixed because CI cannot go green around them, and called out because a merge commit is a bad place to quietly edit someone else's crate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ pub type Spectrum = [f32; SPECTRUM];
|
||||
/// happens before this is applied — see [`Viewing::to_srgb`].
|
||||
const XYZ_TO_SRGB: [[f32; 3]; 3] = [
|
||||
[3.2404542, -1.5371385, -0.4985314],
|
||||
[-0.9692660, 1.8760108, 0.0415560],
|
||||
[-0.969266, 1.8760108, 0.041556],
|
||||
[0.0556434, -0.2040259, 1.0572252],
|
||||
];
|
||||
|
||||
@@ -81,8 +81,8 @@ pub fn blackbody(kelvin: f32) -> Spectrum {
|
||||
let mut out = [0.0f32; SPECTRUM];
|
||||
let mut total = 0.0f64;
|
||||
for (i, slot) in out.iter_mut().enumerate() {
|
||||
let lambda = f64::from(crate::tables::LAMBDA_MIN + crate::tables::LAMBDA_STEP * i as f32)
|
||||
* 1e-9;
|
||||
let lambda =
|
||||
f64::from(crate::tables::LAMBDA_MIN + crate::tables::LAMBDA_STEP * i as f32) * 1e-9;
|
||||
let radiance = (2.0 * H * C * C)
|
||||
/ (lambda.powi(5) * ((H * C / (lambda * KB * f64::from(kelvin))).exp() - 1.0));
|
||||
*slot = radiance as f32;
|
||||
@@ -208,7 +208,10 @@ mod tests {
|
||||
for r in 0..3 {
|
||||
for c in 0..3 {
|
||||
let expected = if r == c { 1.0 } else { 0.0 };
|
||||
assert!((m[r][c] - expected).abs() < 1e-5, "{m:?} is not the identity");
|
||||
assert!(
|
||||
(m[r][c] - expected).abs() < 1e-5,
|
||||
"{m:?} is not the identity"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user