'Convert ``element`` to ``self.dtype``.'

def convert(self, element, base=None):

    if (base is not None):
        return self.convert_from(element, base)
    if self.of_type(element):
        return element
    from sympy.polys.domains import PythonIntegerRing, GMPYIntegerRing, GMPYRationalField, RealField, ComplexField
    if isinstance(element, integer_types):
        return self.convert_from(element, PythonIntegerRing())
    if HAS_GMPY:
        integers = GMPYIntegerRing()
        if isinstance(element, integers.tp):
            return self.convert_from(element, integers)
        rationals = GMPYRationalField()
        if isinstance(element, rationals.tp):
            return self.convert_from(element, rationals)
    if isinstance(element, float):
        parent = RealField(tol=False)
        return self.convert_from(parent(element), parent)
    if isinstance(element, complex):
        parent = ComplexField(tol=False)
        return self.convert_from(parent(element), parent)
    if isinstance(element, DomainElement):
        return self.convert_from(element, element.parent())
    if (self.is_Numerical and getattr(element, 'is_ground', False)):
        return self.convert(element.LC())
    if isinstance(element, Basic):
        try:
            return self.from_sympy(element)
        except (TypeError, ValueError):
            pass
    elif (not is_sequence(element)):
        try:
            element = sympify(element)
            if isinstance(element, Basic):
                return self.from_sympy(element)
        except (TypeError, ValueError):
            pass
    raise CoercionFailed(("can't    convert    %s    of    type    %s    to    %s" % (element, type(element), self)))
