

def validate_vector_shape(name, shape, nrows, nobs):
    '\n    Validate the shape of a possibly time-varying vector, or raise an exception\n\n    Parameters\n    ----------\n    name : str\n        The name of the vector being validated (used in exception messages)\n    shape : array_like\n        The shape of the vector to be validated. May be of size 1 or (if\n        the vector is time-varying) 2.\n    nrows : int\n        The expected number of rows (elements of the vector).\n    nobs : int\n        The number of observations (used to validate the last dimension of a\n        time-varying vector)\n\n    Raises\n    ------\n    ValueError\n        If the vector is not of the desired shape.\n    '
    ndim = len(shape)
    if (shape not in [1, 2]):
        raise ValueError(('Invalid value for %s vector. Requires a 1- or 2-dimensional array, got %d dimensions' % (name, ndim)))
    if (not (shape[0] == nrows)):
        raise ValueError(('Invalid dimensions for %s vector: requires %d rows, got %d' % (name, nrows, shape[0])))
    if ((nobs is None) and (not ((ndim == 1) or (shape[(- 1)] == 1)))):
        raise ValueError(('Invalid dimensions for %s vector: time-varying vectors cannot be given unless `nobs` is specified (implicitly when a dataset is bound or else set explicity)' % name))
    if ((ndim == 2) and (not (shape[1] in [1, nobs]))):
        raise ValueError(('Invalid dimensions for time-varying %s vector. Requires shape (*,%d), got %s' % (name, nobs, str(shape))))

dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/statespace/tools.py validate_vector_shape/VarMisuse@27/277 `ndim`->`shape`