test(diffusion,eval): cover non-square matrix, 1D input, max_iters cap, repeated-event traces#11
Merged
Merged
Conversation
…p, and repeated-event traces Three gaps in test_diffusion.py: - non-square p_t matrix triggers the shape[0]!=shape[1] ValueError - 1D p_t array triggers the ndim!=2 ValueError - max_iters=1 exits before convergence but still returns a valid L1-normalized probability vector Two gaps in test_eval.py: - extract_cases with a trace of repeated identical events produces the correct LocalizationCase pairs - evaluate with duplicate k values in the ks list deduplicates them and returns only unique keys
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.
Why
Three validation branches in
personalized_pagerankhad zero direct test coverage:p_t.ndim != 2(1D array input)p_t.shape[0] != p_t.shape[1](non-square matrix)max_iterscap reached before convergence (the loop exits without thebreak)extract_casesalso had no test for a trace where the same event repeats consecutively, andevaluatehad no test for duplicate values in thekslist (thesorted(set(ks))deduplication path).These are all existing code paths, not new features. Closing them prevents silent regressions as the diffusion core and eval harness evolve.
What
tests/test_diffusion.py: three new casestest_ppr_non_square_matrix_raises:np.zeros((2, 3))triggers the shape checktest_ppr_1d_input_raises:np.zeros(3)triggers the ndim checktest_ppr_max_iters_cap_returns_normalized:max_iters=1exits before convergence but result is still L1-normalized with no negative entriestests/test_eval.py: two new casestest_extract_cases_repeated_events_in_trace:["a", "a", "a"]produces two validLocalizationCasepairstest_evaluate_ks_deduplication:ks=[1, 1, 3]deduplicates to{1, 3}in the returned scoreTests
ruff check: cleanpython -m pytest -q: 88 passed (was 83 before this PR, +5 new)Self-merge gate
Generated by Claude Code