# Path: skmultilearn/utils.py
# def get_matrix_in_format(original_matrix, matrix_format):
#     """Converts matrix to format
# 
#     Parameters
#     ----------
# 
#     original_matrix : np.matrix or scipy matrix or np.array of np. arrays
#         matrix to convert
# 
#     matrix_format : string
#         format
# 
#     Returns
#     -------
# 
#     matrix : scipy matrix
#         matrix in given format
#     """
#     if isinstance(original_matrix, np.ndarray):
#         return SPARSE_FORMAT_TO_CONSTRUCTOR[matrix_format](original_matrix)
# 
#     if original_matrix.getformat() == matrix_format:
#         return original_matrix
# 
#     return original_matrix.asformat(matrix_format)
# 
# def matrix_creation_function_for_format(sparse_format):
#     if sparse_format not in SPARSE_FORMAT_TO_CONSTRUCTOR:
#         return None
# 
#     return SPARSE_FORMAT_TO_CONSTRUCTOR[sparse_format]


import numpy as np
from ..utils import get_matrix_in_format, matrix_creation_function_for_format
from scipy.sparse import issparse
from sklearn.base import BaseEstimator, ClassifierMixin
            Requested format of returned scipy.sparse matrix, if sparse is returned
        enforce_sparse : bool
            Ignore require_dense and enforce sparsity, useful internally

        Returns
        -------
        array-like or sparse matrix
            Transformed X values of shape :code:`(n_samples, n_features)`
            
        .. note:: If :code:`require_dense` was set to :code:`True` for
            input features in the constructor, the returned value is an
            array-like of array-likes. If :code:`require_dense` is 
            set to :code:`false`, a sparse matrix of format
            :code:`sparse_format` is returned, if possible - without cloning.
        """
        is_sparse = issparse(X)

        if is_sparse:
            if self.require_dense[0] and not enforce_sparse:
                return X.toarray()
            else:
                if sparse_format is None:
                    return X
                else:
                    return get_matrix_in_format(X, sparse_format)
        else:
            if self.require_dense[0] and not enforce_sparse:
                # TODO: perhaps a check_array?
                return X
            else:

# Path: skmultilearn/utils.py
# def get_matrix_in_format(original_matrix, matrix_format):
#     """Converts matrix to format
# 
#     Parameters
#     ----------
# 
#     original_matrix : np.matrix or scipy matrix or np.array of np. arrays
#         matrix to convert
# 
#     matrix_format : string
#         format
# 
#     Returns
#     -------
# 
#     matrix : scipy matrix
#         matrix in given format
#     """
#     if isinstance(original_matrix, np.ndarray):
#         return SPARSE_FORMAT_TO_CONSTRUCTOR[matrix_format](original_matrix)
# 
#     if original_matrix.getformat() == matrix_format:
#         return original_matrix
# 
#     return original_matrix.asformat(matrix_format)
# 
# def matrix_creation_function_for_format(sparse_format):
#     if sparse_format not in SPARSE_FORMAT_TO_CONSTRUCTOR:
#         return None
# 
#     return SPARSE_FORMAT_TO_CONSTRUCTOR[sparse_format]


# Path: skmultilearn/base/base.py
import numpy as np
from ..utils import get_matrix_in_format, matrix_creation_function_for_format
from scipy.sparse import issparse
from sklearn.base import BaseEstimator, ClassifierMixin

            Requested format of returned scipy.sparse matrix, if sparse is returned
        enforce_sparse : bool
            Ignore require_dense and enforce sparsity, useful internally

        Returns
        -------
        array-like or sparse matrix
            Transformed X values of shape :code:`(n_samples, n_features)`
            
        .. note:: If :code:`require_dense` was set to :code:`True` for
            input features in the constructor, the returned value is an
            array-like of array-likes. If :code:`require_dense` is 
            set to :code:`false`, a sparse matrix of format
            :code:`sparse_format` is returned, if possible - without cloning.
        """
        is_sparse = issparse(X)

        if is_sparse:
            if self.require_dense[0] and not enforce_sparse:
                return X.toarray()
            else:
                if sparse_format is None:
                    return X
                else:
                    return get_matrix_in_format(X, sparse_format)
        else:
            if self.require_dense[0] and not enforce_sparse:
                # TODO: perhaps a check_array?
                return X
            else:

                return matrix_creation_function_for_format(sparse_format)(X)