'sets out-of-bounds components of ``x`` on the bounds.
Arguments
`bounds`
can be `None`, in which case the "default" bounds are used,
or ``[lb, ub]``, where `lb` and `ub`
represent lower and upper domain bounds respectively that
can be `None` or a scalar or a list or array of length ``len(self)``
code is more or less copy-paste from Solution.repair, but never tested'

def repair(self, x, bounds=None, copy=False, copy_always=False):

    if (bounds is None):
        bounds = self.bounds
    if copy_always:
        x_out = array(x, copy=True)
    if (bounds not in (None, [None, None], (None, None))):
        x_out = (array(x, copy=True) if (copy and (not copy_always)) else x)
        if (bounds[0] is not None):
            if np.isscalar(bounds[0]):
                for i in xrange(len(x)):
                    x_out[i] = max([bounds[0], x[i]])
            else:
                for i in xrange(len(x)):
                    if (bounds[0][i] is not None):
                        x_out[i] = max([bounds[0][i], x[i]])
        if (bounds[1] is not None):
            if np.isscalar(bounds[1]):
                for i in xrange(len(x)):
                    x_out[i] = min([bounds[1], x[i]])
            else:
                for i in xrange(len(x)):
                    if (bounds[1][i] is not None):
                        x_out[i] = min([bounds[1][i], x[i]])
    return x_out
