def assert_type(objects, types, raise_error=False):
    """Assert object(s) from allowed types (instances).

    Parameters
    ----------
    objects :
        Single object or a list of objects
    types :
        Single type or a list of types.
    raise_error :
        Whether to raise error.
    Return:
    ----------
    Return boolean value if raise_error=False.
    """
    if not isinstance(objects, list):
        objects = [objects]
    if not isinstance(types, list):
        types = [types]
    for object in objects:
        if not any([isinstance(object, type) for type in types]):
            if raise_error:
                raise ValueError(
                    'Invalid input data type. List of allowed types: {}. Got {} instead'
                    .format(str(types)[1:-1], type(object)))
            else:
                return False
    return True
