@@ -2246,6 +2246,7 @@ def eval(self, eqs, vars, evaluation: Evaluation):
22462246 eq_list = eqs .elements
22472247 else :
22482248 eq_list = [eqs ]
2249+ sympy_conditions = []
22492250 sympy_eqs = []
22502251 sympy_denoms = []
22512252 for eq in eq_list :
@@ -2254,8 +2255,7 @@ def eval(self, eqs, vars, evaluation: Evaluation):
22542255 elif eq is SymbolFalse :
22552256 return ListExpression ()
22562257 elif not eq .has_form ("Equal" , 2 ):
2257- evaluation .message ("Solve" , "eqf" , eqs )
2258- return
2258+ sympy_conditions .append (eq .to_sympy ())
22592259 else :
22602260 left , right = eq .elements
22612261 left = left .to_sympy ()
@@ -2269,6 +2269,10 @@ def eval(self, eqs, vars, evaluation: Evaluation):
22692269 numer , denom = eq .as_numer_denom ()
22702270 sympy_denoms .append (denom )
22712271
2272+ if not sympy_eqs :
2273+ evaluation .message ("Solve" , "eqf" , eqs )
2274+ return
2275+
22722276 vars_sympy = [var .to_sympy () for var in vars ]
22732277 if None in vars_sympy :
22742278 return
@@ -2333,6 +2337,10 @@ def transform_solution(sol):
23332337 for sol in result :
23342338 results .extend (transform_solution (sol ))
23352339 result = results
2340+ # filter with conditions before further translation
2341+ conditions = sympy .And (* sympy_conditions )
2342+ result = [sol for sol in result if conditions .subs (sol )]
2343+
23362344 if any (
23372345 sol and any (var not in sol for var in all_vars_sympy ) for sol in result
23382346 ):
0 commit comments