'Returns degree of ``f`` in ``x_j``.
The degree of 0 is negative infinity.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x, y
>>> Poly(x**2 + y*x + 1, x, y).degree()
2
>>> Poly(x**2 + y*x + y, x, y).degree(y)
1
>>> Poly(0, x).degree()
-oo'

def degree(f, gen=0):

    j = f._gen_to_level(gen)
    if hasattr(f.rep, 'degree'):
        return f.rep.degree(j)
    else:
        raise OperationNotSupported(f, 'degree')
