Exemple #1
0
 def test_sparse_add_if_sorts_properly(self):
     self.sparse_vector_1[10], self.sparse_vector_1[30] = 10, 30
     self.sparse_vector_2[20], self.sparse_vector_2[40] = 20, 40
     expected_return = {1: 2, 10: 10, 20: 20, 30: 30, 40: 40}
     self.assertEqual(
         lab_08.sparse_add(self.sparse_vector_1, self.sparse_vector_2),
         expected_return)
Exemple #2
0
 def test_sparse_add_with_different_keys_btw_two_dict(self):
     self.sparse_vector_1[2] = 2
     self.sparse_vector_2[3] = 3
     expected_return = {1: 2, 2: 2, 3: 3}
     self.assertEqual(
         lab_08.sparse_add(self.sparse_vector_1, self.sparse_vector_2),
         expected_return)
Exemple #3
0
 def test_sparse_add_with_two_negative_values(self):
     self.sparse_vector_1[1] = -1
     self.sparse_vector_2[1] = -1
     expected_return = {1: -2}
     self.assertEqual(
         lab_08.sparse_add(self.sparse_vector_1, self.sparse_vector_2),
         expected_return)
Exemple #4
0
 def test_sparse_add_with_positive_and_negative_values_with_zero_return(
         self):
     self.sparse_vector_1[1] = 2
     self.sparse_vector_2[1] = -2
     expected_return = {}
     self.assertEqual(
         lab_08.sparse_add(self.sparse_vector_1, self.sparse_vector_2),
         expected_return)
Exemple #5
0
 def test_sparse_add_with_two_positive_values(self):
     expected_return = {1: 2}
     self.assertEqual(
         lab_08.sparse_add(self.sparse_vector_1, self.sparse_vector_2),
         expected_return)
Exemple #6
0
 def test_sparse_add_with_two_empty_values(self):
     sparse_vector_1 = {}
     sparse_vector_2 = {}
     expected_return = {}
     self.assertEqual(lab_08.sparse_add(sparse_vector_1, sparse_vector_2),
                      expected_return)