Skip to content

Commit

Permalink
refactor: bind placeholder functions after substituting implicit para…
Browse files Browse the repository at this point in the history
…meters

Will make functions that are challenging to compute symbolically faster (inv, det, etc.)
  • Loading branch information
mgreminger committed Jul 10, 2023
1 parent c0d29a1 commit 970dea3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/dimensional_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,8 @@ def get_result(exponents: list[Exponent | ExponentName],
else:
dim, dim_latex = dimensional_analysis(dimensional_analysis_subs, expression)

expression = replace_placeholder_funcs(expression)
expression = cast(Expr, expression.xreplace(parameter_subs))
expression = replace_placeholder_funcs(expression)
evaluated_expression = cast(ExprWithAssumptions, expression.evalf(PRECISION))
symbolic_expression = custom_latex(cancel(expression))
if evaluated_expression.is_number:
Expand Down Expand Up @@ -1297,9 +1297,11 @@ def evaluate_statements(statements: list[InputAndSystemStatement]) -> tuple[list
exponent_dimensionless[exponent_name+current_function_name] = True
else:
exponent_dimensionless[exponent_name+current_function_name] = False
final_expression: Expr = replace_placeholder_funcs(final_expression)

final_expression = cast(Expr, cast(Expr, final_expression).xreplace(parameter_subs))
final_expression = replace_placeholder_funcs(final_expression)

exponent_subs[symbols(exponent_name+current_function_name)] = cast(Expr, final_expression.xreplace(parameter_subs))
exponent_subs[symbols(exponent_name+current_function_name)] = final_expression

elif is_function:
while(True):
Expand Down

0 comments on commit 970dea3

Please sign in to comment.