'Adjust quantiles array so that last axis labels the components of
each data point.'

def _process_quantiles(self, x, dim):

    x = np.asarray(x, dtype=float)
    if (x.ndim == 0):
        x = (x * np.eye(dim)[:, :, np.newaxis])
    if (x.ndim == 1):
        if (dim == 1):
            x = x[np.newaxis, np.newaxis, :]
        else:
            x = np.diag(x)[:, :, np.newaxis]
    elif (x.ndim == 2):
        if (not (x.shape[0] == x.shape[1])):
            raise ValueError(('Quantiles    must    be    square    if    they    are    two    dimensional,    but    x.shape    =    %s.' % str(x.shape)))
        x = x[:, :, np.newaxis]
    elif (x.ndim == 3):
        if (not (x.shape[0] == x.shape[1])):
            raise ValueError(('Quantiles    must    be    square    in    the    first    two    dimensions    if    they    are    three    dimensional,    but    x.shape    =    %s.' % str(x.shape)))
    elif (x.ndim > 3):
        raise ValueError(('Quantiles    must    be    at    most    two-dimensional    with    an    additional    dimension    for    multiplecomponents,    but    x.ndim    =    %d' % x.ndim))
    if (not (x.shape[0:2] == (dim, dim))):
        raise ValueError(('Quantiles    have    incompatible    dimensions:    should    be    %s,    got    %s.' % ((dim, dim), x.shape[0:2])))
    return x
