Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Mapping

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -10,6 +10,6 @@ def hits(
G: Graph[_Node],
max_iter: int | None = 100,
tol: float | None = 1e-08,
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
nstart: Mapping[_Node, float] | None = None,
normalized: bool = True,
): ...
) -> tuple[dict[_Node, float], dict[_Node, float]]: ...
19 changes: 10 additions & 9 deletions stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Collection
from collections.abc import Collection, Mapping

import numpy as np
from networkx._typing import Array2D
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

Expand All @@ -10,19 +11,19 @@ __all__ = ["pagerank", "google_matrix"]
def pagerank(
G: Graph[_Node],
alpha: float | None = 0.85,
personalization: SupportsGetItem[Incomplete, Incomplete] | None = None,
personalization: Mapping[_Node, float] | None = None,
max_iter: int | None = 100,
Comment on lines -13 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: This and similar changes in this PR are are because the functions use more than __getitem__ of the passed arguments and the parameters are documented as dictionaries. Covariant Mapping is a middle ground between a dict and a protocol of only used methods (relying on implementation details).

tol: float | None = 1e-06,
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
nstart: Mapping[_Node, float] | None = None,
weight: str | None = "weight",
dangling: SupportsGetItem[Incomplete, Incomplete] | None = None,
) -> dict[Incomplete, float]: ...
dangling: Mapping[_Node, float] | None = None,
) -> dict[_Node, float]: ...
@_dispatchable
def google_matrix(
G: Graph[_Node],
alpha: float = 0.85,
personalization: SupportsGetItem[Incomplete, Incomplete] | None = None,
personalization: Mapping[_Node, float] | None = None,
nodelist: Collection[_Node] | None = None,
weight: str | None = "weight",
dangling: SupportsGetItem[Incomplete, Incomplete] | None = None,
): ...
dangling: Mapping[_Node, float] | None = None,
) -> Array2D[np.float64]: ...
Loading