Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)