style(simulation): fmt + clippy fixes for the measurement batch (gate bounce)

cargo fmt across the four new files; needless_range_loop x2 (enumerate /
iter_mut) and identity_op in hydrology_equilibrium.rs. cargo test was green
on the bounced push — lint-only fixes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 19:25:08 +02:00
co-authored by Claude Fable 5
parent 473b654787
commit 976d4016e9
4 changed files with 129 additions and 71 deletions
+34 -15
View File
@@ -52,9 +52,15 @@ fn synthetic_elevation(width: u32, height: u32) -> Vec<f32> {
// priority-flood + overflow-search work is representative, not
// a degenerate monotonic slope.
let v = 0.5
+ 0.25 * (x * std::f64::consts::TAU * 3.0).sin() * (y * std::f64::consts::TAU * 2.0).cos()
+ 0.15 * (x * std::f64::consts::TAU * 7.3 + 1.7).sin() * (y * std::f64::consts::TAU * 5.1).sin()
+ 0.10 * (x * std::f64::consts::TAU * 13.0).cos() * (y * std::f64::consts::TAU * 11.0 + 0.4).sin();
+ 0.25
* (x * std::f64::consts::TAU * 3.0).sin()
* (y * std::f64::consts::TAU * 2.0).cos()
+ 0.15
* (x * std::f64::consts::TAU * 7.3 + 1.7).sin()
* (y * std::f64::consts::TAU * 5.1).sin()
+ 0.10
* (x * std::f64::consts::TAU * 13.0).cos()
* (y * std::f64::consts::TAU * 11.0 + 0.4).sin();
v.clamp(0.0, 1.0) as f32
})
.collect()
@@ -63,8 +69,7 @@ fn synthetic_elevation(width: u32, height: u32) -> Vec<f32> {
fn gj1c_512x256() -> (Vec<f32>, f32) {
let src = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../wiki/star-systems/GJ-1/bodies/GJ1c/heightmap.png");
let heightmap =
load_heightmap_png(&src, "GJ1c", 0.3).expect("decode committed GJ1c heightmap");
let heightmap = load_heightmap_png(&src, "GJ1c", 0.3).expect("decode committed GJ1c heightmap");
let small = heightmap.downsample(512, 256); // GRID_W x GRID_H, the real production working grid
(small.data, small.sea_level)
}
@@ -86,11 +91,7 @@ fn run_and_report(label: &str, width: u32, height: u32, elevation: &[f32], sea_l
let result_warm = solve(elevation, width, height, sea_level, default_climate());
let warm = t1.elapsed();
let lake_cells: usize = result_cold
.basins
.iter()
.map(|b| b.cells.len())
.sum();
let lake_cells: usize = result_cold.basins.iter().map(|b| b.cells.len()).sum();
let carved_cells = result_cold.cliff_edge.iter().filter(|&&c| c).count();
let endorheic_count = result_cold
.basins
@@ -141,7 +142,13 @@ fn run_and_report(label: &str, width: u32, height: u32, elevation: &[f32], sea_l
#[ignore]
fn bench_512x256_real_gj1c() {
let (elev, sea_level) = gj1c_512x256();
run_and_report("512x256 (real GJ1c, production working-grid size)", 512, 256, &elev, sea_level);
run_and_report(
"512x256 (real GJ1c, production working-grid size)",
512,
256,
&elev,
sea_level,
);
}
#[test]
@@ -183,13 +190,23 @@ fn determinism_at_330k_cells() {
let elev = synthetic_elevation(w, h);
let r1 = solve(&elev, w, h, 0.35, default_climate());
let r2 = solve(&elev, w, h, 0.35, default_climate());
assert_eq!(r1.filled_scaled, r2.filled_scaled, "filled surface must be byte-identical");
assert_eq!(
r1.filled_scaled, r2.filled_scaled,
"filled surface must be byte-identical"
);
assert_eq!(
r1.channel_depth_scaled, r2.channel_depth_scaled,
"carved channel depth must be byte-identical"
);
assert_eq!(r1.cliff_edge, r2.cliff_edge, "cliff-edge flags must be byte-identical");
assert_eq!(r1.basins.len(), r2.basins.len(), "basin count must be identical");
assert_eq!(
r1.cliff_edge, r2.cliff_edge,
"cliff-edge flags must be byte-identical"
);
assert_eq!(
r1.basins.len(),
r2.basins.len(),
"basin count must be identical"
);
for (a, b) in r1.basins.iter().zip(r2.basins.iter()) {
assert_eq!(a.basin_id, b.basin_id);
assert_eq!(a.cells, b.cells);
@@ -231,7 +248,9 @@ fn bench_parallel_273_bodies_at_512x256() {
println!(
"\n=== {body_count} bodies x 512x256, Rayon par_iter ({} threads available) ===",
std::thread::available_parallelism().map(|n| n.get()).unwrap_or(0)
std::thread::available_parallelism()
.map(|n| n.get())
.unwrap_or(0)
);
println!(
" {:>9.2} ms total, {:>7.2} ms/body average, {total_basins} basins summed",