Repository navigation
Conversation
These calls were declined, so a backend graph could not get them: - bethe_hessian_matrix reads a backend graph's values where they are weight's. A weighted NetworkX graph is still declined, since NetworkX converts no edge data for this name; whether it has weights is now read once per version of the graph. - reciprocity and overall_reciprocity answer an undirected graph as NetworkX does: 0.0 overall, and its AttributeError for nodes, naming the class of the caller's graph, which from_networkx now records. - hits serves method="svd" with SciPy's svds on this backend's matrix, as NetworkX 3.7 computes it, and raises its ValueError for an unknown method. On NetworkX 3.6, which has no method, it is this backend's own keyword. - average_shortest_path_length serves both Floyd-Warshall methods and raises NetworkX's ValueError for an unknown method. On a negative cycle it raises NetworkXUnbounded, as NetworkX 3.7 does; where the installed NetworkX's Floyd-Warshall gives a number instead, should_run leaves a NetworkX graph with a negative weight to it. - diameter, radius, periphery, center and eccentricity give the null graph the installed NetworkX's own answer, which differs between its versions. - k_core, k_shell, k_crust and k_corona compare a k that is not a real number with each core number as NetworkX does, and k_corona takes a k of None as the largest core number. - bfs_edges and bfs_successors walk with sort_neighbors as NetworkX does, handing it each node's neighbors in node order. should_run leaves a NetworkX graph to NetworkX, which hands them in the order they were added, and whose walk of its own graph is faster. - schultz_index and gutman_index give a graph with a node named "weight" the index its degree gives, where NetworkX takes that node's degree from its weight argument. should_run leaves such a graph to NetworkX where it would convert it.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 75-should-run-base #176 +/- ##
======================================================
+ Coverage 93.07% 93.28% +0.21%
======================================================
Files 184 185 +1
Lines 11568 12054 +486
Branches 1290 1355 +65
======================================================
+ Hits 10767 11245 +478
- Misses 549 556 +7
- Partials 252 253 +1 🚀 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.
Serve the calls on #102 to #121 that this backend declined although NetworkX answers them, so that a backend graph gets them too, each with NetworkX's answer or error. Where NetworkX has a bug, the answer here is the one the docs below give, and the call NetworkX dispatches itself still gets NetworkX's, through the
should_runthis is stacked on. The difference and symmetric difference of a Graph and a DiGraph (#107) stay as they are, since #147 revises that rule.bethe_hessian_matrix(03 dispatch #102) reads a backend graph's values where they areweight's, and otherwise weighs every edge 1, as NetworkX reads the graph. A weighted NetworkX graph is still declined: NetworkX readsweighthere but declares no edge attribute, so its conversion carries no weights, andbackend="graphblas"on such a graph raises NotImplementedError. Whether a NetworkX graph has weights is read once per version of the graph, throughremembered.reciprocityandoverall_reciprocity(03 dispatch #102) answer an undirected graph as NetworkX does: 0.0 overall (NetworkXError for a graph without edges), and for nodes NetworkX's AttributeError, raised at the first node the graph has, as NetworkX's lazy search meets it;{}when it has none. The error names the class of the caller's graph, such as a subclass ofnx.Graph, whichfrom_networkxnow records on a conversion and on a backend graph built from a NetworkX graph. The decorator is now NetworkX's, which refuses only an undirected multigraph.hits(05 link analysis #104) servesmethod="svd", NetworkX 3.7's own computation (SciPy'ssvdswith its start vector,max_iterandtol) on this backend's matrix, and raises NetworkX'sValueError: method not supportedfor any other method. The second method is "svd", not the "scipy" and "numpy" the audit named. Where the largest singular value is repeated (any undirected bipartite graph), SciPy's vector, and NetworkX's own answer, changes from one call to the next. NetworkX 3.6 has nomethod: NetworkX's dispatch passes a keyword it does not declare to the backend, so there this backend takes it as its own, as it took "power_iteration" before, while NetworkX alone raises TypeError. The notes NetworkX shows forhitssay so.average_shortest_path_length(13 distance measures #112) servesmethod="floyd-warshall"and"floyd-warshall-numpy", whose mean is the other methods' mean, and raisesValueError: method not supportedbefore anything else, as NetworkX does. On a negative cycle it raises NetworkXUnbounded, as NetworkX 3.7's Floyd-Warshall does, for a backend graph and forbackend="graphblas". NetworkX 3.6's Floyd-Warshall gives a number there, so where the installed NetworkX's does not raise,should_runleaves a NetworkX graph with a negative weight for those methods to NetworkX; whether a graph has one is read once per version of the graph, throughremembered. The installed NetworkX is asked once per method, on a two-node negative cycle, and the answer is kept for the process, so it comes from NetworkX's own code, called without dispatching it and without writing NetworkX's config, which other threads share: a write there races with another thread's ownwith nx.config.backend_priority(...). In 3.6.1, 3.7 and dev,floyd_warshallraises only throughfloyd_warshall_predecessor_and_distance, which it calls dispatched, so a priority foralgosor for that name would give the call to this backend, which raises on the cycle. That function's own code calls nothing dispatched, and it is what runs for "floyd-warshall". For the numpy methodfloyd_warshall_numpy's own code runs; theto_numpy_arrayit calls is dispatched, and this backend does not implement it. NetworkX's test mode hands that call to the backend under test anyway, where it raises pytest's xfail, so there the numpy method gets the other method's answer. Any error but NetworkXUnbounded counts as no, which leaves such a graph to NetworkX. Asked afresh 20000 times under no priority,algos, a priority for each of those names and the test mode, beside a thread looping on its ownwithover the priorities, beside one setting a priority back and forth, and from two threads at once, it gave no wrong answer and no error in any thread, and left the config as it was, in 3.6.1, 3.7 and dev. With a priority for this name, NetworkX 3.6 then gives its number. With thealgospriority, NetworkX's own mean callsfloyd_warshall, which this backend serves and which raises on a negative cycle in every version: that isfloyd_warshall's own difference from NetworkX 3.6, which this does not change.diameter,radius,periphery,centerandeccentricity(13 distance measures #112) give the null graph the installed NetworkX's answer, which changes between versions: NetworkXPointlessConcept from 3.7, ValueError or{}in 3.6, ValueError withusebounds, and the maximum of a givene. The installed NetworkX is asked directly, on a null graph of the same kind; nothing is converted or walked. A precomputedspon a null graph now gets that answer too.k_core,k_shell,k_crustandk_corona(19 core #120) take akthat is not a real number to NetworkX's own test of each node's core number, in node order: a string or a complex number raises NetworkX's TypeError where NetworkX's comparison raises, a Decimal compares as a number, and the null graph compares nothing. The subgraph is built as for any otherk.k_coronatakes akof None as the largest core number, as NetworkX does; it raised TypeError before.bfs_edgesandbfs_successors(11 bfs #110) walk withsort_neighborsas NetworkX'sgeneric_bfs_edgesdoes:sort_neighborsis asked for each node's neighbors as the node is found, the walk reads what it returns lazily and stops once every node is seen. It is handed each node's neighbors in node order, where NetworkX hands them in the order they were added, so asort_neighborsthat keeps its input's order walks differently; one that sorts the nodes gives NetworkX's tree.should_runleaves a NetworkX graph to the next backend or NetworkX, which hands the neighbors in the order they were added, and whose walk of its own graph is faster than this one in Python.schultz_indexandgutman_index(20 wiener efficiency #121) give a graph with a node named "weight" the index its degree gives. NetworkX builds its degrees asdict(G.degree, weight=weight), which gives that node theweightargument as its degree, so NetworkX raises TypeError on a connected graph and gives inf on another.should_runleaves such a NetworkX graph to the next backend or NetworkX; a backend graph andbackend="graphblas"get the index.backend="graphblas"on a NetworkX graph, and with NetworkX choosing the backend, and compares each with NetworkX's answer or error (floats to 1e-12, the HITS vectors to 1e-6), or, for the three rules, with the documented answer, checking whether NetworkX converted the graph for the third. The cases are a weighted graph with a self-loop,randnodelist, and the same values under another attribute; undirected graphs with nodes given as None, a node, lists with and without members, a missing node, an unhashable member before and after a member, and a string; HITS by "svd" on graphs that are not bipartite (weighted, directed,tol,nstart, unnormalized up to SciPy's sign, nodes out of row order, hubs and authorities of a digraph) and its errors, compared on NetworkX 3.6 with NetworkX 3.7's computation, which the tests hold and check against NetworkX's own where it has it, and on NetworkX 3.6 NetworkX's TypeError beside the backend's answer; Floyd-Warshall on weighted, directed and negative-weight graphs, two negative cycles (one whose negative weight lies between -1 and 0) and an unknown method, with NetworkX's number on the automatic path on NetworkX 3.6, the negative weight read once per version of the graph, and the installed NetworkX asked afresh under thealgospriority, under a priority for each name its Floyd-Warshall calls and in its test mode, with nothing converted and nothing written to NetworkX's config, and a changed signature or a missingorig_functaken for no; reciprocity's error on a subclass; the five names on null graphs of both kinds with each argument; eight kinds ofkon three graphs, andk_coronawith None on four; three sorts on four graphs withdepth_limitandreverse, the calls tosort_neighborsand what it yields being read, and a missing, an unhashable and a stranger node; and the Wiener relatives with a node named "weight" on connected and disconnected graphs, weighted and not. The tests of the old declines are gone. 50 mutants, of each rule and of each answer above, fail these tests in dev, 3.7 and 3.6.1, but these: the check of the installed NetworkX's Floyd-Warshall, made to answer that it raises (or that it does not), changes nothing on the NetworkX that does (or does not), and fails them on the other; and a negative weight seen only at -1 or below changes nothing where that check says it raises, and fails them on NetworkX 3.6. Among those that fail them: the check run throughfloyd_warshall's own code, or through either function dispatched, or by emptying the priorities in NetworkX's config; the numpy method asked in the test mode; and another error let out, or taken for yes.test_hits_invalid_methodand the svd case,test_specified_methodsandtest_bad_methodfor the mean,test_diameter_radius_empty_graphandtest_eccentricity,test_bfs_edges_sorting), and otherwise only in the tests whose counts also change between two runs of one tree (the traveling salesman ascent,test_kcomponents,test_lukes, the double-edge swap and small-world tests).Stacked on #174.