Skip to content

Trim three long comment blocks moved to notes/code_history/ - #58

Merged
davidhbernstein merged 1 commit into
mainfrom
docs/trim-code-comments
Oct 6, 2026
Merged

davidhbernstein merged 1 commit into
mainfrom
docs/trim-code-comments

Conversation

@davidhbernstein

Copy link
Copy Markdown
Owner

What this is

A comments-only change restoring the 2026-08-24 convention in three places
where I broke it: R/ reads as code, with one or two lines above each block
saying what it does, and the long explanation lives in
notes/code_history/<file>.md (outside the package, so it reaches neither the
CRAN tarball nor this repo).

file before after
R/data.processing.R 24 lines (two sweep tables) 3
R/sfm.R 10 lines 2
R/sfareg_methods.R 6 lines 2

Net 28 fewer comment lines.

Why it is safe

Comments only. Stripping ## lines from all three files leaves them
byte-identical to main (verified by md5 of the stripped files). The full
suite is FAIL 0 | WARN 43 | SKIP 8 | PASS 5417 -- the same counts as main.

No NEWS.md entry: nothing a user can observe changed.

The prose was written first

A short comment pointing at a file that does not discuss the topic is worse
than a long comment, so each note section went in before the corresponding
trim:

  • data.processing.md gains a DOMAIN_PENALTY_PER_OBS section carrying both
    sweeps -- the five-tHN sweep over penalty magnitude, and the sweep across
    n that is the reason the penalty is per observation rather than a fixed
    total (a fixed total keeps its margin only while n is small).
  • sfareg_methods.md gains a bhhh-recommendation section. It had no entry
    for this; trimming the source first would have left a dangling pointer.
  • sfm.md's A56a section said DOMAIN_PENALTY = 1e6. That is stale twice
    over -- wrong name and wrong value -- and is corrected to
    DOMAIN_PENALTY_PER_OBS = 1e4.

All three pointers were then checked to resolve to files that mention their
topic.

One real defect fixed in passing

R/sfm.R's block ended by referring the reader to
.SFA_CONSTANTS$DOMAIN_PENALTY "for the sweep behind this value". That name
stopped existing when A56a renamed it to DOMAIN_PENALTY_PER_OBS, so the
comment two lines above the correct name sent the reader to a constant that is
not defined anywhere. Removed.

Scope

Deliberately limited to blocks I wrote after the convention was adopted. The
long file headers that predate it -- mundlak.R (37 lines),
lcsfm_homogeneity.R (36), matrix_utils.R (34/28/26/26) -- are a larger and
more opinionated change, and are left alone.

🤖 Generated with Claude Code

The 2026-08-24 convention is that R/ reads as code, with one or two lines
above each block saying what it does, and the long explanation living in
notes/code_history/<file>.md. Three blocks I added since then did not
follow it: the DOMAIN_PENALTY_PER_OBS sweep tables (24 lines), the tHN
domain-guard rationale (10), and the vcov() bhhh reasoning (6).

Comments only -- stripping ## lines leaves all three files byte-identical
to main, and the suite is unchanged (FAIL 0 | PASS 5417, same counts as
main). The prose was written into notes/code_history/ FIRST, so no
pointer here lands on a file that does not discuss its topic:

- data.processing.md gains the DOMAIN_PENALTY_PER_OBS section (both
  sweeps, and why the penalty is per observation rather than a total).
- sfareg_methods.md gains the bhhh-recommendation section; it had no
  entry for this at all.
- sfm.md's A56a section had a stale DOMAIN_PENALTY = 1e6 line, corrected
  to DOMAIN_PENALTY_PER_OBS = 1e4.

R/sfm.R's block also pointed at .SFA_CONSTANTS$DOMAIN_PENALTY, a name
that stopped existing when A56a renamed it; that pointer is gone.

Scoped to blocks I wrote. The long file headers in mundlak.R,
lcsfm_homogeneity.R and matrix_utils.R predate the convention and are a
larger, more opinionated change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidhbernstein
davidhbernstein enabled auto-merge (squash) October 6, 2026 13:24
@davidhbernstein
davidhbernstein merged commit 0cb58cf into main Oct 6, 2026
5 checks passed
@davidhbernstein
davidhbernstein deleted the docs/trim-code-comments branch October 6, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant