Add custom operators .allclose. and .isclose. for test comparisons #647
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 335 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.348
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #647"
general
weight: 0.35
joewallwork
Hi! 👋
I'm working on issue #606 which asked for custom operators to make test comparisons cleaner and more readable.
What this PR does
I've added two new Fortran operators that make it easier to compare values and arrays in tests. Instead of writing verbose function calls, you can now use a more natural operator syntax.
Before:
After:
Much cleaner. This is especially nice when you're writing quick checks or assertions where you don't need custom test names or tolerances.
What's included
I added support for:
.isclose.- for comparing single values (both real32 and real64).allclose.- for comparing arrays (1D, 2D, and 3D arrays, both precisions)The operators use a sensible default tolerance (1e-5) and don't print output, making them perfect for inline conditionals. The original
allclose()andisclose()functions are still there and unchanged - this just adds a more convenient alternative.Implementation details
ftorch_test_utils(2 for isclose, 6 for allclose covering different array dimensions).fypptemplate and regenerated the.f90fileftorchmoduleTesting
I wrote comprehensive tests that cover:
All tests check that the operators work correctly and return the expected true/false values.
Backward compatibility
This is purely additive - no existing code needs to change. The original
allclose()andisclose()functions work exactly as before. Users can choose which style they prefer, or mix and match depending on what's clearer in each situation.AI Disclosure
Developed with assistance from Claude (Anthropic AI). All code has been reviewed and verified for correctness.
Files changed
src/ftorch_test_utils.fypp- added operator interfaces and implementationssrc/ftorch_test_utils.f90- regenerated from fyppsrc/ftorch.f90- exported the operatorstest/unit/test_utils/- new directory with test suitetest/unit/CMakeLists.txt- hooked up the new testsCHANGELOG.md- documented the featureLet me know if you'd like me to change anything or if you have questions about the implementation!
Closes #606