Fix L1 distance to use Manhattan sum - #1998
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe ChangesMetric distance behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change corrects L1 distance to use the documented Manhattan sum and adds regression coverage. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The focused regression change is ready for maintainer review. The test suite coverage and formatting checks are complete. |
|
sum fix looks right but it's a breaking change for existing l1 users — distances will scale with dim now. Consider adding a deprecation warning or changelog note |
|
Hi @SahilKumar75 Thanks for the pull request! Please so our guidelines for the usual contribution process: https://sbi.readthedocs.io/en/latest/contributing.html The usual workflow would be first creating an issue stating the problem and discussing a solution. Can you please provide more details (as intended in our Pull Request Template): What's the problem here? what is this PR implementing and why? Thanks |
What does this PR do?
Changes
l1()from the mean of absolute differences to their sum, implementing the standard Manhattan distance.Updates the docstring and adds a regression test showing that a single differing coordinate contributes a distance of 1, including when additional identical coordinates are present.
Does this close any issues?
No linked issue.
Anything else we should know?
The existing docstring explicitly describes averaging. This change therefore alters existing behavior: for an axis of length n, the new distance is n times the previous distance. The intended convention and compatibility approach need discussion before merging.
Previously reported validation:
ruff check sbi/utils/metrics.py tests/metrics_test.pyruff format --check sbi/utils/metrics.py tests/metrics_test.pypytest_harvestandnflowswere unavailable.No tests were rerun for this description update. The broader checks below remain unverified.
Checklist
uv run pytest -n auto -m "not slow and not gpu"passes.uv run pre-commit run --all-filespasses (ruff and formatting).uv run pyright sbipasses.pytest.mark.slow.