def test_expression_with_dimensions(self): expected = ("(0x0) (0x0)\n" "┌ ┐ . ┌ ┐ \n" "└ ┘ └ ┘ ") actual = prettymatrix.expression_to_string(np.full((0, 0), '0'), prettymatrix.DOT, np.full((0, 0), '0'), include_dimensions=True) self.assertEqual(expected, actual)
def test_expression_with_two_names(self): expected = ("M N \n" "┌ ┐ . ┌ ┐\n" "└ ┘ └ ┘") actual = prettymatrix.expression_to_string(np.full((0, 0), '0'), prettymatrix.DOT, np.full((0, 0), '0'), names=['M', 'N']) self.assertEqual(expected, actual)
def test_expression_with_too_many_names(self): with self.assertRaises(ValueError): prettymatrix.expression_to_string(np.full((0, 0), '0'), names=['M', 'N'])
def test_equality_of_two_empty_matrices(self): expected = ("┌ ┐ = ┌ ┐\n" "└ ┘ └ ┘") actual = prettymatrix.expression_to_string(np.full((0, 0), '0'), prettymatrix.EQUALS, np.full((0, 0), '0')) self.assertEqual(expected, actual)
def test_hadamard_product_of_two_empty_matrices(self): expected = ("┌ ┐ ∘ ┌ ┐\n" "└ ┘ └ ┘") actual = prettymatrix.expression_to_string(np.full((0, 0), '0'), prettymatrix.HADAMARD, np.full((0, 0), '0')) self.assertEqual(expected, actual)
def test_subtraction_of_two_empty_matrices(self): expected = ("┌ ┐ - ┌ ┐\n" "└ ┘ └ ┘") actual = prettymatrix.expression_to_string(np.full((0, 0), '0'), prettymatrix.MINUS, np.full((0, 0), '0')) self.assertEqual(expected, actual)
def test_dot_product_of_two_empty_matrices(self): expected = ("┌ ┐ . ┌ ┐\n" "└ ┘ └ ┘") actual = prettymatrix.expression_to_string(np.full((0, 0), '0'), prettymatrix.DOT, np.full((0, 0), '0')) self.assertEqual(expected, actual)
def test_hadamard(self): expected = ("∘") actual = prettymatrix.expression_to_string(prettymatrix.HADAMARD) self.assertEqual(expected, actual)
def test_minus(self): expected = ("-") actual = prettymatrix.expression_to_string(prettymatrix.MINUS) self.assertEqual(expected, actual)
def test_plus(self): expected = ("+") actual = prettymatrix.expression_to_string(prettymatrix.PLUS) self.assertEqual(expected, actual)
def test_dot_product(self): expected = (".") actual = prettymatrix.expression_to_string(prettymatrix.DOT) self.assertEqual(expected, actual)