# 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 unittest
import numpy as np
import scipy.sparse as sp
from ..utils import get_matrix_in_format, matrix_creation_function_for_format


SPARSE_MATRIX_FORMATS = ["bsr", "coo", "csc", "csr", "dia", "dok", "lil"]


class UtilsTest(unittest.TestCase):

    def test_if_get_matrix_ensures_type(self):
        matrix = sp.csr_matrix([])
        for sparse_format in SPARSE_MATRIX_FORMATS:
            new_matrix = get_matrix_in_format(matrix, sparse_format)

            self.assertTrue(sp.issparse(new_matrix))
            self.assertTrue(new_matrix.format == sparse_format)

    def test_if_matrix_creation_follows_format(self):
        matrix = np.matrix([])
        for sparse_format in SPARSE_MATRIX_FORMATS:
            new_matrix = matrix_creation_function_for_format(
                sparse_format)(matrix)

            self.assertTrue(sp.issparse(new_matrix))
            self.assertTrue(new_matrix.format == sparse_format)

    def test_ensure_get_matrix_does_not_clone_if_format_agrees(self):
        matrix = np.matrix([])
        for sparse_format in SPARSE_MATRIX_FORMATS:

# 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/tests/test_utils.py
import unittest
import numpy as np
import scipy.sparse as sp
from ..utils import get_matrix_in_format, matrix_creation_function_for_format



SPARSE_MATRIX_FORMATS = ["bsr", "coo", "csc", "csr", "dia", "dok", "lil"]


class UtilsTest(unittest.TestCase):

    def test_if_get_matrix_ensures_type(self):
        matrix = sp.csr_matrix([])
        for sparse_format in SPARSE_MATRIX_FORMATS:
            new_matrix = get_matrix_in_format(matrix, sparse_format)

            self.assertTrue(sp.issparse(new_matrix))
            self.assertTrue(new_matrix.format == sparse_format)

    def test_if_matrix_creation_follows_format(self):
        matrix = np.matrix([])
        for sparse_format in SPARSE_MATRIX_FORMATS:
            new_matrix = matrix_creation_function_for_format(
                sparse_format)(matrix)

            self.assertTrue(sp.issparse(new_matrix))
            self.assertTrue(new_matrix.format == sparse_format)

    def test_ensure_get_matrix_does_not_clone_if_format_agrees(self):
        matrix = np.matrix([])
        for sparse_format in SPARSE_MATRIX_FORMATS:

            created_matrix = matrix_creation_function_for_format(