Skip to content

61 generic declines - #156

Open
eriknw wants to merge 1 commit into
python-graphblas:20-wiener-efficiencyfrom
eriknw:61-generic-declines
Open

eriknw wants to merge 1 commit into
python-graphblas:20-wiener-efficiencyfrom
eriknw:61-generic-declines

Conversation

@eriknw

@eriknw eriknw commented Dec 3, 2026

Copy link
Copy Markdown
Member

Two declines that apply to every dispatched name. Each leaves a call to NetworkX where this backend's answer or error would differ from NetworkX's.

  • Newer keywords. Dispatcher.can_run declines a keyword NetworkX added after its oldest supported release (the _NOT_EXTRA table) when the installed NetworkX lacks it. NetworkX 3.6 passes such a keyword on to the backend, and the wrappers take it, so hits(G, method=...), closeness_centrality(G, sp=None) and adjacency_matrix(G, format=...) were answered there. NetworkX's own function raises TypeError for them, such as "hits() got an unexpected keyword argument 'method'", and now it does. NetworkX 3.7 and the development branch have these keywords and serve them as before.
    • The backend's own keywords, such as chunksize, are in no NetworkX and are taken on any version.
    • A keyword neither knows already gave NetworkX's own TypeError text.
    • test_signatures_match_nx already requires every NetworkX keyword newer than 3.6 that a wrapper takes to be in _NOT_EXTRA, so the table is complete. All three are keyword-only in NetworkX, so none can be passed positionally.
  • A conversion's TypeError. Dispatcher.convert_from_nx turns a TypeError from converting an edge attribute's values into NotImplementedError, as it already did scipy's ValueError, and NetworkX falls back. NetworkX's to_scipy_sparse_array negates the value of an undirected self-loop before scipy sees it. For a string, bytes, None, a list or an object without arithmetic, that raises "bad operand type for unary -", and before this change a weighted call on such a graph raised it at the call.
    • With backend="graphblas" named, such a call now raises NotImplementedError, carrying the TypeError as its cause.
    • A TypeError from a fault in the conversion itself would now fall back too, rather than surface. This applies only when an edge attribute is converted.
  • Effect on the weighted names. The probe covers every weighted name this backend serves that has an argument recipe NetworkX accepts (45 of them). Each runs on directed and undirected graphs, with and without a self-loop, with str, bytes, object, None, list, Decimal and Fraction values, comparing NetworkX alone with NetworkX with graphblas first.
    • Before: 110 of 1148 calls differed, in NetworkX 3.6.1, 3.7 and dev alike. All were undirected with a self-loop and a value that cannot be negated, across 22 names: the Bellman-Ford and Floyd-Warshall names, the eccentricity family, the Wiener family, clustering, closeness, harmonic, Katz and eigenvector centrality, google_matrix, volume and mutual_weight. In those 110, NetworkX answered 14, raised its own error at the call in 91, and raised as the result was read in 5.
    • After: none differ, in all three versions.
    • pagerank matched before as well, since NetworkX's own pagerank converts with the same function and raises the same TypeError.
  • Tests.
    • Each newer keyword is declined, with NetworkX's TypeError, where NetworkX lacks it, and served with NetworkX's answer where NetworkX has it. A check makes sure the test table names every _NOT_EXTRA entry of a dispatched name.
    • chunksize is served on any NetworkX.
    • The conversion refuses each of the five values on a self-loop.
    • Nine weighted names under priority give NetworkX's own answer or error for each value.
    • hits's power-iteration test now expects the decline where NetworkX lacks method.
    • Four mutants (the TypeError raised, a newer keyword served, declined on every NetworkX, every keyword NetworkX lacks declined) each fail these tests in every NetworkX where they change behaviour, and are equivalent elsewhere.

Stacked on #121.

Two declines that apply to every dispatched name.

A keyword NetworkX added after its oldest supported release is now
declined where the installed NetworkX lacks it: hits's method,
closeness_centrality's sp and adjacency_matrix's format on 3.6. Such a
NetworkX passes the keyword on, and the backend, whose wrappers take
it, answered where NetworkX's own function raises TypeError for it.
The backend's own keywords, such as chunksize, are taken on any
NetworkX.

A TypeError from converting an edge attribute's values is now a
decline, as scipy's ValueError already was, so NetworkX answers or
raises its own error. NetworkX's to_scipy_sparse_array negates the
value of an undirected self-loop before scipy sees it, which raises
TypeError for a string, bytes, None, a list or an object without
arithmetic. A weighted call on such a graph raised that error at the
call, where NetworkX often answers, raises a different error, or
raises only as its generator is read.
This was referenced Dec 3, 2026
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.10145% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.90%. Comparing base (5b54ace) to head (83d8c57).

Additional details and impacted files
@@                   Coverage Diff                    @@
##           20-wiener-efficiency     #156      +/-   ##
========================================================
+ Coverage                 92.88%   92.90%   +0.02%     
========================================================
  Files                       182      182              
  Lines                     11227    11294      +67     
  Branches                   1274     1281       +7     
========================================================
+ Hits                      10428    10493      +65     
- Misses                      546      547       +1     
- Partials                    253      254       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknw eriknw mentioned this pull request Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant