Skip to content

Commit

Permalink
fix: only convert exponent to float for numeric base and exp
Browse files Browse the repository at this point in the history
Prevents losing exactness for symbolic results while speeding up numerical results
  • Loading branch information
mgreminger committed Jan 7, 2025
1 parent 0e447db commit 771036f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion public/dimensional_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,10 @@ def custom_add_dims(*args: Expr):
return Add(*[Abs(arg) for arg in args])

def custom_pow(base: Expr, exponent: Expr):
return base**(exponent.evalf(PRECISION))
if base.is_number and exponent.is_number:
return base**(exponent.evalf(PRECISION))
else:
return base**exponent

def custom_pow_dims(dim_values: list[Expr], base: Expr, exponent: Expr):
if custom_get_dimensional_dependencies(exponent) != {}:
Expand Down

0 comments on commit 771036f

Please sign in to comment.