Example #1
0
 def test_construction_by_name_value_pairs(self):
     self.event = events.Event(time=3.3, typ='c', seq=111)
     self.assertEqual(111, self.event.seq)
     self.assertEqual(3.3, self.event.time)
     self.assertEqual('c', self.event.typ)
     self.assertIsNone(self.event.end)
     self.assertIsNone(self.event.val)
Example #2
0
 def test_story004(self):
     # Order events in reverse by their name and then strip times to
     # convert to sequences.  Number events starting at 1.
     rev_evs_to_seqs = sequences.make_timeline_to_sequence_flattener(
         ordering=lambda evs: sorted(evs, key=lambda e: e.typ, reverse=True
                                     ),
         start=1)
     seqs = (
         data.seq_concurrent_events,
         data.seq_sorted,
         data.seq_rand1_08,
     )
     index_maps = (
         (2, 1, 0, 6, 5, 4, 3, 8, 7, 13, 12, 11, 10, 9),
         (1, 2, 0, 3, 4, 6, 5, 9, 8, 7, 10),
         (1, 0, 4, 3, 2, 5, 6, 7),
     )
     expected = []
     for seq_idx, seq in enumerate(seqs):
         for ev_num, ev_idx in enumerate(index_maps[seq_idx], 1):
             ev = seq[ev_idx]
             expected.append(
                 events.Event(ev.seq, ev_num, ev.end, ev.typ, ev.val))
     actual = list(
         streams.map_sequences_as_events(rev_evs_to_seqs,
                                         itools.chain.from_iterable(seqs)))
     self.assertEqual(expected, actual)
Example #3
0
 def test_hash(self):
     event2 = events.Event(*self.event_fields)
     self.assertEqual(hash(self.event), hash(event2))
Example #4
0
 def test_eq(self):
     event2 = events.Event(*self.event_fields)
     self.assertEqual(self.event, event2)
Example #5
0
 def setUp(self):
     self.event = events.Event(*self.event_fields)
Example #6
0
 def test_matches_nones(self):
     event = events.Event()
     self.assertTrue(event.matches())
     self.assertTrue(event.matches(None, None, None, None, None))
Example #7
0
 def test_timeline_to_sequence(self):
     expected = list(data.seq_rand2_15)
     for idx, ev in enumerate(expected):
         expected[idx] = events.Event(ev.seq, idx, ev.end, ev.typ, ev.val)
     actual = list(sequences.timeline_to_sequence(data.seq_rand2_15))
     self.assertEqual(expected, actual)
Example #8
0
    (1, 0, 'a'),
    (7, 6, 'b'),
    (1, 0, 'e'),
    (6, 3, 'e'),
    (1, 8, 'd'),
    (3, 3, 'f'),
    (3, 3, 'e'),
    (1, 3, 'c'),
    (6, 8, 'e'),
    (4, 1, 'e'),
    (9, 7, 'd'),
)  # 94

# Event tuples for binary events
binary_events = tuple(
    map(lambda tup: events.Event(seq=tup[0], time=tup[1], typ=tup[2]),
        binary_event_tuples))

# Specific event sequences to be used in preference to indexing events
seq_len1 = binary_events[0:1]
seq_abcdef = binary_events[9:15]
seq_concurrent_events = binary_events[15:29]
seq_unsorted = binary_events[29:40]
seq_sorted = binary_events[40:51]
seq_rand1_08 = binary_events[51:59]
seq_rand2_15 = binary_events[59:74]
evs_for_selection = binary_events[74:94]

# Drug and condition events for example medical data
drugs = (
    'd_ace_inhibitor',