Skip to content

test(diffusion,eval): cover non-square matrix, 1D input, max_iters cap, repeated-event traces#11

Merged
protosphinx merged 1 commit into
mainfrom
bot/diffusion-eval-gap-tests
May 15, 2026
Merged

test(diffusion,eval): cover non-square matrix, 1D input, max_iters cap, repeated-event traces#11
protosphinx merged 1 commit into
mainfrom
bot/diffusion-eval-gap-tests

Conversation

@protosphinx
Copy link
Copy Markdown
Member

Why

Three validation branches in personalized_pagerank had zero direct test coverage:

  • p_t.ndim != 2 (1D array input)
  • p_t.shape[0] != p_t.shape[1] (non-square matrix)
  • max_iters cap reached before convergence (the loop exits without the break)

extract_cases also had no test for a trace where the same event repeats consecutively, and evaluate had no test for duplicate values in the ks list (the sorted(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 cases
    • test_ppr_non_square_matrix_raises: np.zeros((2, 3)) triggers the shape check
    • test_ppr_1d_input_raises: np.zeros(3) triggers the ndim check
    • test_ppr_max_iters_cap_returns_normalized: max_iters=1 exits before convergence but result is still L1-normalized with no negative entries
  • tests/test_eval.py: two new cases
    • test_extract_cases_repeated_events_in_trace: ["a", "a", "a"] produces two valid LocalizationCase pairs
    • test_evaluate_ks_deduplication: ks=[1, 1, 3] deduplicates to {1, 3} in the returned score

Tests

  • ruff check: clean
  • python -m pytest -q: 88 passed (was 83 before this PR, +5 new)

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (added + removed)
  • no public-API surface change
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended

Generated by Claude Code

…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
@protosphinx protosphinx added the automated Opened by the daily bot label May 15, 2026 — with Claude
@protosphinx protosphinx merged commit 8c4981e into main May 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant