def create_random_matrix(self): self.logger.log('Button create_random_matrix clicked') self.created_random_matrix.clear() if self.button_convert_state == 'normal': matrix = BisymmetricMatrix() self.set_created_random_matrix( matrix.generate_random_bisymmetric_matrix(self.matrix_size))
def create_matrix_by_vector(self): self.created_matrix_by_vector.clear() if self.button_convert_state == 'normal': matrix = BisymmetricMatrix() self.matrix_size = is_correct_vector_size(len(self.vector)) self.set_created_matrix_by_vector( matrix.generate_bisymmetric_matrix_by_vector(self.vector))
def test_necessary_condition_is_not_met(self): necessary_condition_is_not_met_matrix = BisymmetricMatrix() necessary_condition_is_not_met_matrix.init_matrix([[1, 2, 3], [4, 5, 4], [3, 2, 1]]) self.assertFalse(necessary_condition_is_not_met_matrix. necessary_condition_for_bisymmetric())
def test_generate_bisymmetric_is_correct(self): result = BisymmetricMatrix() result.generate_bisymmetric_matrix_by_vector([1, 2, 3, 4, 5, 6]) correct_bisymmetric_matrix = [[1, 2, 3, 4], [2, 5, 6, 3], [3, 6, 5, 2], [4, 3, 2, 1]] for i in range(4): for j in range(4): self.assertEqual(result[i][j], correct_bisymmetric_matrix[i][j])
def test_incorrect_size_matrix(self): incorrect_size_matrix = BisymmetricMatrix() incorrect_size_matrix.init_matrix([[1, 2, 3], [1, 2]]) self.assertFalse(incorrect_size_matrix.is_valid_square_matrix())
def test_not_square_matrix(self): not_square_matrix = BisymmetricMatrix() not_square_matrix.init_matrix([[3, 2, 1], [4, 3, 2]]) self.assertFalse(not_square_matrix.is_valid_square_matrix())
def test_necessary_condition_is_not_met(self): necessary_condition_is_not_met_matrix = BisymmetricMatrix() necessary_condition_is_not_met_matrix.init_matrix([[1, 2], [2, 3]]) self.assertFalse( necessary_condition_is_not_met_matrix.is_bisymmetric())
def test_0_size_matrix(self): empty_matrix = BisymmetricMatrix() empty_matrix.init_matrix([]) self.assertTrue(empty_matrix.necessary_condition_for_bisymmetric())
def test_correct_persymmetric_matrix(self): persymmetric_matrix = BisymmetricMatrix() persymmetric_matrix.init_matrix([[1, 2, 3], [4, 1, 2], [5, 4, 1]]) self.assertTrue(persymmetric_matrix.is_persymmetric())
def test_0_size_matrix(self): empty_matrix = BisymmetricMatrix() empty_matrix.init_matrix([]) self.assertTrue(empty_matrix.is_persymmetric())
def test_correct_square_matrix(self): square_matrix = BisymmetricMatrix() square_matrix.init_matrix([[3, 2, 1], [4, 3, 2], [5, 4, 3]]) self.assertTrue(square_matrix.is_valid_square_matrix())
def test_float_vector_size(self): self.assertRaises(ValueError, BisymmetricMatrix().is_correct_vector_size, 2.4)
def test_incorrect_vector_size(self): self.assertEqual(BisymmetricMatrix().is_correct_vector_size(3), -1)
def test_0_size_vector(self): self.assertEqual(BisymmetricMatrix().is_correct_vector_size(0), 0)
def test_generate_bisymmetric_is_bisymmetric(self): correct_bisymmetric_matrix = BisymmetricMatrix() correct_bisymmetric_matrix.generate_random_bisymmetric_matrix(10) self.assertTrue(correct_bisymmetric_matrix.is_bisymmetric())
def test_not_square(self): not_square_matrix = BisymmetricMatrix() not_square_matrix.init_matrix([[1, 2, 3], [4, 5, 4]]) self.assertFalse(not_square_matrix.is_bisymmetric())
def test_correct_symmetric_matrix(self): symmetric_matrix = BisymmetricMatrix() symmetric_matrix.init_matrix([[1, 2, 3], [2, 4, 5], [3, 5, 6]]) self.assertTrue(symmetric_matrix.is_symmetric())
def test_not_symmetric_matrix(self): not_symmetric_matrix = BisymmetricMatrix() not_symmetric_matrix.init_matrix([[1, 2], [1, 2]]) self.assertFalse(not_symmetric_matrix.is_symmetric())
def test_str_vector_size(self): self.assertRaises(ValueError, BisymmetricMatrix().is_correct_vector_size, 'six')
def test_0_size_matrix(self): empty_matrix = BisymmetricMatrix() empty_matrix.init_matrix([]) self.assertTrue(empty_matrix.is_valid_square_matrix())
def test_generate_by_0_size_vector_is_bisymmetric(self): empty_matrix = BisymmetricMatrix() empty_matrix.generate_bisymmetric_matrix_by_vector([]) self.assertTrue(empty_matrix.is_bisymmetric())
def test_not_square_matrix(self): not_square_matrix = BisymmetricMatrix() not_square_matrix.init_matrix([[1, 2], [3]]) self.assertFalse(not_square_matrix.is_persymmetric())
def test_generate_bisymmetric_is_bisymmetric(self): correct_bisymmetric_matrix = BisymmetricMatrix() correct_bisymmetric_matrix.generate_bisymmetric_matrix_by_vector( [1, 2, 3, 4]) self.assertTrue(correct_bisymmetric_matrix.is_bisymmetric())
def test_necessary_condition_for_not_bisymmetric_is_met(self): not_bisymmetric_matrix = BisymmetricMatrix() not_bisymmetric_matrix.init_matrix([[1, 2, 3], [2, 3, 2], [2, 2, 1]]) self.assertTrue( not_bisymmetric_matrix.necessary_condition_for_bisymmetric())
def test_correct_bisymmetric(self): correct_bisymmetric_matrix = BisymmetricMatrix() correct_bisymmetric_matrix.init_matrix([[1, 2, 3], [2, 4, 2], [3, 2, 1]]) self.assertTrue(correct_bisymmetric_matrix.is_bisymmetric())
def test_generate_by_incorrect_vector(self): correct_bisymmetric_matrix = BisymmetricMatrix() self.assertRaises( ValueError, correct_bisymmetric_matrix.generate_bisymmetric_matrix_by_vector, [1, 2, 3])
def test_incorrect_matrix(self): incorrect_matrix = BisymmetricMatrix() incorrect_matrix.init_matrix([['one', 2], [2, '3']]) self.assertFalse(incorrect_matrix.is_valid_square_matrix())