Skip to content

Commit

Permalink
Comment use of cast
Browse files Browse the repository at this point in the history
  • Loading branch information
davidar committed Oct 28, 2024
1 parent 6488552 commit c2aa901
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mathics/core/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def get_mpmath_function(self, args):
def eval(self, z, evaluation: Evaluation):
"%(name)s[z__]"

args = cast(Sequence[Number], numerify(z, evaluation).get_sequence())
args = numerify(z, evaluation).get_sequence()

# if no arguments are inexact attempt to use sympy
if all(not x.is_inexact() for x in args):
Expand All @@ -668,6 +668,8 @@ def eval(self, z, evaluation: Evaluation):

if not all(isinstance(arg, Number) for arg in args):
return
# mypy isn't yet smart enough to recognise that we can only reach this point if all args are Numbers
args = cast(Sequence[Number], args)

mpmath_function = self.get_mpmath_function(tuple(args))
if mpmath_function is None:
Expand All @@ -680,7 +682,9 @@ def eval(self, z, evaluation: Evaluation):
d = dps(prec)
args = tuple([arg.round(d) for arg in args])

return eval_mpmath_function(mpmath_function, *args, prec=prec)
return eval_mpmath_function(
mpmath_function, *cast(Sequence[Number], args), prec=prec
)


class MPMathMultiFunction(MPMathFunction):
Expand Down

0 comments on commit c2aa901

Please sign in to comment.