'Infer dimensionality from mean or covariance matrix, ensure that
mean and covariance are full vector resp. matrix.'

def _process_parameters(self, dim, mean, cov):

    if (dim is None):
        if (mean is None):
            if (cov is None):
                dim = 1
            else:
                cov = np.asarray(cov, dtype=float)
                if (cov.ndim < 2):
                    dim = 1
                else:
                    dim = cov.shape[0]
        else:
            mean = np.asarray(mean, dtype=float)
            dim = mean.size
    elif (not np.isscalar(dim)):
        raise ValueError('Dimension    of    random    variable    must    be    a    scalar.')
    if (mean is None):
        mean = np.zeros(dim)
    mean = np.asarray(mean, dtype=float)
    if (cov is None):
        cov = 1.0
    cov = np.asarray(cov, dtype=float)
    if (dim == 1):
        mean.shape = (1,)
        cov.shape = (1, 1)
    if ((mean.ndim != 1) or (mean.shape[0] != dim)):
        raise ValueError(("Array    'mean'    must    be    a    vector    of    length    %d." % dim))
    if (cov.ndim == 0):
        cov = (cov * np.eye(dim))
    elif (cov.ndim == 1):
        cov = np.diag(cov)
    elif ((cov.ndim == 2) and (cov.shape != (dim, dim))):
        (rows, cols) = cov.shape
        if (rows != cols):
            msg = ("Array    'cov'    must    be    square    if    it    is    two    dimensional,    but    cov.shape    =    %s." % str(cov.shape))
        else:
            msg = "Dimension    mismatch:    array    'cov'    is    of    shape    %s,    but    'mean'    is    a    vector    of    length    %d."
            msg = (msg % (str(cov.shape), len(mean)))
        raise ValueError(msg)
    elif (cov.ndim > 2):
        raise ValueError(("Array    'cov'    must    be    at    most    two-dimensional,    but    cov.ndim    =    %d" % cov.ndim))
    return (dim, mean, cov)
