(self, y, bounds=None, copy_never=False, copy_always=False)
return y
Argument `y` is a phenotypic vector,
        return `y` put into boundaries, as a copy iff ``y != into_bounds(y)``.

        Note: this code is duplicated in `Solution.repair` and might
        disappear in future.
Argument `y` is a phenotypic vector,
        return `y` put into boundaries, as a copy iff ``y != into_bounds(y)``.
Argument y is a phenotypic vector return y put into boundaries as a copy iff y ! = into_bounds ( y ) .
def into_bounds(self, y, bounds=None, copy_never=False, copy_always=False):
        """Argument `y` is a phenotypic vector,
        return `y` put into boundaries, as a copy iff ``y != into_bounds(y)``.

        Note: this code is duplicated in `Solution.repair` and might
        disappear in future.

        """
        bounds = bounds if bounds is not None else self.bounds
        if bounds in (None, [None, None]):
            return y if not copy_always else array(y, copy=True)
        if bounds[0] is not None:
            if len(bounds[0]) not in (1, len(y)):
                raise ValueError('len(bounds[0]) = ' + str(len(bounds[0])) +
                                 ' and len of initial solution (' + str(len(y)) + ') disagree')
            if copy_never:  # is rather slower
                for i in xrange(len(y)):
                    y[i] = max(bounds[0][i], y[i])
            else:
                y = np.max([bounds[0], y], axis=0)
        if bounds[1] is not None:
            if len(bounds[1]) not in (1, len(y)):
                raise ValueError('len(bounds[1]) = ' + str(len(bounds[1])) +
                                    ' and initial solution (' + str(len(y)) + ') disagree')
            if copy_never:
                for i in xrange(len(y)):
                    y[i] = min(bounds[1][i], y[i])
            else:
                y = np.min([bounds[1], y], axis=0)
        return y
def into_bounds ( self , y , bounds = None , copy_never = False , copy_always = False ) : bounds = bounds if bounds is not None else self . bounds if bounds in ( None , [ None , None ] ) : return y if not copy_always else array ( y , copy = True ) if bounds [ 0 ] is not None : if len ( bounds [ 0 ] ) not in ( 1 , len ( y ) ) : raise ValueError ( 'len(bounds[0]) = ' + str ( len ( bounds [ 0 ] ) ) + ' and len of initial solution (' + str ( len ( y ) ) + ') disagree' ) if copy_never : # is rather slower for i in xrange ( len ( y ) ) : y [ i ] = max ( bounds [ 0 ] [ i ] , y [ i ] ) else : y = np . max ( [ bounds [ 0 ] , y ] , axis = 0 ) if bounds [ 1 ] is not None : if len ( bounds [ 1 ] ) not in ( 1 , len ( y ) ) : raise ValueError ( 'len(bounds[1]) = ' + str ( len ( bounds [ 1 ] ) ) + ' and initial solution (' + str ( len ( y ) ) + ') disagree' ) if copy_never : for i in xrange ( len ( y ) ) : y [ i ] = min ( bounds [ 1 ] [ i ] , y [ i ] ) else : y = np . min ( [ bounds [ 1 ] , y ] , axis = 0 ) return y