Пример #1
0
 def norm_test(self):
     """Test the length calculation of a Vector."""
     rows = 3
     data = [[6], [4], [5]]
     vector = Vector(rows)
     vector.initialize(data, rowBased=True)
     exRes = 8.774964387392123
     res = vector.norm()
     self.assertEqual(res, exRes)
Пример #2
0
 def unify_test(self):
     """Test if the matrix is unified correctly."""
     rows = 3
     data = [[0], [4], [3]]
     vector = Vector(rows)
     vector.initialize(data, rowBased=True)
     exRes = [[0, 4 / 5.0, 3 / 5.0]]
     res = vector.unify()
     self.assertEqual(res.matrix, exRes)
Пример #3
0
 def unify_test(self):
     """Test if the matrix is unified correctly."""
     rows = 3
     data = [[0], [4], [3]]
     vector = Vector(rows)
     vector.initialize(data, rowBased=True)
     exRes = [[0, 4 / 5.0, 3 / 5.0]]
     res = vector.unify()
     self.assertEqual(res.matrix, exRes)
Пример #4
0
 def norm_test(self):
     """Test the length calculation of a Vector."""
     rows = 3
     data = [[6], [4], [5]]
     vector = Vector(rows)
     vector.initialize(data, rowBased=True)
     exRes = 8.774964387392123
     res = vector.norm()
     self.assertEqual(res, exRes)
Пример #5
0
 def initialize_from_matrix_test(self):
     """Test to create a Vector from a specified column of a Matrix."""
     rows = 3
     cols = 2
     data = [[1, -4], [-2, 5], [3, 6]]
     # build Matrix
     matrix = Matrix(cols, rows)
     matrix.initialize(data, rowBased=True)
     # Create Vektor with the 2nd column of the matrix
     vector = Vector.initialize_from_matrix(matrix, 1)
     exRes = [[-4, 5, 6]]
     self.assertEqual(vector.matrix, exRes)
Пример #6
0
 def initialize_from_matrix_test(self):
     """Test to create a Vector from a specified column of a Matrix."""
     rows = 3
     cols = 2
     data = [
                 [1, -4],
                 [-2, 5],
                 [3, 6]
             ]
     # build Matrix
     matrix = Matrix(cols, rows)
     matrix.initialize(data, rowBased=True)
     # Create Vektor with the 2nd column of the matrix
     vector = Vector.initialize_from_matrix(matrix, 1)
     exRes = [[-4, 5, 6]]
     self.assertEqual(vector.matrix, exRes)
Пример #7
0
 def init_test(self):
     """Test the initialization of a Vector."""
     rows = random.randint(1, 1000)
     vector = Vector(rows)
     self.assertEqual(vector.get_height(), rows)
Пример #8
0
 def init_test(self):
     """Test the initialization of a Vector."""
     rows = random.randint(1, 1000)
     vector = Vector(rows)
     self.assertEqual(vector.get_height(), rows)