# 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
            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(matrix)

        if is_sparse:
            if self.require_dense[1] and not enforce_sparse:
                if matrix.shape[1] != 1:
                    return matrix.toarray()
                elif matrix.shape[1] == 1:
                    return np.ravel(matrix.toarray())
            else:
                if sparse_format is None:
                    return matrix
                else:
                    return get_matrix_in_format(matrix, sparse_format)
        else:
            if self.require_dense[1] and not enforce_sparse:
                # ensuring 1d
                if len(matrix.shape) > 1:
                    # a regular dense np.matrix or np.array of np.arrays
                    return np.ravel(matrix)
                else:
                    return matrix
            else:
                # ensuring 2d
                if len(matrix.shape) == 1:
                    matrix = matrix.reshape((matrix.shape[0], 1))

# 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

            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(matrix)

        if is_sparse:
            if self.require_dense[1] and not enforce_sparse:
                if matrix.shape[1] != 1:
                    return matrix.toarray()
                elif matrix.shape[1] == 1:
                    return np.ravel(matrix.toarray())
            else:
                if sparse_format is None:
                    return matrix
                else:
                    return get_matrix_in_format(matrix, sparse_format)
        else:
            if self.require_dense[1] and not enforce_sparse:
                # ensuring 1d
                if len(matrix.shape) > 1:
                    # a regular dense np.matrix or np.array of np.arrays
                    return np.ravel(matrix)
                else:
                    return matrix
            else:
                # ensuring 2d
                if len(matrix.shape) == 1:
                    matrix = matrix.reshape((matrix.shape[0], 1))

                return matrix_creation_function_for_format(sparse_format)(matrix)