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))
Exemple #3
0
 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())
Exemple #4
0
 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])
Exemple #5
0
 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())
Exemple #6
0
 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())
Exemple #7
0
 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())
Exemple #8
0
 def test_0_size_matrix(self):
     empty_matrix = BisymmetricMatrix()
     empty_matrix.init_matrix([])
     self.assertTrue(empty_matrix.necessary_condition_for_bisymmetric())
Exemple #9
0
 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())
Exemple #10
0
 def test_0_size_matrix(self):
     empty_matrix = BisymmetricMatrix()
     empty_matrix.init_matrix([])
     self.assertTrue(empty_matrix.is_persymmetric())
Exemple #11
0
 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())
Exemple #12
0
 def test_float_vector_size(self):
     self.assertRaises(ValueError,
                       BisymmetricMatrix().is_correct_vector_size, 2.4)
Exemple #13
0
 def test_incorrect_vector_size(self):
     self.assertEqual(BisymmetricMatrix().is_correct_vector_size(3), -1)
Exemple #14
0
 def test_0_size_vector(self):
     self.assertEqual(BisymmetricMatrix().is_correct_vector_size(0), 0)
Exemple #15
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())
Exemple #16
0
 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())
Exemple #17
0
 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())
Exemple #18
0
 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())
Exemple #19
0
 def test_str_vector_size(self):
     self.assertRaises(ValueError,
                       BisymmetricMatrix().is_correct_vector_size, 'six')
Exemple #20
0
 def test_0_size_matrix(self):
     empty_matrix = BisymmetricMatrix()
     empty_matrix.init_matrix([])
     self.assertTrue(empty_matrix.is_valid_square_matrix())
Exemple #21
0
 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())
Exemple #22
0
 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())
Exemple #23
0
 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())
Exemple #24
0
 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())
Exemple #25
0
 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())
Exemple #26
0
 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])
Exemple #27
0
 def test_incorrect_matrix(self):
     incorrect_matrix = BisymmetricMatrix()
     incorrect_matrix.init_matrix([['one', 2], [2, '3']])
     self.assertFalse(incorrect_matrix.is_valid_square_matrix())