test(rf3): clear utils.loss mypy module and add alignment unit tests#302
Open
lyskov-ai wants to merge 4 commits into
Open
test(rf3): clear utils.loss mypy module and add alignment unit tests#302lyskov-ai wants to merge 4 commits into
lyskov-ai wants to merge 4 commits into
Conversation
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>
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.
Two small type-checking + test improvements for
models/rf3:Type-check
rf3/utils/loss.py.convert_batched_losses_to_list_of_dictsbuilds per-batch dicts that mix anintbatch index with float loss values (tensor.item()returnsint | float), whichmypyrejected because the dict's value type was inferred from the first (int) key. Annotated the containers and the return type asdict[str, int | float]and enabledmypytype-checking for the module (it was previously excluded). Annotation-only — no behavior change.Unit tests for
rf3/alignment.py. Added CPU unit tests forweighted_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) andget_rmsd(sqrt(eps) on identical inputs, constant-offset case). Small inline tensor fixtures — no data files, GPU, or checkpoints.