Analysis histogram bin index clips after the i32 cast, not before (compute-one crashes on extreme rollout values) #61
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
_bin_expringiant/analysis/reduce.pyclips the bin index to[0, nbins-1]only after casting it toInt32, so the clip never gets a chance to run: a rolloutstep_lengthof1.0725e10mm against fixed edges[2.9e-5, 94.04]with 50 bins produces a raw index of ~5.7e9, which overflows i32 and fails the strict cast — killing the wholecompute-onejob. Same failure mode for+/-inf.Fix: clamp in f64 first, then cast to Int32. NaN has no edge to clamp to, so map it to null and drop it in the two callers (
hist1d,profile_partial) — matching whatnp.histogramdoes with NaN, and whatprofile_partialneeds anyway since a null bin index would break itsnp.add.at.This was already fixed once in commit
313373c("Clamp analysis histogram bins before the i32 cast, not after"), but that commit landed on a branch (fix/rollout-negative-secondary-mass) that forked off a stale master and was never merged —giant/analysis/reduce.pyhas since diverged enough that it doesn't apply cleanly. Needs to be reimplemented against currentmaster. The original commit's diff (including its two new regression tests intests/test_analysis_reduce.py) is a good reference:git show 313373cc10d77d9c452c0b13fd62f8770a963590.Fixed in
a746efbon fix/issue-61._bin_expr now clamps in f64 before the Int32 cast, and NaN maps to null instead (dropped in hist1d/profile_partial via drop_nulls) rather than crashing the cast. This reimplements
313373c, whose fix and two regression tests (test_hist1d_clamps_extreme_values_and_drops_nan, test_profile_partial_clamps_extreme_values_and_drops_nan) never made it to master since that commit's branch (fix/rollout-negative-secondary-mass) was never merged and reduce.py has since diverged. Both tests were confirmed to fail on unpatched master (cast-overflow exception) and pass after the fix. Full check suite (pytest, ruff format/check, ty) all clean. No follow-up filed.