Exemplo n.º 1
0
def filter_real_part_not_prime(list_track):
    list_snapshot = track.peek(list_track)
    list_snapshot = [
        item for item in list_snapshot
        if not utils.is_prime(item.real)
    ]
    track.push(list_track, list_snapshot)
Exemplo n.º 2
0
def filter_by_absolute_relation(list_track, target, relation):
    list_snapshot = track.peek(list_track)
    list_snapshot = [
        item for item in list_snapshot
        if not utils.satisfies_relation(abs(item), target, relation)
    ]
    track.push(list_track, list_snapshot)
Exemplo n.º 3
0
 def test_print_absolute_equal_with_ten(self):
     """
     Test controller print_absolute_equal_with_ten.
     """
     self.assertEqual(
         controllers.print_absolute_equal_with_ten(self.list_track), [])
     track.push(self.list_track, [9 + 5j, 0 + 10j, 8 + 5j, 10 + 0j])
     self.assertEqual(
         controllers.print_absolute_equal_with_ten(self.list_track),
         [0 + 10j, 10 + 0j])
Exemplo n.º 4
0
 def test_print_absolute_less_than_ten(self):
     """
     Test controller print_absolute_less_than_ten.
     """
     self.assertEqual(
         controllers.print_absolute_less_than_ten(self.list_track),
         [1 + 1j, 2 + 2.5j, 3 + 0j])
     track.push(self.list_track, [9 + 5j, 0 + 10j, 8 + 4j, 10 + 0j])
     self.assertEqual(
         controllers.print_absolute_less_than_ten(self.list_track),
         [8 + 4j])
Exemplo n.º 5
0
 def test_undo_list_track(self):
     """
     Test controller undo_list_track.
     """
     controllers.undo_list_track(self.list_track)
     self.assertEqual(track.peek(self.list_track),
                      [1 + 1j, 2 + 2.5j, 3 + 0j])
     track.push(self.list_track, [3 + 0j])
     controllers.undo_list_track(self.list_track)
     self.assertEqual(track.peek(self.list_track),
                      [1 + 1j, 2 + 2.5j, 3 + 0j])
Exemplo n.º 6
0
 def test_print_complex_numbers_product(self):
     """
     Test controller print_complex_numbers_product.
     """
     self.assertEqual(
         controllers.print_complex_numbers_product(self.list_track, 0, 1),
         -0.5 + 4.5j)
     track.push(self.list_track, [])
     self.assertEqual(
         controllers.print_complex_numbers_product(self.list_track, -1000,
                                                   100), None)
Exemplo n.º 7
0
 def test_print_complex_numbers_sum(self):
     """
     Test controller print_complex_numbers_sum.
     """
     self.assertEqual(
         controllers.print_complex_numbers_sum(self.list_track, 0, 100),
         6 + 3.5j)
     track.push(self.list_track, [])
     self.assertEqual(
         controllers.print_complex_numbers_sum(self.list_track, -1000, 100),
         None)
Exemplo n.º 8
0
 def test_remove_complex_numbers_sequence(self):
     """
     Test controller remove_complex_numbers_sequence.
     """
     controllers.remove_complex_numbers_sequence(self.list_track, 1, 2)
     self.assertEqual(track.peek(self.list_track), [1 + 1j])
     track.push(self.list_track, [1 + 1j, 2 + 2.5j, 3 + 0j])
     controllers.remove_complex_numbers_sequence(self.list_track, -2, -1)
     self.assertEqual(track.peek(self.list_track), [1 + 1j])
     track.push(self.list_track, [1 + 1j, 2 + 2.5j, 3 + 0j])
     controllers.remove_complex_numbers_sequence(self.list_track, -10, 1)
     self.assertEqual(track.peek(self.list_track), [3 + 0j])
Exemplo n.º 9
0
 def test_filter_by_absolute_relation(self):
     """
     Test controller filter_by_absolute_relation.
     """
     controllers.filter_by_absolute_relation(self.list_track, 3, 0)
     self.assertEqual(track.peek(self.list_track), [1 + 1j, 2 + 2.5j])
     track.push(self.list_track, [1 + 1j, 2 + 2.5j, 3 + 0j])
     controllers.filter_by_absolute_relation(self.list_track, 2, -999)
     self.assertEqual(track.peek(self.list_track), [2 + 2.5j, 3 + 0j])
     track.push(self.list_track, [1 + 1j, 2 + 2.5j, 3 + 0j])
     controllers.filter_by_absolute_relation(self.list_track, 3, 12321)
     self.assertEqual(track.peek(self.list_track), [1 + 1j, 3 + 0j])
Exemplo n.º 10
0
def append_complex_number_to_list(list_track, item):
    list_snapshot = track.peek(list_track)
    list_snapshot.append(item)
    track.push(list_track, list_snapshot)
Exemplo n.º 11
0
def replace_complex_number(list_track, old_item, new_item):
    list_snapshot = track.peek(list_track)
    list_snapshot = [new_item if item == old_item else item for item in list_snapshot]
    track.push(list_track, list_snapshot)
Exemplo n.º 12
0
def remove_complex_numbers_sequence(list_track, index_left, index_right):
    list_snapshot = track.peek(list_track)
    list_snapshot[index_left:index_right + 1 or None] = []
    track.push(list_track, list_snapshot)
Exemplo n.º 13
0
def remove_complex_number_at_index(list_track, index):
    list_snapshot = track.peek(list_track)
    list_snapshot.pop(index)
    track.push(list_track, list_snapshot)
Exemplo n.º 14
0
def insert_complex_number_at_index(list_track, item, index):
    list_snapshot = track.peek(list_track)
    list_snapshot.insert(index, item)
    track.push(list_track, list_snapshot)