def test_sequence_last_point_empty(self): """ Ensure OSequence.last_point doesn't barf when the sequence is empty """ from sebastian.core import OSequence from sebastian.core import OFFSET_64, DURATION_64 sequence = OSequence([]) self.assertEqual(sequence.last_point(), {DURATION_64: 0, OFFSET_64: 0})
def test_sequence_last_point_empty(self): """ Ensure OSequence.last_point doesn't barf when the sequence is empty """ from sebastian.core import OSequence from sebastian.core import OFFSET_64, DURATION_64 sequence = OSequence([]) self.assertEqual(sequence.last_point(), { DURATION_64: 0, OFFSET_64: 0 })
def test_sequence_last_point(self): """ Ensure that OSequence.last_point returns the highest offset note """ points = [self.make_point(offset=x) for x in range(100, -1, -10)] from sebastian.core import OSequence from sebastian.core import OFFSET_64, MIDI_PITCH, DURATION_64 sequence = OSequence(points) self.assertEqual(sequence.last_point(), { DURATION_64: 17 + 100, OFFSET_64: 16 + 100, MIDI_PITCH: 50 + 100 })
## sequences p2 = Point({ OFFSET_64: 32, MIDI_PITCH: 52, DURATION_64: 16, }) s1 = OSequence([p1, p2]) assert s1._elements == [ {DURATION_64: 16, OFFSET_64: 16, MIDI_PITCH: 50}, {DURATION_64: 16, OFFSET_64: 32, MIDI_PITCH: 52} ] assert s1.last_point() == { MIDI_PITCH: 52, OFFSET_64: 32, DURATION_64: 16 } assert OSequence([]).last_point() == { OFFSET_64: 0, DURATION_64: 0 } ## concatenation assert (s1 + s1)._elements == [ {DURATION_64: 16, OFFSET_64: 16, MIDI_PITCH: 50}, {DURATION_64: 16, OFFSET_64: 32, MIDI_PITCH: 52}, {DURATION_64: 16, OFFSET_64: 64, MIDI_PITCH: 50}, {DURATION_64: 16, OFFSET_64: 80, MIDI_PITCH: 52}