11import os
22from collections .abc import Iterable , Mapping , Sequence
3- from typing import Any , AnyStr , ClassVar , Literal , Self , SupportsFloat , Union , overload
3+ from typing import Any , AnyStr , ClassVar , Literal , SupportsFloat , Union , overload
44
55import numpy as np
66from _typeshed import Incomplete
7- from typing_extensions import CapsuleType , disjoint_base
7+ from typing_extensions import CapsuleType , Self , disjoint_base
88
99CONST : Term
1010EventNames : dict
@@ -31,25 +31,25 @@ str_conversion: Incomplete
3131value_to_array : Incomplete
3232
3333@overload
34- def exp (x : Expr | GenExpr ) -> UnaryExpr : ...
34+ def exp (x : float | Expr | GenExpr ) -> UnaryExpr : ...
3535@overload
36- def exp (x : MatrixExpr ) -> MatrixGenExpr : ...
36+ def exp (x : list | tuple | np . ndarray | MatrixExpr ) -> MatrixGenExpr : ...
3737@overload
38- def log (x : Expr | GenExpr ) -> UnaryExpr : ...
38+ def log (x : float | Expr | GenExpr ) -> UnaryExpr : ...
3939@overload
40- def log (x : MatrixExpr ) -> MatrixGenExpr : ...
40+ def log (x : list | tuple | np . ndarray | MatrixExpr ) -> MatrixGenExpr : ...
4141@overload
42- def sqrt (x : Expr | GenExpr ) -> UnaryExpr : ...
42+ def sqrt (x : float | Expr | GenExpr ) -> UnaryExpr : ...
4343@overload
44- def sqrt (x : MatrixExpr ) -> MatrixGenExpr : ...
44+ def sqrt (x : list | tuple | np . ndarray | MatrixExpr ) -> MatrixGenExpr : ...
4545@overload
46- def sin (x : Expr | GenExpr ) -> UnaryExpr : ...
46+ def sin (x : float | Expr | GenExpr ) -> UnaryExpr : ...
4747@overload
48- def sin (x : MatrixExpr ) -> MatrixGenExpr : ...
48+ def sin (x : list | tuple | np . ndarray | MatrixExpr ) -> MatrixGenExpr : ...
4949@overload
50- def cos (x : Expr | GenExpr ) -> UnaryExpr : ...
50+ def cos (x : float | Expr | GenExpr ) -> UnaryExpr : ...
5151@overload
52- def cos (x : MatrixExpr ) -> MatrixGenExpr : ...
52+ def cos (x : list | tuple | np . ndarray | MatrixExpr ) -> MatrixGenExpr : ...
5353
5454@disjoint_base
5555class Benders :
@@ -253,7 +253,7 @@ class Constant(GenExpr):
253253 number : Incomplete
254254 def __init__ (self , * args : Incomplete , ** kwargs : Incomplete ) -> None : ...
255255 def __pow__ ( # type: ignore[override]
256- self , other : float | Constant , modulo : Incomplete = ..., /
256+ self , other : float | Constant , mod : Incomplete = ..., /
257257 ) -> Constant : ...
258258
259259@disjoint_base
@@ -409,10 +409,17 @@ class Expr(ExprLike):
409409 @overload
410410 def __truediv__ (self , other : np .ndarray | MatrixExpr , / ) -> MatrixExpr : ...
411411 def __rtruediv__ (self , other : float , / ) -> ProdExpr : ...
412+ # __pow__'s return type depends on the value of `other`:
413+ # non-negative integers (including integer-valued floats) yield Expr,
414+ # negative integers and non-integers yield PowExpr
415+ # We annotate the int case as Expr to handle the common case (e.g. x**2)
416+ # knowing it might be wrong in some cases, and likewise the float case as
417+ # PowExpr can be wrong. We aim to make the stubs useful in common cases
418+ # even though the type system cannot fully express the real types.
412419 @overload
413- def __pow__ (self , other : int , modulo : Incomplete = ..., / ) -> Expr : ...
420+ def __pow__ (self , other : int , mod : Incomplete = ..., / ) -> Expr : ...
414421 @overload
415- def __pow__ (self , other : float , module : Incomplete = ..., / ) -> PowExpr : ...
422+ def __pow__ (self , other : float , mod : Incomplete = ..., / ) -> PowExpr : ...
416423 def __rpow__ (self , other : float , / ) -> UnaryExpr : ...
417424 def __getitem__ (self , index : Incomplete , / ) -> Incomplete : ...
418425 def __iter__ (self ) -> Incomplete : ...
@@ -458,7 +465,6 @@ class GenExpr(ExprLike):
458465 @overload
459466 def __truediv__ (self , other : np .ndarray | MatrixExpr , / ) -> MatrixExpr : ...
460467 def __rtruediv__ (self , other : float , / ) -> ProdExpr : ...
461- def __ne__ (self , other : object , / ) -> bool : ...
462468 def __pow__ (self , other : float | Constant , mod : Incomplete = ..., / ) -> PowExpr : ...
463469 def __rpow__ (self , other : float , mod : Incomplete = ..., / ) -> UnaryExpr : ...
464470
0 commit comments