Skip to content

Commit fe84282

Browse files
committed
🏷️ integrate: stub the remaining private C-extension modules
1 parent fcfda4f commit fe84282

File tree

5 files changed

+205
-0
lines changed

5 files changed

+205
-0
lines changed

scipy-stubs/integrate/_dop.pyi

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from collections.abc import Callable
2+
from typing import Concatenate, Final, Never, Protocol, TypeAlias, final, type_check_only
3+
4+
import numpy as np
5+
import optype.numpy as onp
6+
import optype.numpy.compat as npc
7+
8+
_VecI32: TypeAlias = onp.Array1D[np.int32]
9+
_VecF64: TypeAlias = onp.Array1D[np.float64]
10+
11+
# (x, y) -> f
12+
_FnCallback: TypeAlias = Callable[Concatenate[float, _VecF64, ...], onp.ArrayND[npc.floating]]
13+
# (nr, xold, x, y, con, icomp[, nd]) -> irtn
14+
_FnSolOut: TypeAlias = Callable[Concatenate[int, float, float, _VecF64, _VecF64, _VecI32, ...], int]
15+
16+
@type_check_only
17+
@final
18+
class _fortran_dop(Protocol):
19+
def __call__(
20+
self,
21+
/,
22+
fcn: _FnCallback,
23+
x: float,
24+
y: _VecF64,
25+
xend: float,
26+
rtol: _VecF64,
27+
atol: _VecF64,
28+
solout: _FnSolOut,
29+
iout: int,
30+
work: _VecF64,
31+
iwork: _VecI32,
32+
fcn_extra_args: tuple[object, ...] = (),
33+
overwrite_y: onp.ToBool = 0,
34+
solout_extra_args: tuple[object, ...] = (),
35+
) -> tuple[float, _VecF64, _VecI32, int]: ... # (x, y, iwork, idid)
36+
37+
@type_check_only
38+
@final
39+
class _fortran_types(Protocol):
40+
intvar: onp.Array0D[np.int32]
41+
def __call__(self, *args: Never, **kwargs: Never) -> Never: ... # raises TypeError at runtime
42+
43+
###
44+
45+
__f2py_numpy_version__: Final[str] = ...
46+
__version__: Final[str] = ...
47+
48+
dop853: _fortran_dop = ...
49+
dopri5: _fortran_dop = ...
50+
types: _fortran_types = ...

scipy-stubs/integrate/_lsoda.pyi

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from collections.abc import Callable
2+
from typing import Concatenate, Final, Protocol, TypeAlias, final, type_check_only
3+
4+
import numpy as np
5+
import optype.numpy as onp
6+
import optype.numpy.compat as npc
7+
8+
from ._dop import types as types # same signature, so no need to redefine
9+
10+
_VecI32: TypeAlias = onp.Array1D[np.int32]
11+
_VecF64: TypeAlias = onp.Array1D[np.float64]
12+
13+
# (t, y) -> ydot
14+
_FnCallback: TypeAlias = Callable[Concatenate[float, _VecF64, ...], onp.ArrayND[npc.floating]]
15+
16+
@type_check_only
17+
@final
18+
class _fortran_lsoda(Protocol):
19+
def __call__(
20+
self,
21+
/,
22+
f: _FnCallback,
23+
y: _VecF64,
24+
t: float,
25+
tout: float,
26+
rtol: _VecF64,
27+
atol: _VecF64,
28+
itask: int,
29+
istate: int,
30+
rwork: _VecF64,
31+
iwork: _VecI32,
32+
jac: _FnCallback,
33+
jt: int,
34+
f_extra_args: tuple[object, ...] = (),
35+
overwrite_y: onp.ToBool = 0,
36+
jac_extra_args: tuple[object, ...] = (),
37+
) -> tuple[_VecF64, float, int]: ... # (y, t, istate)
38+
39+
###
40+
41+
__f2py_numpy_version__: Final[str] = ...
42+
__version__: Final[str] = ...
43+
44+
lsoda: _fortran_lsoda = ...

scipy-stubs/integrate/_odepack.pyi

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from _typeshed import Incomplete
2+
from collections.abc import Callable
3+
4+
import optype.numpy as onp
5+
6+
class error(Exception): ...
7+
8+
def odeint(
9+
fun: Callable[..., Incomplete],
10+
y0: onp.ToFloat | onp.ToFloatND,
11+
t: float,
12+
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 = ...,
21+
h0: float = 0.0,
22+
hmax: float = 0.0,
23+
hmin: float = 0.0,
24+
ixpr: float = 0.0,
25+
mxstep: float = 0.0,
26+
mxhnil: int = 0,
27+
mxordn: int = 0,
28+
mxords: int = 0,
29+
) -> tuple[Incomplete, ...]: ...

scipy-stubs/integrate/_quadpack.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class error(Exception): ...
2+
3+
# _qagie(fun, bound, inf, | args, full_output, epsabs, epsrel, limit) -> {out}
4+
# _qagse(fun, a, b, | args, full_output, epsabs, epsrel, limit) -> {out}
5+
# _qagpe(fun, a, b, points, | args, full_output, epsabs, epsrel, limit) -> {out}
6+
# _qawce(fun, a, b, c, | args, full_output, epsabs, epsrel, limit) -> {out}
7+
# _qawse(fun, a, b, (alpha, beta), integr, | args, full_output, epsabs, epsrel, limit) -> {out}
8+
# _qawfe(fun, a, omega, integr, | args, full_output, epsabs, limlst, limit, maxp1) -> {out}
9+
# _qawoe(fun, a, b, omega, integr, | args, full_output, epsabs, epsrel, limit, maxp1, icall, momcom, chebmo) -> {out}
10+
11+
# {out} := [result, abserr, infodict, ier]

scipy-stubs/integrate/_vode.pyi

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from collections.abc import Callable
2+
from typing import Concatenate, Final, Protocol, TypeAlias, final, type_check_only
3+
4+
import numpy as np
5+
import optype.numpy as onp
6+
import optype.numpy.compat as npc
7+
8+
from ._dop import types as types # same signature, so no need to redefine
9+
10+
_VecI32: TypeAlias = onp.Array1D[np.int32]
11+
_VecF64: TypeAlias = onp.Array1D[np.float64]
12+
_VecC128: TypeAlias = onp.Array1D[np.complex128]
13+
14+
# (t, y) -> ydot or jac
15+
_FnCallbackD: TypeAlias = Callable[Concatenate[float, _VecF64, ...], onp.ArrayND[npc.floating]]
16+
_FnCallbackZ: TypeAlias = Callable[Concatenate[float, _VecC128, ...], onp.ArrayND[npc.complexfloating]]
17+
18+
@type_check_only
19+
@final
20+
class _fortran_dvode(Protocol):
21+
def __call__(
22+
self,
23+
/,
24+
f: _FnCallbackD,
25+
jac: _FnCallbackD,
26+
y: _VecF64,
27+
t: float,
28+
tout: float,
29+
rtol: _VecF64,
30+
atol: _VecF64,
31+
itask: int,
32+
istate: int,
33+
rwork: _VecF64,
34+
iwork: _VecI32,
35+
mf: int,
36+
f_extra_args: tuple[object, ...] = (),
37+
jac_extra_args: tuple[object, ...] = (),
38+
overwrite_y: onp.ToBool = 0,
39+
) -> tuple[_VecF64, float, int]: ... # (y, t, istate)
40+
41+
@type_check_only
42+
@final
43+
class _fortran_zvode(Protocol):
44+
def __call__(
45+
self,
46+
/,
47+
f: _FnCallbackZ,
48+
jac: _FnCallbackZ,
49+
y: _VecC128,
50+
t: float,
51+
tout: float,
52+
rtol: _VecF64,
53+
atol: _VecF64,
54+
itask: int,
55+
istate: int,
56+
zwork: _VecC128,
57+
rwork: _VecF64,
58+
iwork: _VecI32,
59+
mf: int,
60+
f_extra_args: tuple[object, ...] = (),
61+
jac_extra_args: tuple[object, ...] = (),
62+
overwrite_y: onp.ToBool = 0,
63+
) -> tuple[_VecF64, float, int]: ... # (y, t, istate)
64+
65+
###
66+
67+
__f2py_numpy_version__: Final[str] = ...
68+
__version__: Final[str] = ...
69+
70+
dvode: _fortran_dvode = ...
71+
zvode: _fortran_zvode = ...

0 commit comments

Comments
 (0)