Prior to this change, symbolics.prod only accepted SymbolicInt arguments and returned SymbolicInt. Now, it also accepts SymbolicFloat to return SymbolicFloat.
The function also now accepts an iterator rather than being variadic, matching the interface of built-in sum.
This goal is achieved via a new type variable SymbolicT. There does not seem to be a correct approach using @overload instead due to limitations of mypy, which does not consider float | Expr and int | Expr to be two valid overloads for a function since int is automatically promoted to float.
Prior to this change,
symbolics.prod
only acceptedSymbolicInt
arguments and returnedSymbolicInt
. Now, it also acceptsSymbolicFloat
to returnSymbolicFloat
.The function also now accepts an iterator rather than being variadic, matching the interface of built-in
sum
.This goal is achieved via a new type variable
SymbolicT
. There does not seem to be a correct approach using@overload
instead due to limitations of mypy, which does not considerfloat | Expr
andint | Expr
to be two valid overloads for a function sinceint
is automatically promoted tofloat
.