Repository navigation
test: incidence() is checked cell by cell - #50
Merged
Merged
Conversation
0.6.5 returned the wrong matrix for every graph with an edge: a loop variable overwrote the vertex index, so edges were marked in the wrong rows, and for a directed graph the vertex at the end of an edge was not marked. The tests that existed checked only column and row sums, because edges() was a set and the column order was not defined, so neither bug was caught. edges() is now in the order the edges were added, so the matrix can be checked by position. Each expectation is written out by hand, for both kinds of graph: paths, a star, edges pointing backwards, a vertex that is only ever an end, creation order against names, parallel and antiparallel edges, loops, and rows and columns closing up after a removal. 16 of them fail on the 0.6.5 source. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 22 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
=======================================
Coverage 95.37% 95.37%
=======================================
Files 3 3
Lines 1277 1277
=======================================
Hits 1218 1218
Misses 59 59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Tests for
incidence()that compare the matrix cell by cell. No source change.0.6.5 returned the wrong matrix for every graph with an edge, from two bugs visible in its source:
iis overwritten, so edges are marked in the wrong rows;edges()are visited, so in a directed graph the vertex at the end of an edge is never marked.Both were fixed in this cycle (the matrix is now built from
edges()and both endpoints), but nothing pinned them: the existing tests check only column sums and row sums, becauseedges()was a set and the column order was undefined. It is now in the order the edges were added, so the matrix can be checked by position.Tests
tests/test_incidence.py(32, both graph kinds), with each expectation written out by hand rather than derived from the code under test:edges()orderremove_edge, rows afterremove_vertex, and an isolated vertex is a row of zerosThey discriminate: run against the real
v0.6.5source, 16 of the 16 that do not need newer API fail, all by assertion.Also corrects a stale comment in
test_graph.pythat said the column order was not deterministic.🤖 Generated with Claude Code