Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add networkx stubs #10544

Merged
merged 38 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
afa3c9c
Add networkx
rhelmot Aug 8, 2023
9155998
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2023
adfc9f9
Update stubs/networkx/networkx/readwrite/graphml.pyi
rhelmot Oct 22, 2023
7173ae0
Update stubs/networkx/networkx/algorithms/flow/maxflow.pyi
rhelmot Oct 22, 2023
cf6dad5
Update stubs/networkx/networkx/algorithms/boundary.pyi
rhelmot Oct 22, 2023
3884ce6
Update stubs/networkx/networkx/classes/function.pyi
rhelmot Oct 22, 2023
3d116d9
Update stubs/networkx/networkx/classes/reportviews.pyi
rhelmot Oct 22, 2023
d84fba0
Update stubs/networkx/networkx/classes/graph.pyi
rhelmot Oct 22, 2023
b79c591
Update stubs/networkx/networkx/algorithms/bridges.pyi
rhelmot Oct 22, 2023
423a35e
Update stubs/networkx/METADATA.toml
rhelmot Oct 22, 2023
76d4b6f
Update stubs/networkx/networkx/algorithms/tree/branchings.pyi
rhelmot Oct 22, 2023
90c991f
Update stubs/networkx/networkx/algorithms/tree/branchings.pyi
rhelmot Oct 22, 2023
cb02f2c
Fix typevar names
rhelmot Oct 22, 2023
83e9077
Nuke extra incompletes
rhelmot Oct 22, 2023
05daed0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 22, 2023
9c6f2ee
Remove redundant Incomplete and ellipses (#2)
Avasam Oct 23, 2023
8a17cca
Adress PR comments, fix mypy and pyright issues (#3)
Avasam Oct 23, 2023
7355586
Fix stubtest "is not present at runtime" issues (#4)
Avasam Oct 23, 2023
ebef107
Work around stubuploader issue (#6)
Avasam Oct 23, 2023
34d72ae
Run stubdefaulter; closes #5
rhelmot Oct 23, 2023
db33680
Fix invalid default `None` values (#7)
Avasam Oct 24, 2023
6228903
Fixing all stubtest errors left (#8)
Avasam Oct 24, 2023
6aa2fce
fix pytype issues (#9)
Avasam Oct 24, 2023
284482b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2023
391234e
Fix reportviews metaclasses
rhelmot Oct 24, 2023
73c4bb6
Improve fidelity of interfaces in convert_matrix
rhelmot Oct 24, 2023
e80965c
Update stubs/networkx/networkx/convert_matrix.pyi
rhelmot Oct 24, 2023
cfa3ff6
Improve two create_using cases
rhelmot Oct 24, 2023
c5cefbb
Improve fidelity of graphviews
rhelmot Oct 24, 2023
97822cb
Specify generic arguments for _Edge
rhelmot Oct 24, 2023
cdc358e
Batch apply simple suggestions from code review
Avasam Nov 28, 2023
e074379
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 28, 2023
ddcb1b5
Fix imports and types after batch suggestions
Avasam Nov 28, 2023
ea04db6
Fix new Y059, Y060 violations
Avasam Nov 29, 2023
f17307e
Reduce unbound TypeVar declarations, reuse _Node
Avasam Nov 29, 2023
1941eb8
Applied further suggestions
Avasam Nov 29, 2023
1239536
Add comment to `view_pygraphviz`'s `edgelabel` param
Avasam Nov 29, 2023
a4d8ebc
Merge branch 'main' into main
Avasam Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"stubs/mysqlclient",
"stubs/oauthlib",
"stubs/openpyxl",
"stubs/networkx",
"stubs/passlib",
"stubs/peewee",
"stubs/pexpect",
Expand Down
9 changes: 9 additions & 0 deletions stubs/networkx/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = "3.1"
upstream_repository = "https://github.com/networkx/networkx"
requires = ["numpy"]
partial_stub = true
Avasam marked this conversation as resolved.
Show resolved Hide resolved
rhelmot marked this conversation as resolved.
Show resolved Hide resolved

[tool.stubtest]
ignore_missing_stub = true
# stub_uploader won't allow pandas-stubs in the requires field https://github.com/typeshed-internal/stub_uploader/issues/90
stubtest_requirements = ["pandas"]
24 changes: 24 additions & 0 deletions stubs/networkx/networkx/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from networkx.algorithms import *
from networkx.classes import *
from networkx.classes import filters as filters
from networkx.convert import *
from networkx.convert_matrix import *
from networkx.drawing import *
from networkx.exception import *
from networkx.generators import *
from networkx.linalg import *
from networkx.readwrite import *
from networkx.relabel import *

from . import (
algorithms as algorithms,
classes as classes,
convert as convert,
convert_matrix as convert_matrix,
drawing as drawing,
generators as generators,
linalg as linalg,
readwrite as readwrite,
relabel as relabel,
utils as utils,
)
135 changes: 135 additions & 0 deletions stubs/networkx/networkx/algorithms/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from networkx.algorithms import (
approximation as approximation,
assortativity as assortativity,
bipartite as bipartite,
centrality as centrality,
chordal as chordal,
clique as clique,
cluster as cluster,
coloring as coloring,
community as community,
components as components,
connectivity as connectivity,
flow as flow,
isomorphism as isomorphism,
link_analysis as link_analysis,
lowest_common_ancestors as lowest_common_ancestors,
node_classification as node_classification,
operators as operators,
shortest_paths as shortest_paths,
tournament as tournament,
traversal as traversal,
tree as tree,
)
from networkx.algorithms.assortativity import *
from networkx.algorithms.asteroidal import *
from networkx.algorithms.bipartite import (
complete_bipartite_graph as complete_bipartite_graph,
is_bipartite as is_bipartite,
projected_graph as projected_graph,
)
from networkx.algorithms.boundary import *
from networkx.algorithms.bridges import *
from networkx.algorithms.centrality import *
from networkx.algorithms.chains import *
from networkx.algorithms.chordal import *
from networkx.algorithms.clique import *
from networkx.algorithms.cluster import *
from networkx.algorithms.coloring import *
from networkx.algorithms.communicability_alg import *
from networkx.algorithms.components import *
from networkx.algorithms.connectivity import (
all_node_cuts as all_node_cuts,
all_pairs_node_connectivity as all_pairs_node_connectivity,
average_node_connectivity as average_node_connectivity,
edge_connectivity as edge_connectivity,
edge_disjoint_paths as edge_disjoint_paths,
is_k_edge_connected as is_k_edge_connected,
k_components as k_components,
k_edge_augmentation as k_edge_augmentation,
k_edge_components as k_edge_components,
k_edge_subgraphs as k_edge_subgraphs,
minimum_edge_cut as minimum_edge_cut,
minimum_node_cut as minimum_node_cut,
node_connectivity as node_connectivity,
node_disjoint_paths as node_disjoint_paths,
stoer_wagner as stoer_wagner,
)
from networkx.algorithms.core import *
from networkx.algorithms.covering import *
from networkx.algorithms.cuts import *
from networkx.algorithms.cycles import *
from networkx.algorithms.d_separation import *
from networkx.algorithms.dag import *
from networkx.algorithms.distance_measures import *
from networkx.algorithms.distance_regular import *
from networkx.algorithms.dominance import *
from networkx.algorithms.dominating import *
from networkx.algorithms.efficiency_measures import *
from networkx.algorithms.euler import *
from networkx.algorithms.flow import (
capacity_scaling as capacity_scaling,
cost_of_flow as cost_of_flow,
gomory_hu_tree as gomory_hu_tree,
max_flow_min_cost as max_flow_min_cost,
maximum_flow as maximum_flow,
maximum_flow_value as maximum_flow_value,
min_cost_flow as min_cost_flow,
min_cost_flow_cost as min_cost_flow_cost,
minimum_cut as minimum_cut,
minimum_cut_value as minimum_cut_value,
network_simplex as network_simplex,
)
from networkx.algorithms.graph_hashing import *
from networkx.algorithms.graphical import *
from networkx.algorithms.hierarchy import *
from networkx.algorithms.hybrid import *
from networkx.algorithms.isolate import *
from networkx.algorithms.isomorphism import (
could_be_isomorphic as could_be_isomorphic,
fast_could_be_isomorphic as fast_could_be_isomorphic,
faster_could_be_isomorphic as faster_could_be_isomorphic,
is_isomorphic as is_isomorphic,
)
from networkx.algorithms.isomorphism.vf2pp import *
from networkx.algorithms.link_analysis import *
from networkx.algorithms.link_prediction import *
from networkx.algorithms.lowest_common_ancestors import *
from networkx.algorithms.matching import *
from networkx.algorithms.minors import *
from networkx.algorithms.mis import *
from networkx.algorithms.moral import *
from networkx.algorithms.non_randomness import *
from networkx.algorithms.operators import *
from networkx.algorithms.planar_drawing import *
from networkx.algorithms.planarity import *
from networkx.algorithms.polynomials import *
from networkx.algorithms.reciprocity import *
from networkx.algorithms.regular import *
from networkx.algorithms.richclub import *
from networkx.algorithms.shortest_paths import *
from networkx.algorithms.similarity import *
from networkx.algorithms.simple_paths import *
from networkx.algorithms.smallworld import *
from networkx.algorithms.smetric import *
from networkx.algorithms.sparsifiers import *
from networkx.algorithms.structuralholes import *
from networkx.algorithms.summarization import *
from networkx.algorithms.swap import *
from networkx.algorithms.traversal import *
from networkx.algorithms.tree.branchings import (
ArborescenceIterator as ArborescenceIterator,
maximum_branching as maximum_branching,
maximum_spanning_arborescence as maximum_spanning_arborescence,
minimum_branching as minimum_branching,
minimum_spanning_arborescence as minimum_spanning_arborescence,
)
from networkx.algorithms.tree.coding import *
from networkx.algorithms.tree.decomposition import *
from networkx.algorithms.tree.mst import *
from networkx.algorithms.tree.operations import *
from networkx.algorithms.tree.recognition import *
from networkx.algorithms.triads import *
from networkx.algorithms.vitality import *
from networkx.algorithms.voronoi import *
from networkx.algorithms.wiener import *
13 changes: 13 additions & 0 deletions stubs/networkx/networkx/algorithms/approximation/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from networkx.algorithms.approximation.clique import *
from networkx.algorithms.approximation.clustering_coefficient import *
from networkx.algorithms.approximation.connectivity import *
from networkx.algorithms.approximation.distance_measures import *
from networkx.algorithms.approximation.dominating_set import *
from networkx.algorithms.approximation.kcomponents import *
from networkx.algorithms.approximation.matching import *
from networkx.algorithms.approximation.maxcut import *
from networkx.algorithms.approximation.ramsey import *
from networkx.algorithms.approximation.steinertree import *
from networkx.algorithms.approximation.traveling_salesman import *
from networkx.algorithms.approximation.treewidth import *
from networkx.algorithms.approximation.vertex_cover import *
4 changes: 4 additions & 0 deletions stubs/networkx/networkx/algorithms/approximation/clique.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def maximum_independent_set(G): ...
def max_clique(G): ...
def clique_removal(G): ...
def large_clique_size(G): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from _typeshed import Incomplete

def average_clustering(G, trials: int = 1000, seed: Incomplete | None = None): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from _typeshed import Incomplete

def local_node_connectivity(G, source, target, cutoff: Incomplete | None = None): ...
def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None): ...
def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from _typeshed import Incomplete

def diameter(G, seed: Incomplete | None = None): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from _typeshed import Incomplete

def min_weighted_dominating_set(G, weight: Incomplete | None = None): ...
def min_edge_dominating_set(G): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def k_components(G, min_density: float = 0.95): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def min_maximal_matching(G): ...
4 changes: 4 additions & 0 deletions stubs/networkx/networkx/algorithms/approximation/maxcut.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from _typeshed import Incomplete

def randomized_partitioning(G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None): ...
def one_exchange(G, initial_cut: Incomplete | None = None, seed: Incomplete | None = None, weight: Incomplete | None = None): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def ramsey_R2(G): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from _typeshed import Incomplete

def metric_closure(G, weight: str = "weight"): ...
def steiner_tree(G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from _typeshed import Incomplete

def christofides(G, weight: str = "weight", tree: Incomplete | None = None): ...
def traveling_salesman_problem(
G, weight: str = "weight", nodes: Incomplete | None = None, cycle: bool = True, method: Incomplete | None = None
): ...
def asadpour_atsp(G, weight: str = "weight", seed: Incomplete | None = None, source: Incomplete | None = None): ...
def greedy_tsp(G, weight: str = "weight", source: Incomplete | None = None): ...
def simulated_annealing_tsp(
G,
init_cycle,
weight: str = "weight",
source: Incomplete | None = None,
temp: int = 100,
Avasam marked this conversation as resolved.
Show resolved Hide resolved
move: str = "1-1",
max_iterations: int = 10,
N_inner: int = 100,
alpha: float = 0.01,
seed: Incomplete | None = None,
): ...
def threshold_accepting_tsp(
G,
init_cycle,
weight: str = "weight",
source: Incomplete | None = None,
threshold: int = 1,
Avasam marked this conversation as resolved.
Show resolved Hide resolved
move: str = "1-1",
max_iterations: int = 10,
N_inner: int = 100,
alpha: float = 0.1,
seed: Incomplete | None = None,
): ...
11 changes: 11 additions & 0 deletions stubs/networkx/networkx/algorithms/approximation/treewidth.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from _typeshed import Incomplete

__all__ = ["treewidth_min_degree", "treewidth_min_fill_in"]

def treewidth_min_degree(G): ...
def treewidth_min_fill_in(G): ...

class MinDegreeHeuristic:
count: Incomplete
def __init__(self, graph) -> None: ...
def best_node(self, graph): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from _typeshed import Incomplete

def min_weighted_vertex_cover(G, weight: Incomplete | None = None): ...
5 changes: 5 additions & 0 deletions stubs/networkx/networkx/algorithms/assortativity/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from networkx.algorithms.assortativity.connectivity import *
from networkx.algorithms.assortativity.correlation import *
from networkx.algorithms.assortativity.mixing import *
from networkx.algorithms.assortativity.neighbor_degree import *
from networkx.algorithms.assortativity.pairs import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from _typeshed import Incomplete

def average_degree_connectivity(
G, source: str = "in+out", target: str = "in+out", nodes: Incomplete | None = None, weight: Incomplete | None = None
): ...
10 changes: 10 additions & 0 deletions stubs/networkx/networkx/algorithms/assortativity/correlation.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from _typeshed import Incomplete

def degree_assortativity_coefficient(
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None
): ...
def degree_pearson_correlation_coefficient(
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None
): ...
def attribute_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ...
def numeric_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ...
19 changes: 19 additions & 0 deletions stubs/networkx/networkx/algorithms/assortativity/mixing.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from _typeshed import Incomplete

def attribute_mixing_dict(G, attribute, nodes: Incomplete | None = None, normalized: bool = False): ...
def attribute_mixing_matrix(
G, attribute, nodes: Incomplete | None = None, mapping: Incomplete | None = None, normalized: bool = True
): ...
def degree_mixing_dict(
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None, normalized: bool = False
): ...
def degree_mixing_matrix(
G,
x: str = "out",
y: str = "in",
weight: Incomplete | None = None,
nodes: Incomplete | None = None,
normalized: bool = True,
mapping: Incomplete | None = None,
): ...
def mixing_dict(xy, normalized: bool = False): ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from _typeshed import Incomplete

def average_neighbor_degree(
G, source: str = "out", target: str = "out", nodes: Incomplete | None = None, weight: Incomplete | None = None
): ...
7 changes: 7 additions & 0 deletions stubs/networkx/networkx/algorithms/assortativity/pairs.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Generator

def node_attribute_xy(G, attribute, nodes: Incomplete | None = None) -> Generator[Incomplete, None, None]: ...
def node_degree_xy(
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None
) -> Generator[Incomplete, None, None]: ...
2 changes: 2 additions & 0 deletions stubs/networkx/networkx/algorithms/asteroidal.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def find_asteroidal_triple(G): ...
def is_at_free(G): ...
11 changes: 11 additions & 0 deletions stubs/networkx/networkx/algorithms/bipartite/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from networkx.algorithms.bipartite.basic import *
from networkx.algorithms.bipartite.centrality import *
from networkx.algorithms.bipartite.cluster import *
from networkx.algorithms.bipartite.covering import *
from networkx.algorithms.bipartite.edgelist import *
from networkx.algorithms.bipartite.generators import *
from networkx.algorithms.bipartite.matching import *
from networkx.algorithms.bipartite.matrix import *
from networkx.algorithms.bipartite.projection import *
from networkx.algorithms.bipartite.redundancy import *
from networkx.algorithms.bipartite.spectral import *
8 changes: 8 additions & 0 deletions stubs/networkx/networkx/algorithms/bipartite/basic.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from _typeshed import Incomplete

def color(G): ...
def is_bipartite(G): ...
def is_bipartite_node_set(G, nodes): ...
def sets(G, top_nodes: Incomplete | None = None): ...
def density(B, nodes): ...
def degrees(B, nodes, weight: Incomplete | None = None): ...
3 changes: 3 additions & 0 deletions stubs/networkx/networkx/algorithms/bipartite/centrality.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def degree_centrality(G, nodes): ...
def betweenness_centrality(G, nodes): ...
def closeness_centrality(G, nodes, normalized: bool = True): ...
8 changes: 8 additions & 0 deletions stubs/networkx/networkx/algorithms/bipartite/cluster.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from _typeshed import Incomplete

def latapy_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ...

clustering = latapy_clustering

def average_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ...
def robins_alexander_clustering(G): ...
3 changes: 3 additions & 0 deletions stubs/networkx/networkx/algorithms/bipartite/covering.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from _typeshed import Incomplete

def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ...