'Construct a polynomial from a polynomial.'

@classmethod
def _from_poly(cls, rep, opt):

    if (cls != rep.__class__):
        rep = cls.new(rep.rep, *rep.gens)
    gens = opt.gens
    field = opt.field
    domain = opt.domain
    if (gens and (rep.gens != gens)):
        if (set(rep.gens) != set(gens)):
            return cls._from_expr(rep.as_expr(), opt)
        else:
            rep = rep.reorder(*gens)
    if (('domain' in opt) and domain):
        rep = rep.set_domain(domain)
    elif (field is True):
        rep = rep.to_field()
    return rep
