def transform(self, X):
        """Transform each time series into a recurrence plot.

        Parameters
        ----------
        X : array-like, shape = (n_samples, n_timestamps)

        Returns
        -------
        X_new : array, shape = (n_samples, image_size, image_size)
            Recurrence plots. ``image_size`` is the number of
            trajectories and is equal to
            ``n_timestamps - (dimension - 1) * time_delay``.
            If ``flatten=True``, the shape is
            `(n_samples, image_size * image_size)`.

        """
        X = check_array(X)
        n_samples, n_timestamps = X.shape
        dimension, time_delay = self._check_params(n_timestamps)

        if dimension == 1:
            X_dist = np.abs(X[:, :, None] - X[:, None, :])
        else:
            X_traj = _trajectories(X, dimension, time_delay)
            X_dist = np.sqrt(
                np.sum((X_traj[:, None, :, :] - X_traj[:, :, None, :]) ** 2,
                       axis=3)
            )
        if self.threshold is None:
            X_rp = X_dist
        elif self.threshold == 'point':
            image_size = n_timestamps - (dimension - 1) * time_delay
            percents = np.percentile(
                np.reshape(X_dist, (n_samples, image_size * image_size)),
                self.percentage, axis=1
            )
            X_rp = X_dist < percents[:, None, None]
        elif self.threshold == 'distance':
            percents = self.percentage / 100 * np.max(X_dist, axis=(1, 2))
            X_rp = X_dist < percents[:, None, None]
        else:
            X_rp = X_dist < self.threshold

        if self.flatten:
            return X_rp.reshape(n_samples, -1).astype('float64')
        return X_rp.astype('float64')
Transform each time series into a recurrence plot.

        Parameters
        ----------
        X : array-like, shape = (n_samples, n_timestamps)

        Returns
        -------
        X_new : array, shape = (n_samples, image_size, image_size)
            Recurrence plots. ``image_size`` is the number of
            trajectories and is equal to
            ``n_timestamps - (dimension - 1) * time_delay``.
            If ``flatten=True``, the shape is
            `(n_samples, image_size * image_size)`.

        
pyts/image/recurrence.py