def isArray(v, N=None):
    """Check if v is an array or a vector, with optional size.

    Examples
    --------
    >>> import pygimli as pg
    >>> print(pg.isArray([0, 1]))
    True
    >>> print(pg.isArray(np.array(5)))
    True
    >>> print(pg.isArray(pg.Vector(5)))
    True
    >>> print(pg.isArray(pg.Vector(5), N=5))
    True
    >>> print(pg.isArray(pg.Vector(5), N=2))
    False
    >>> print(pg.isArray('foo'))
    False
    """
    if N is None:
        return hasattr(v, '__iter__') and not isinstance(v, (str))

    return isArray(v) and len(v) == N