def _preprocess_data(self, data):
        """Converts a data array to the preferred 3D structure.

        Parameters
        ----------
        data : :obj:`numpy.ndarray`
            The data to process.

        Returns
        -------
        :obj:`numpy.ndarray`
            The data re-formatted (if needed) as a 3D matrix

        Raises
        ------
        ValueError
            If the data is not 1, 2, or 3D to begin with.
        """
        original_type = data.dtype
        if len(data.shape) == 1:
            data = data[:, np.newaxis, np.newaxis]
        elif len(data.shape) == 2:
            data = data[:, :, np.newaxis]
        elif len(data.shape) == 0 or len(data.shape) > 3:
            raise ValueError(
                'Illegal data array passed to image. Must be 1, 2, or 3 dimensional numpy array')
        return data.astype(original_type)
def _preprocess_data ( self , data ) : original_type = data . dtype if len ( data . shape ) == 1 : data = data [ : , np . newaxis , np . newaxis ] elif len ( data . shape ) == 2 : data = data [ : , : , np . newaxis ] elif len ( data . shape ) == 0 or len ( data . shape ) > 3 : raise ValueError ( 'Illegal data array passed to image. Must be 1, 2, or 3 dimensional numpy array' ) return data . astype ( original_type )
Converts a data array to the preferred 3D structure.

        Parameters
        ----------
        data : :obj:`numpy.ndarray`
            The data to process.

        Returns
        -------
        :obj:`numpy.ndarray`
            The data re-formatted (if needed) as a 3D matrix

        Raises
        ------
        ValueError
            If the data is not 1, 2, or 3D to begin with.