Skip to content

test(rf3): clear utils.loss mypy module and add alignment unit tests#302

Open
lyskov-ai wants to merge 4 commits into
RosettaCommons:productionfrom
lyskov-ai:0016-rf3-mypy-loss-and-alignment-tests
Open

test(rf3): clear utils.loss mypy module and add alignment unit tests#302
lyskov-ai wants to merge 4 commits into
RosettaCommons:productionfrom
lyskov-ai:0016-rf3-mypy-loss-and-alignment-tests

Conversation

@lyskov-ai
Copy link
Copy Markdown
Contributor

Two small type-checking + test improvements for models/rf3:

  • Type-check rf3/utils/loss.py. convert_batched_losses_to_list_of_dicts builds per-batch dicts that mix an int batch index with float loss values (tensor.item() returns int | float), which mypy rejected because the dict's value type was inferred from the first (int) key. Annotated the containers and the return type as dict[str, int | float] and enabled mypy type-checking for the module (it was previously excluded). Annotation-only — no behavior change.

  • Unit tests for rf3/alignment.py. Added CPU unit tests for weighted_rigid_align (identity no-op, recovering a known rigid transform / pure translation, exclusion of points from the fit via the existence mask and via zero weights, detached output, rejection of a non-boolean mask) and get_rmsd (sqrt(eps) on identical inputs, constant-offset case). Small inline tensor fixtures — no data files, GPU, or checkpoints.

lyskov and others added 4 commits June 3, 2026 22:03
Fixture-backed CPU unit tests for the pure symmetry geometry in
rfd3.inference.symmetry: cyclic/dihedral frame generation, the
framecoord <-> (R, t) round-trip, pack/unpack, Kabsch _align/_rms
recovery, symmetry-id parsing, and contig-string expansion.

New tests/rfd3/ dir, auto-collected by testpaths and kept separate
from the cluster-only models/rfd3/tests/. No source or config changes.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>
Add models/rf3/src/rf3 to [tool.mypy].files and seed a fresh per-module
ignore_errors ratchet listing the 26 rf3 modules with pre-existing errors
(158 total), mirroring the rfd3 bootstrap. mypy now type-checks the 28
already-clean rf3 modules; the 26 are cleared slice-by-slice in follow-ups.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>
mypy: fix the 3 one-error rf3 modules (extra_xforms setattr,
metrics_logging set[str], predict_and_score assert-narrow on run()'s
dict|None return) and drop them from the ignore_errors ratchet (26 -> 23).
Annotation/type-honesty only, no behavior change.

tests: add tests/rf3/ first pass — 15 fixture-backed CPU unit tests
pinning utils/frames.py (rigid_from_3_points proper-rotation/origin/batch
/NA-branch, is_atom) and metrics/metric_utils.py (bin midpoints, unbin
expectation, chain/interface masks, subsampled mean/min).

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>
Clear rf3.utils.loss off the mypy ignore_errors ratchet: the per-batch dict
in convert_batched_losses_to_list_of_dicts mixes an int batch_idx with int|float
.item() loss values, so annotate the containers and return type as
dict[str, int | float] (annotation-only, no behavior change).

Add 9 fixture-backed CPU unit tests for rf3/alignment.py (weighted_rigid_align,
get_rmsd) in tests/rf3/test_rf3_alignment.py, mirroring the foundry suite and
adapted to rf3's required-4-arg signature.

Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>
@lyskov-ai lyskov-ai requested a review from woodsh17 June 3, 2026 23:15
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.

2 participants