def _solve_inequality(ie, s):
 expr = (ie.lhs - ie.rhs)
 try:
  p = Poly(expr, s)
  if (p.degree() != 1):
   raise NotImplementedError
 except (PolynomialError, NotImplementedError):
  try:
   return reduce_rational_inequalities([[ie]], s)
  except PolynomialError:
   return solve_univariate_inequality(ie, s)
 (a, b) = p.all_coeffs()
 if (a.is_positive or (ie.rel_op in ('!=', '=='))):
  return ie.func(s, ((- b) / a))
 elif a.is_negative:
  return ie.reversed.func(s, ((- b) / a))
 else:
  raise NotImplementedError

def _solve_inequality ( ie , s ) : expr = ( ie . lhs - ie . rhs ) try : p = Poly ( expr , s ) if ( p . degree ( ) != 1 ) : raise NotImplementedError except ( PolynomialError , NotImplementedError ) : try : return reduce_rational_inequalities ( [ [ ie ] ] , s ) except PolynomialError : return solve_univariate_inequality ( ie , s ) ( a , b ) = p . all_coeffs ( ) if ( a . is_positive or ( ie . rel_op in ( '!=' , '==' ) ) ) : return ie . func ( s , ( ( - b ) / a ) ) elif a . is_negative : return ie . reversed . func ( s , ( ( - b ) / a ) ) else : raise NotImplementedError
a hacky replacement for solve .