def monomial_key(order=None, gens=None):
 if (order is None):
  order = lex
 if isinstance(order, Symbol):
  order = str(order)
 if isinstance(order, str):
  try:
   order = _monomial_key[order]
  except KeyError:
   raise ValueError(("supported monomial orderings are 'lex', 'grlex' and 'grevlex', got %r" % order))
 if hasattr(order, '__call__'):
  if (gens is not None):
   def _order(expr):
    return order(expr.as_poly(*gens).degree_list())
   return _order
  return order
 else:
  raise ValueError(('monomial ordering specification must be a string or a callable, got %s' % order))

def monomial_key ( order = None , gens = None ) : if ( order is None ) : order = lex if isinstance ( order , Symbol ) : order = str ( order ) if isinstance ( order , str ) : try : order = _monomial_key [ order ] except KeyError : raise ValueError ( ( "supported monomial orderings are 'lex', 'grlex' and 'grevlex', got %r" % order ) ) if hasattr ( order , '__call__' ) : if ( gens is not None ) : def _order ( expr ) : return order ( expr . as_poly ( * gens ) . degree_list ( ) ) return _order return order else : raise ValueError ( ( 'monomial ordering specification must be a string or a callable, got %s' % order ) )
return a function defining admissible order on monomials .