Skip to content

Commit e0670a1

Browse files
authored
🏷️ cluster: stub internal cython submodules (#714)
2 parents c2f8b79 + 6d668fa commit e0670a1

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

scipy-stubs/cluster/_hierarchy.pyi

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from typing import Any, Final, Literal, final, type_check_only
2+
3+
import numpy as np
4+
import optype.numpy as onp
5+
6+
@type_check_only
7+
class _CythonMixin:
8+
def __reduce_cython__(self) -> tuple[Any, ...]: ...
9+
def __setstate_cython__(self, /, state: tuple[Any, ...]) -> None: ...
10+
11+
# defined in `cluster/_structures.pxi`
12+
@type_check_only
13+
@final
14+
class Pair:
15+
key: Final[int]
16+
value: Final[float]
17+
18+
# defined in `cluster/_structures.pxi`
19+
class Heap(_CythonMixin):
20+
index_by_key: Final[onp.Array1D[np.int32]]
21+
keys_by_index: Final[onp.Array1D[np.int32]]
22+
values: Final[onp.Array1D[np.float64]]
23+
size: Final[int]
24+
25+
def __init__(self, /, values: onp.Array1D[np.float64]) -> None: ...
26+
def get_min(self, /) -> Pair: ...
27+
def remove_min(self, /) -> None: ...
28+
def change_value(self, /, key: int, value: float) -> None: ...
29+
30+
class LinkageUnionFind(_CythonMixin):
31+
parent: Final[onp.Array1D[np.int32]]
32+
size: Final[onp.Array1D[np.int32]]
33+
next_label: int
34+
def __init__(self, /, n: int) -> None: ...
35+
36+
def calculate_cluster_sizes(Z: onp.Array2D[np.float64], cs: onp.Array1D[np.float64], n: int) -> None: ...
37+
def cluster_dist(Z: onp.Array2D[np.float64], T: onp.Array1D[np.int32], cutoff: float, n: int) -> None: ...
38+
def cluster_in(
39+
Z: onp.Array2D[np.float64], R: onp.Array2D[np.float64], T: onp.Array1D[np.int32], cutoff: float, n: int
40+
) -> None: ...
41+
def cluster_maxclust_dist(Z: onp.Array2D[np.float64], T: onp.Array1D[np.int32], n: int, mc: int) -> None: ...
42+
def cluster_maxclust_monocrit(
43+
Z: onp.Array2D[np.float64], MC: onp.Array1D[np.float64], T: onp.Array1D[np.int32], n: int, max_nc: int
44+
) -> None: ...
45+
def cluster_monocrit(
46+
Z: onp.Array2D[np.float64], MC: onp.Array1D[np.float64], T: onp.Array1D[np.int32], cutoff: float, n: int
47+
) -> None: ...
48+
def cophenetic_distances(Z: onp.Array2D[np.float64], d: onp.Array1D[np.float64], n: int) -> None: ...
49+
def get_max_Rfield_for_each_cluster(
50+
Z: onp.Array2D[np.float64], R: onp.Array2D[np.float64], max_rfs: onp.Array1D[np.float64], n: int, rf: int
51+
) -> None: ...
52+
def get_max_dist_for_each_cluster(Z: onp.Array2D[np.float64], MD: onp.Array1D[np.float64], n: int) -> None: ...
53+
def inconsistent(Z: onp.Array2D[np.float64], R: onp.Array2D[np.float64], n: int, d: float) -> None: ...
54+
def leaders(
55+
Z: onp.Array2D[np.float64], T: onp.Array1D[np.int32], L: onp.Array1D[np.int32], M: onp.Array1D[np.int32], nc: int, n: float
56+
) -> None: ...
57+
58+
#
59+
def linkage(
60+
dists: onp.Array1D[np.float64], n: np.int64 | int, method: Literal[0, 1, 2, 3, 4, 5, 6]
61+
) -> onp.Array2D[np.float64]: ...
62+
def fast_linkage(dists: onp.Array1D[np.float64], n: int, method: Literal[0, 1, 2, 3, 4, 5, 6]) -> onp.Array2D[np.float64]: ...
63+
def nn_chain(dists: onp.Array1D[np.float64], n: int, method: Literal[0, 1, 2, 3, 4, 5, 6]) -> onp.Array2D[np.float64]: ...
64+
def mst_single_linkage(dists: onp.Array1D[np.float64], n: int) -> onp.Array2D[np.float64]: ...
65+
def prelist(Z: onp.Array2D[np.float64], members: onp.Array1D[np.int32], n: int) -> None: ...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import numpy as np
2+
import optype.numpy as onp
3+
4+
def optimal_leaf_ordering(Z: onp.Array2D[np.float64], D: onp.Array2D[np.float64]) -> onp.Array2D[np.float64]: ...

scipy-stubs/cluster/_vq.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import TypeVar
2+
3+
import numpy as np
4+
import optype.numpy as onp
5+
6+
_FloatT = TypeVar("_FloatT", np.float32, np.float64)
7+
_ShapeT = TypeVar("_ShapeT", bound=tuple[int] | tuple[int, int])
8+
9+
def update_cluster_means(
10+
obs: onp.ArrayND[_FloatT, _ShapeT], labels: onp.Array1D[np.int32], nc: int
11+
) -> tuple[onp.ArrayND[_FloatT, _ShapeT], onp.Array1D[np.int32]]: ...
12+
def vq(
13+
obs: onp.ArrayND[_FloatT, tuple[int] | tuple[int, int]], codes: onp.Array2D[_FloatT]
14+
) -> tuple[onp.Array1D[np.int32], onp.Array1D[_FloatT]]: ...

0 commit comments

Comments
 (0)