Skip to content

Fix misleading unit comments in CAV/Arias/LRU code; drop unused GAL - #245

Merged
lispandfound merged 1 commit into
masterfrom
ai/issue-232
Sep 30, 2026
Merged

lispandfound merged 1 commit into
masterfrom
ai/issue-232

Conversation

@ucgmsim

@ucgmsim ucgmsim Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

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

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>
@ucgmsim ucgmsim Bot added ai-generated Opened by the scheduled Claude jobs ai-fix Bot-written fix that needs review labels Sep 30, 2026
@ucgmsim
ucgmsim Bot requested a review from lispandfound September 30, 2026 13:27
@lispandfound
lispandfound merged commit 351c623 into master Sep 30, 2026
7 checks passed
@lispandfound
lispandfound deleted the ai/issue-232 branch September 30, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-fix Bot-written fix that needs review ai-generated Opened by the scheduled Claude jobs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix misleading unit comments in the CAV/Arias Rust code, remove unused GAL, correct the LRU comment

1 participant