@@ -2248,6 +2248,7 @@ def eval(self, eqs, vars, evaluation: Evaluation):
22482248 eq_list = eqs .elements
22492249 else :
22502250 eq_list = [eqs ]
2251+ sympy_conditions = []
22512252 sympy_eqs = []
22522253 sympy_denoms = []
22532254 for eq in eq_list :
@@ -2256,8 +2257,7 @@ def eval(self, eqs, vars, evaluation: Evaluation):
22562257 elif eq is SymbolFalse :
22572258 return ListExpression ()
22582259 elif not eq .has_form ("Equal" , 2 ):
2259- evaluation .message ("Solve" , "eqf" , eqs )
2260- return
2260+ sympy_conditions .append (eq .to_sympy ())
22612261 else :
22622262 left , right = eq .elements
22632263 left = left .to_sympy ()
@@ -2271,6 +2271,10 @@ def eval(self, eqs, vars, evaluation: Evaluation):
22712271 numer , denom = eq .as_numer_denom ()
22722272 sympy_denoms .append (denom )
22732273
2274+ if not sympy_eqs :
2275+ evaluation .message ("Solve" , "eqf" , eqs )
2276+ return
2277+
22742278 vars_sympy = [var .to_sympy () for var in vars ]
22752279 if None in vars_sympy :
22762280 return
@@ -2335,6 +2339,10 @@ def transform_solution(sol):
23352339 for sol in result :
23362340 results .extend (transform_solution (sol ))
23372341 result = results
2342+ # filter with conditions before further translation
2343+ conditions = sympy .And (* sympy_conditions )
2344+ result = [sol for sol in result if conditions .subs (sol )]
2345+
23382346 if any (
23392347 sol and any (var not in sol for var in all_vars_sympy ) for sol in result
23402348 ):
0 commit comments