-
Notifications
You must be signed in to change notification settings - Fork 17
Add sparse matrix and edge case test coverage for random landmarking with precomputed matrices #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sparse matrix and edge case test coverage for random landmarking with precomputed matrices #89
Conversation
…prove comment clarity Co-authored-by: MattScicluna <19255250+MattScicluna@users.noreply.github.com>
Pull Request Test Coverage Report for Build 20349013595Details
💛 - Coveralls |
MattScicluna
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm. But not sure why coveralls failing.
eb30e4a
into
random_landmarking_precomp_aff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive test coverage for sparse matrices and edge cases in random landmarking with precomputed matrices. The changes address review feedback from PR #88 by ensuring that sparse precomputed affinity/distance matrices and zero-affinity edge cases are properly tested.
Key Changes:
- Added test for sparse CSR precomputed affinity matrices with random landmarking
- Added test for sparse CSR precomputed distance matrices with random landmarking
- Added test for zero affinity edge case that validates proper warning emission
- Improved code comment clarity in graphs.py to better explain kernel usage
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/test_random_landmarking.py | Added three new test functions covering sparse precomputed matrices (affinity and distance) and zero affinity warning edge case, plus sp import |
| graphtools/graphs.py | Updated comment to clarify that kernel contains affinities computed from precomputed matrices regardless of precomputed type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.simplefilter("always") | ||
| G = graphtools.Graph( | ||
| affinity, | ||
| precomputed="affinity", | ||
| n_landmark=n_landmark, | ||
| random_landmarking=True, | ||
| random_state=random_state, | ||
| knn=3, | ||
| thresh=0, | ||
| ) | ||
| _ = G.landmark_op | ||
|
|
||
| assert len(w) == 1 | ||
| assert issubclass(w[0].category, RuntimeWarning) | ||
| assert "zero affinity to all randomly selected landmarks" in str(w[0].message) |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test should use the assert_warns_message helper function available in load_tests instead of manual warning capture with warnings.catch_warnings. This is the established pattern in the codebase for testing warnings (see test_exact.py line 96). Replace this manual warning handling with a cleaner approach using the helper.
Addresses review feedback on PR #88 by adding comprehensive test coverage for sparse matrices and edge cases in random landmarking with precomputed matrices.
Changes
All 21 random landmarking tests pass.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.