def assert_type(group, type1, type2):
    """
    Asserts that the types are the same,
    raises TypeError otherwise.
    """
    try:
        assert type1 == type2
    except Exception:
        type1 == type2
        name = group.__class__.__name__
        raise TypeError("'{0}', unmatched types for operation '{1}' != '{2}'"
            .format(name, type1, type2))
