Skip to content

Commit 5997a25

Browse files
authored
Merge pull request #227 from jorenham/optimize.quadratic_assignment
✨ complete `optimize.quadratic_assignment`
2 parents 565410f + 15841d5 commit 5997a25

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

scipy-stubs/optimize/_qap.pyi

+42-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
1-
from typing import Final
1+
from typing import Final, Literal, TypedDict, overload, type_check_only
22

3-
from scipy._typing import Untyped
3+
import numpy as np
4+
import optype.numpy as onp
5+
from ._optimize import OptimizeResult as _OptimizeResult
6+
7+
@type_check_only
8+
class _CommonOptions(TypedDict, total=False):
9+
maximize: onp.ToBool
10+
rng: onp.ToJustInt | np.random.Generator | np.random.RandomState | None
11+
partial_match: onp.ToInt2D | None
12+
13+
@type_check_only
14+
class _FAQOptions(_CommonOptions, TypedDict, total=False):
15+
P0: onp.ToFloat2D | Literal["barycenter", "randomized"]
16+
shuffle: onp.ToBool
17+
maxiter: onp.ToJustInt
18+
tol: onp.ToFloat
19+
20+
@type_check_only
21+
class _2OptOptions(_CommonOptions, TypedDict, total=False):
22+
partial_guess: onp.ToInt2D | None
23+
24+
###
425

526
QUADRATIC_ASSIGNMENT_METHODS: Final = ["faq", "2opt"]
627

7-
def quadratic_assignment(A: Untyped, B: Untyped, method: str = "faq", options: Untyped | None = None) -> Untyped: ...
28+
class OptimizeResult(_OptimizeResult):
29+
col_ind: onp.Array1D[np.intp]
30+
fun: float | np.float64
31+
nit: int
32+
33+
@overload
34+
def quadratic_assignment(
35+
A: onp.ToFloat2D,
36+
B: onp.ToFloat2D,
37+
method: Literal["faq"] = "faq",
38+
options: _FAQOptions | None = None,
39+
) -> OptimizeResult: ...
40+
@overload
41+
def quadratic_assignment(
42+
A: onp.ToFloat2D,
43+
B: onp.ToFloat2D,
44+
method: Literal["2opt"],
45+
options: _2OptOptions | None = None,
46+
) -> OptimizeResult: ...

0 commit comments

Comments
 (0)