Interchange axes and swap values axes appropriately.

        Returns
        -------
        y : same as input
358650
def swapaxes(self, axis1, axis2, copy=True):
        
        i = self._get_axis_number(axis1)
        j = self._get_axis_number(axis2)

        if i == j:
            if copy:
                return self.copy()
            return self

        mapping = {i: j, j: i}

        new_axes = (self._get_axis(mapping.get(k, k))
                    for k in range(self._AXIS_LEN))
        new_values = self.values.swapaxes(i, j)
        if copy:
            new_values = new_values.copy()

        return self._constructor(new_values, *new_axes).__finalize__(self)
536309
public static DoubleMatrix swap(DoubleMatrix x, DoubleMatrix y) {
		//NativeBlas.dswap(x.length, x.data, 0, 1, y.data, 0, 1);
		JavaBlas.rswap(x.length, x.data, 0, 1, y.data, 0, 1);
		return y;
	}
104226
def set(self, x, y, value):
        
        xBase = int(x) * self.xScale
        yBase = int(y) * self.yScale
        for xOffset in range(self.xScale):
            for yOffset in range(self.yScale):
                self.data[yBase + yOffset, xBase + xOffset] = value
1109480
def gantry_axes(cls) -> Tuple['Axis', 'Axis', 'Axis', 'Axis']:
        
        return (cls.X, cls.Y, cls.Z, cls.A)
166582
def _rolling_lstsq(x, y):
    """"""
    if x.ndim == 2:
        # Treat everything as 3d and avoid AxisError on .swapaxes(1, 2) below
        # This means an original input of:
        #     array([0., 1., 2., 3., 4., 5., 6.])
        # becomes:
        # array([[[0.],
        #         [1.],
        #         [2.],
        #         [3.]],
        #
        #        [[1.],
        #         [2.],
        #         ...
        x = x[:, :, None]
    elif x.ndim <= 1:
        raise np.AxisError("x should have ndmi >= 2")
    return np.squeeze(
        np.matmul(
            np.linalg.inv(np.matmul(x.swapaxes(1, 2), x)),
            np.matmul(x.swapaxes(1, 2), np.atleast_3d(y)),
        )
    )
712746
def translate_y(self, d):
        
        mat = numpy.array([
            [1, 0, 0, 0],
            [0, 1, 0, 0],
            [0, 0, 1, 0],
            [0, d, 0, 1]
        ])
        self.vectors = self.vectors.dot(mat)
        return self
1115265
def transform(self, y):
        
        if isinstance(y, pd.DataFrame):
            x = y.ix[:,0]
            y = y.ix[:,1]
        else:
            x = y[:,0]
            y = y[:,1]
        if self.transform_type == 'add':
            return pd.DataFrame(np.add(x, y))
        elif self.transform_type == 'sub':
            return pd.DataFrame(np.subtract(x, y))
        elif self.transform_type == 'mul':
            return pd.DataFrame(np.multiply(x, y))
        elif self.transform_type == 'div':
            return pd.DataFrame(np.divide(x, y))
        elif self.transform_type == 'rem':
            return pd.DataFrame(np.remainder(x, y))
        elif self.transform_type == 'pow':
            return pd.DataFrame(x**y)
1104495
def set(self, x, y, z):
        
        self.x = x
        self.y = y
        self.z = z

        return self
1262314
def get_right_axes(self):
        ""
        if len(self.fig.get_axes()) < 2:
            ax = self.axes.twinx()

        return self.fig.get_axes()[1]
921652
def _element_equal(x, y):
    
    if isinstance(x, _np.ndarray) or isinstance(y, _np.ndarray):
        try:
            return (abs(_np.asarray(x) - _np.asarray(y)) < 1e-5).all()
        except:
            return False
    elif isinstance(x, dict):
        return (isinstance(y, dict)
                and _element_equal(x.keys(), y.keys())
                and all(_element_equal(x[k], y[k]) for k in x.keys()))
    elif isinstance(x, float):
        return abs(x - y) < 1e-5 * (abs(x) + abs(y))
    elif isinstance(x, (list, tuple)):
        return x == y
    else:
        return bool(x == y)
1327101
def fit(self, X, y):
        
        self.X = X
        self.y = y
219958
def _transform(self, X, y):
        '''
        
        '''
        z, p, y_rle = self._rle(y)
        p = np.append(p, len(y))
        big_enough = p[1:] - p[:-1] >= self.min_length
        Xt = []

        for i in range(len(y_rle)):
            if (big_enough[i]):
                Xt.append(X[p[i]:p[i+1]])

        yt = y_rle[big_enough].tolist()
        return Xt, yt
1122971
def _swaplch(LCH):
    ""
    try: # Numpy array
        L,C,H = np.dsplit(LCH,3)
        return np.dstack((H,C,L))
    except: # Tuple
        L,C,H = LCH
        return H,C,L
1207720
def setY(self,Y,standardize=False):
        
        assert Y.shape[0]==self.N, 'CVarianceDecomposition:: Incompatible shape'
        assert Y.shape[1]==self.P, 'CVarianceDecomposition:: Incompatible shape'

        
        if standardize:
            Y=preprocess.standardize(Y)

        #check that missing values match the current structure
        assert (~(SP.isnan(Y).any(axis=1))==self.Iok).all(), 'CVarianceDecomposition:: pattern of missing values needs to match Y given at initialization'

        self.Y = Y
        self.vd.setPheno(Y)

        self.optimum = None
    
        self.cache['Sigma']   = None
        self.cache['Hessian'] = None
        self.cache['Lparams'] = None
        self.cache['paramsST']= None
35812
def axes(self):
        
        out = self._axes[:]
        if self._horizontalAxis:
            out.append(self._horizontalAxis)
        if self._verticalAxis:
            out.append(self._verticalAxis)
        return out
796075
def block_cat(self, Y0, Y1):
        

        # Axes are swapped here for similar reasons to those
        # motivating swapping in cbpdn.ConvTwoBlockCnstrnt.block_cat
        Y1sa = np.swapaxes(Y1, self.cri.axisM, -1)[..., 0]

        # If cri.Cd > 1 (multi-channel dictionary) Y0 has a singleton
        # channel axis but Y1 has a non-singleton channel axis. To make
        # it possible to concatenate Y0 and Y1, we reshape Y1 by a
        # partial ravel of axisM and axisC onto axisM.
        if self.cri.Cd > 1:
            shp = list(Y1sa.shape)
            shp[self.cri.axisM] *= shp[self.cri.axisC]
            shp[self.cri.axisC] = 1
            Y1sa = Y1sa.reshape(shp)

        return np.concatenate((Y0, Y1sa), axis=self.cri.axisM)
616503
def equal(x, y):
    
    x = BigFloat._implicit_convert(x)
    y = BigFloat._implicit_convert(y)
    return mpfr.mpfr_equal_p(x, y)