Skip to content

Commit 74479b4

Browse files
authored
integrate: improve the odeint signature (#763)
2 parents 7cbc2b6 + 5346bcb commit 74479b4

File tree

4 files changed

+236
-148
lines changed

4 files changed

+236
-148
lines changed

scipy-stubs/integrate/_odepack.pyi

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,77 @@
1-
from _typeshed import Incomplete
1+
# defined in scipy/integrate/_odepackmodule.c
2+
23
from collections.abc import Callable
4+
from typing import Literal, TypedDict, overload, type_check_only
35

6+
import numpy as np
47
import optype.numpy as onp
58

69
class error(Exception): ...
710

11+
@type_check_only
12+
class _InfoDict(TypedDict):
13+
hu: onp.Array1D[np.float64]
14+
tcur: onp.Array1D[np.float64]
15+
tolsf: onp.Array1D[np.float64]
16+
tsw: onp.Array1D[np.float64]
17+
nst: onp.Array1D[np.int32]
18+
nfe: onp.Array1D[np.int32]
19+
nje: onp.Array1D[np.int32]
20+
nqu: onp.Array1D[np.int32]
21+
imxer: int
22+
lenrw: int
23+
leniw: int
24+
mused: onp.Array1D[np.int32]
25+
26+
###
27+
28+
# NOTE: This (private) `odeint` differs from the one in `_odepack_py` because it
29+
# doesn't have a `printmessg` kwarg, and has a different return type.
30+
@overload
831
def odeint(
9-
fun: Callable[..., Incomplete],
10-
y0: onp.ToFloat | onp.ToFloatND,
11-
t: float,
32+
fun: Callable[..., onp.ToFloat1D | float],
33+
y0: onp.ToFloatND | float,
34+
t: onp.ToFloat1D,
1235
args: tuple[object, ...] = (),
13-
Dfun: Callable[..., Incomplete] | None = None,
14-
col_deriv: int = 0,
15-
ml: int = ...,
16-
mu: int = ...,
17-
full_output: onp.ToBool = 0,
18-
rtol: float = ...,
19-
atol: float = ...,
20-
tcrit: float = ...,
36+
Dfun: Callable[..., onp.ToFloat2D] | None = None,
37+
col_deriv: onp.ToBool = 0,
38+
ml: int = -1,
39+
mu: int = -1,
40+
full_output: Literal[0, False] = 0,
41+
rtol: float | None = None,
42+
atol: float | None = None,
43+
tcrit: onp.ToFloat1D | None = None,
44+
h0: float = 0.0,
45+
hmax: float = 0.0,
46+
hmin: float = 0.0,
47+
ixpr: onp.ToBool = 0,
48+
mxstep: int = 0,
49+
mxhnil: int = 0,
50+
mxordn: int = 12,
51+
mxords: int = 5,
52+
tfirst: int = 0,
53+
) -> tuple[onp.Array2D[np.float64], int]: ...
54+
@overload
55+
def odeint(
56+
fun: Callable[..., onp.ToFloat1D | float],
57+
y0: onp.ToFloatND | float,
58+
t: onp.ToFloat1D,
59+
args: tuple[object, ...],
60+
Dfun: Callable[..., onp.ToFloat2D] | None,
61+
col_deriv: onp.ToBool,
62+
ml: int,
63+
mu: int,
64+
full_output: Literal[True, 1],
65+
rtol: float | None = None,
66+
atol: float | None = None,
67+
tcrit: onp.ToFloat1D | None = None,
2168
h0: float = 0.0,
2269
hmax: float = 0.0,
2370
hmin: float = 0.0,
24-
ixpr: float = 0.0,
25-
mxstep: float = 0.0,
71+
ixpr: onp.ToBool = 0,
72+
mxstep: int = 0,
2673
mxhnil: int = 0,
27-
mxordn: int = 0,
28-
mxords: int = 0,
29-
) -> tuple[Incomplete, ...]: ...
74+
mxordn: int = 12,
75+
mxords: int = 5,
76+
tfirst: int = 0,
77+
) -> tuple[onp.Array2D[np.float64], _InfoDict, int]: ...

0 commit comments

Comments
 (0)