refined tool use
This commit is contained in:
@@ -58,8 +58,21 @@ def solve_multi_equation(equations, variables):
|
||||
|
||||
# solutionpairs = [f"{variable}={value.doit()}" for variable, value in zip(variables, list(solution)[0])]
|
||||
|
||||
return "solved equation system for " + ", ".join(solutionpairs[:-1]) + " and " + solutionpairs[-1]
|
||||
# return "solved equation system for " + ", ".join(solutionpairs[:-1]) + " and " + solutionpairs[-1]
|
||||
|
||||
if len(equations) > 1:
|
||||
leadin = "Solved equation system "
|
||||
else:
|
||||
leadin = "Solved equation "
|
||||
return leadin + _natural_join([_pretty_equation(e) for e in equations]) + " for " + _natural_join(solutionpairs) + "."
|
||||
|
||||
def _natural_join(data: list[any], joiner=", ", last=" and "):
|
||||
if len(data) > 1:
|
||||
return joiner.join(data[:-1]) + last + data[-1]
|
||||
return last.join(data)
|
||||
|
||||
def _pretty_equation(simpy_Eq) -> str:
|
||||
return f"{simpy_Eq.lhs} = {simpy_Eq.rhs}"
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user