def fit(self, X=None, u=None, s=None):
        """Fit X into an embedded space.
        Inputs
        ----------
        X : array, shape (n_samples, n_features)
        u,s,v : svd decomposition of X (optional)

        Assigns
        ----------
        embedding : array-like, shape (n_samples, n_components)
            Stores the embedding vectors.
        u,sv,v : singular value decomposition of data S, potentially with smoothing
        isort1 : sorting along first dimension of matrix
        isort2 : sorting along second dimension of matrix (if n_Y > 0)
        cmap: correlation of each item with all locations in the embedding map (before upsampling)
        A:    PC coefficients of each Fourier mode

        """
        if self.mode is 'parallel':
            #X = X.copy()
            X = np.reshape(X, (-1, X.shape[-1]))
        else:
            X = X.copy()
        if ((u is None)):
            # compute svd and keep iPC's of data
            X -= np.mean(X, axis=0)
            nmin = min([X.shape[0], X.shape[1]])
            nmin = np.minimum(nmin, self.nPC)
            print("nmin %d"%nmin)
            u,sv,v = svdecon(X, k=nmin)
            u = u * sv
            self.v = v
        self.u = u

        NN, self.nPC = u.shape
        if self.constraints==3:
            plaw = 1/(1+np.arange(1000))**(self.alpha/2)
            self.vscale = np.sum(u**2,axis=0)**.5
            tail = self.vscale[-1] * plaw[u.shape[1]:]/plaw[u.shape[1]]
            self.vscale = np.hstack((self.vscale, tail))
        # first smooth in Y (if n_Y > 0)

        if self.mode is 'parallel':
            NN = int(X.shape[0]/2)
            u = np.reshape(u, (2, NN, u.shape[1]))

        nclust = self.n_X
        if self.init == 'pca':
            if self.mode is 'parallel':
                usort = u[0] * np.sign(skew(u[0], axis=0))
            else:
                usort = u * np.sign(skew(u, axis=0))
        elif self.init == 'random':
            init_sort = np.random.permutation(NN)[:,np.newaxis]
            for j in range(1,self.n_components):
                init_sort = np.concatenate((init_sort, np.random.permutation(NN)[:,np.newaxis]), axis=-1)
            xid = np.zeros(NN)
            for j in range(self.n_components):
                iclust = np.floor(nclust * init_sort[:,j].astype(np.float64)/NN)
                xid = nclust * xid + iclust
        elif self.init =='laplacian':
            Uz = zscore(u, axis=1)/u.shape[1]**.5
            CC = Uz @ Uz.T
            CCsort = np.sort(CC, axis=0)[::-1, :]
            CC[CC<CCsort[100, :]] = 0
            CC = (CC + CC.T)/2
            Ds = 1. - CC
            W = np.diag(np.sum(Ds, axis=1)) - Ds
            usort = svdecon(W, k=2)[0]
            usort = usort * np.sign(skew(usort, axis=0))
        else:
            init_sort = self.init
            xid = np.zeros(NN)
            for j in range(self.n_components):
                iclust = np.floor(nclust * init_sort[:,j].astype(np.float64)/NN)
                xid = nclust * xid + iclust

        if self.init=='pca' or self.init=='laplacian':
            init_sort = np.argsort(usort[:, :self.n_components], axis=0)
            xid = np.zeros(NN)
            for j in range(self.n_components):
                iclust = np.floor(nclust * init_sort[:,j].astype(np.float64)/NN)
                xid = nclust * xid + iclust

        xid = xid.astype('int').flatten()

        #self.init_sort = usort

        if self.n_components==1 and init_sort.ndim==1:
            init_sort = init_sort[:,np.newaxis]

        # now sort in X
        isort1, iclustup = self._map(u.copy(), self.n_components, self.n_X, xid, s)
        self.isort = isort1
        self.embedding = iclustup
        return self
Fit X into an embedded space.
        Inputs
        ----------
        X : array, shape (n_samples, n_features)
        u,s,v : svd decomposition of X (optional)

        Assigns
        ----------
        embedding : array-like, shape (n_samples, n_components)
            Stores the embedding vectors.
        u,sv,v : singular value decomposition of data S, potentially with smoothing
        isort1 : sorting along first dimension of matrix
        isort2 : sorting along second dimension of matrix (if n_Y > 0)
        cmap: correlation of each item with all locations in the embedding map (before upsampling)
        A:    PC coefficients of each Fourier mode