def test_matrix_to_string(self): self.assertEqual(matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=None), '1\t2\n' '3\t4') self.assertEqual(matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=None, fmtfun=lambda x: '{0:.2f}'.format(x)), '1.00\t2.00\n' '3.00\t4.00') self.assertEqual(matrix_to_string([[1, 2], [3, 4]], row_headers=['c', 'd'], col_headers=None), 'c\t1\t2\n' 'd\t3\t4') self.assertEqual(matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=['a', 'b']), 'a\tb\n' '1\t2\n' '3\t4') self.assertEqual(matrix_to_string([[1, 2], [3, 4]], row_headers=['c', 'd'], col_headers=['a', 'b']), '\ta\tb\n' 'c\t1\t2\n' 'd\t3\t4')
def test_matrix_to_string(self): assert (matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=None) == "1\t2\n" "3\t4") assert (matrix_to_string( [[1, 2], [3, 4]], row_headers=None, col_headers=None, fmtfun=lambda x: f"{x:.2f}", ) == "1.00\t2.00\n" "3.00\t4.00") assert (matrix_to_string([[1, 2], [3, 4]], row_headers=["c", "d"], col_headers=None) == "c\t1\t2\n" "d\t3\t4") assert (matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=["a", "b"]) == "a\tb\n" "1\t2\n" "3\t4") assert (matrix_to_string([[1, 2], [3, 4]], row_headers=["c", "d"], col_headers=["a", "b"]) == "\ta\tb\n" "c\t1\t2\n" "d\t3\t4")
def test_matrix_to_string(self): self.assertEqual( matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=None), "1\t2\n" "3\t4", ) self.assertEqual( matrix_to_string( [[1, 2], [3, 4]], row_headers=None, col_headers=None, fmtfun=lambda x: f"{x:.2f}", ), "1.00\t2.00\n" "3.00\t4.00", ) self.assertEqual( matrix_to_string([[1, 2], [3, 4]], row_headers=["c", "d"], col_headers=None), "c\t1\t2\n" "d\t3\t4", ) self.assertEqual( matrix_to_string([[1, 2], [3, 4]], row_headers=None, col_headers=["a", "b"]), "a\tb\n" "1\t2\n" "3\t4", ) self.assertEqual( matrix_to_string([[1, 2], [3, 4]], row_headers=["c", "d"], col_headers=["a", "b"]), "\ta\tb\n" "c\t1\t2\n" "d\t3\t4", )