def test_run3(self):
     """Doctest case with propage recovered singles"""
     d = ContextAggregator(
         config={
             "propagation_mode": ContextAggregator.AGGREGATION_MODE,
             "max_tau": 1,
             "propagate_recovered_singles": True,
         }
     )
     # d.initialize() # Always execute initialize before newly receive data
     # Emulating receive data from neighbors
     d.receive(1, set([Context(value=1.0, cohorts=[0, 1, 2])]))
     d.receive(2, set([Context(value=2.0, cohorts=[0])]))
     d.receive(3, set([Context(value=3.0, cohorts=[1])]))
     d.receive(4, set([Context(value=7.0, cohorts=[9], hopcount=Context.SPECIAL_CONTEXT)]))
     # Emulating accumulated contexts
     context_db = set(
         [
             Context(value=1.0, cohorts=[2, 4, 5, 3]),
             Context(value=1.0, cohorts=[5, 6]),
             Context(value=7.0, cohorts=[7, 8]),
         ]
     )
     d.set_database(singles=set([]), aggregates=context_db, timestamp=10)
     d.run_dataflow(timestamp=10)
     # Emulating newly found singles and aggregates from database
     self.assertTrue(same(d.get_database_singles(timestamp=10), [[0, 1, 2, 9], []]))
     self.assertTrue(same(d.get_database_aggregates(timestamp=10), [[7, 8], [3, 4, 5], [6, 5]]))
     # Emulating the disaggregation process
     self.assertTrue(same(d.get_singles(timestamp=10), [[0, 1, 2, 9], []]))
     self.assertTrue(same(d.get_primes(timestamp=10), [[7, 8]]))
     self.assertTrue(same(d.get_non_primes(timestamp=10), [[3, 4, 5], [5, 6]]))
     self.assertTrue(same(d.get_selected_non_primes(timestamp=10), [[3, 4, 5]]))
     self.assertTrue(d.get_new_aggregate().get_cohorts_as_set() == set([0, 1, 2, 3, 4, 5, 7, 8, 9]))
     self.assertTrue(same(d.get_filtered_singles(), [[0, 1, 2, 9], []]))
 def test_run1(self):
     """Only [4,5] is prime
     All the others are singles
     """
     d = ContextAggregator()
     d.receive(1, set([Context(value=1.0, cohorts=[0, 1, 2])]))
     d.receive(2, set([Context(value=2.0, cohorts=[0])]))
     d.set_database(
         set([Context(value=1.0, cohorts=[0, 1, 2, 3, 4, 5]), Context(value=2.0, cohorts=[1])]),
         set([Context(value=1.0, cohorts=[2, 3])]),
     )
     d.run_dataflow()
     self.assertTrue(same(d.get_singles(), [[0, 1, 2, 3], []]))
     self.assertTrue(same(d.get_primes(), [[], [4, 5]]))