Skip to content

Commit 2e1ba2e

Browse files
committed
Use Constant.log().exp() for pow with float base
directly use inner method
1 parent 3c88ce7 commit 2e1ba2e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/pyscipopt/expr.pxi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,10 @@ cdef class Expr(ExprLike):
390390
Note: base must be positive.
391391
"""
392392
if _is_number(other):
393-
base = float(other)
393+
base = <double>other
394394
if base <= 0.0:
395395
raise ValueError("Base of a**x must be positive, as expression is reformulated to scip.exp(x * scip.log(a)); got %g" % base)
396-
return exp(self * log(base))
396+
return (self * Constant(base).log()).exp()
397397
else:
398398
raise TypeError(f"Unsupported base type {type(other)} for exponentiation.")
399399

@@ -686,10 +686,10 @@ cdef class GenExpr(ExprLike):
686686
Note: base must be positive.
687687
"""
688688
if _is_number(other):
689-
base = float(other)
689+
base = <double>other
690690
if base <= 0.0:
691691
raise ValueError("Base of a**x must be positive, as expression is reformulated to scip.exp(x * scip.log(a)); got %g" % base)
692-
return exp(self * log(base))
692+
return (self * Constant(base).log()).exp()
693693
else:
694694
raise TypeError(f"Unsupported base type {type(other)} for exponentiation.")
695695

0 commit comments

Comments
 (0)