Repository navigation
Fix misleading unit comments in CAV/Arias/LRU code; drop unused GAL - #245
Merged
Merged
Conversation
Closes #232 ## What was wrong - `src-rust/arias_intensity.rs`: the module doc and the `ARIAS_CONSTANT` doc comment gave the formula as $\frac{\pi}{2g}$, but `ARIAS_CONSTANT = G * PI / 2.0`, i.e. $\frac{\pi g}{2}$. The code is correct — it expects acceleration in units of $g$ — but the comments described the formula for acceleration in physical units, which is off by a factor of $g^2$. The `test_arias_physical_constant` comment likewise claimed the input was "1.0 cm/s^2" with an expected result of `PI / (2.0 * 981.0)`, when the input is actually 1 g and the expected result is `9.81 * PI / 2.0`. - `src-rust/cav.rs`: the module doc omitted the `G` factor the code applies, and the `test_cav_constant` comment claimed the input was "1.0 cm/s^2" with a result of "G (9.81 cm/s)", when the input is 1 g and the result is in m/s. - `src-rust/constants.rs`: `GAL` was dead code — never referenced anywhere in the Rust crate. Removed it rather than wiring up a shared definition with Python's separate `G = 981` in `IM/ims.py`, since the two live in different languages with no existing constant-sharing mechanism, and removing unused code is the smaller, lower-risk fix. - `IM/konno_ohmachi.py`: the comment above the cache pop-and-reinsert said it "shifts the key to the front of the insertion order," but `dict.pop` + re-assignment actually moves the key to the *end* (most recently inserted position). The eviction loop a few lines down does walk from the front (oldest first), so the cache logic itself is correct — only the comment had the direction backwards. No numerical or behavioral change; comments and one unused constant only. ## How the new test shows it `test_arias_physical_constant` previously asserted the result against `ARIAS_CONSTANT` itself, which is circular: it would pass regardless of whether the constant matched the documented formula. Changed the assertion to compare against the literal `9.81 * PI / 2.0` from the corrected comment. If `ARIAS_CONSTANT` were changed to match the old, wrong comment's formula (`PI / (2.0 * 981.0)` ≈ 0.0016 vs. the correct ≈ 15.41), this test would now fail, whereas it previously would not have caught that. ## What to check closely - The corrected formulas/comments in `arias_intensity.rs` and `cav.rs` match the actual runtime behavior of `arias_intensity`/`cav` (inputs in units of $g$). - Confirm `GAL` truly has no other consumers (checked via grep across the Rust sources; only `constants.rs` defined it). _Cost $0.43, 27 turns._ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
lispandfound
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #232
What was wrong
src-rust/arias_intensity.rs: the module doc and theARIAS_CONSTANTdoc comment gave the formula as
ARIAS_CONSTANT = G * PI / 2.0, i.e.acceleration in units of
acceleration in physical units, which is off by a factor of
test_arias_physical_constantcomment likewise claimed the input was"1.0 cm/s^2" with an expected result of
PI / (2.0 * 981.0), when theinput is actually 1 g and the expected result is
9.81 * PI / 2.0.src-rust/cav.rs: the module doc omitted theGfactor the code applies,and the
test_cav_constantcomment claimed the input was "1.0 cm/s^2"with a result of "G (9.81 cm/s)", when the input is 1 g and the result is
in m/s.
src-rust/constants.rs:GALwas dead code — never referenced anywherein the Rust crate. Removed it rather than wiring up a shared definition
with Python's separate
G = 981inIM/ims.py, since the two live indifferent languages with no existing constant-sharing mechanism, and
removing unused code is the smaller, lower-risk fix.
IM/konno_ohmachi.py: the comment above the cache pop-and-reinsert saidit "shifts the key to the front of the insertion order," but
dict.pop+ re-assignment actually moves the key to the end (mostrecently inserted position). The eviction loop a few lines down does walk
from the front (oldest first), so the cache logic itself is correct — only
the comment had the direction backwards.
No numerical or behavioral change; comments and one unused constant only.
How the new test shows it
test_arias_physical_constantpreviously asserted the result againstARIAS_CONSTANTitself, which is circular: it would pass regardless ofwhether the constant matched the documented formula. Changed the assertion
to compare against the literal
9.81 * PI / 2.0from the correctedcomment. If
ARIAS_CONSTANTwere changed to match the old, wrong comment'sformula (
PI / (2.0 * 981.0)≈ 0.0016 vs. the correct ≈ 15.41), this testwould now fail, whereas it previously would not have caught that.
What to check closely
arias_intensity.rsandcav.rsmatch the actual runtime behavior of
arias_intensity/cav(inputs inunits of
GALtruly has no other consumers (checked via grep across theRust sources; only
constants.rsdefined it).Cost $0.43, 27 turns.
🤖 Generated with Claude Code