def test_note_beat_strength_indexer_1(self): # When the parts are empty expected = pandas.DataFrame({'0': pandas.Series(), '1': pandas.Series()}) test_parts = [stream.Part(), stream.Part()] ip = IndexedPiece() ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = test_parts # supply part_streams. actual = ip._get_beat_strength()['meter.NoteBeatStrengthIndexer'] self.assertTrue(actual.equals(expected))
def test_note_beat_strength_indexer_1(self): # When the parts are empty expected = pandas.DataFrame({ '0': pandas.Series(), '1': pandas.Series() }) test_parts = [stream.Part(), stream.Part()] ip = IndexedPiece() ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = test_parts # supply part_streams. actual = ip._get_beat_strength()['meter.NoteBeatStrengthIndexer'] self.assertTrue(actual.equals(expected))
def test_note_beat_strength_indexer_2(self): # When the part has no Note or Rest objects in it expected = pandas.DataFrame({'0': pandas.Series()}) test_part = stream.Part() # add stuff to the test_part for i in range(1000): add_me = clef.BassClef() add_me.offset = i test_part.append(add_me) add_me = bar.Barline() add_me.offset = i test_part.append(add_me) # finished adding stuff to the test_part ip = IndexedPiece() ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = [test_part] # supply part_streams. actual = ip._get_beat_strength()['meter.NoteBeatStrengthIndexer'] self.assertTrue(actual.equals(expected))
def test_note_beat_strength_indexer_3(self): # When there are a few notes expected = pandas.DataFrame({'0': pandas.Series([1.0, 0.5, 0.5, 1.0, 0.5, 0.5])}) test_part = stream.Part() # add stuff to the test_part measure = stream.Measure() # In music21 beginning time signatures are preferably inserted in the first measure and a # timeSignature is needed to be able to calculate beatStrength measure.insert(0, m21_meter.TimeSignature('3/4')) for i in range(6): add_me = note.Note(u'C4', quarterLength=1.0) add_me.offset = i measure.append(add_me) test_part.insert(0, measure) # finished adding stuff to the test_part ip = IndexedPiece() ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = [test_part] # supply part_streams. actual = ip._get_beat_strength()['meter.NoteBeatStrengthIndexer'] self.assertTrue(actual.equals(expected))
def test_note_beat_strength_indexer_3(self): # When there are a few notes expected = pandas.DataFrame( {'0': pandas.Series([1.0, 0.5, 0.5, 1.0, 0.5, 0.5])}) test_part = stream.Part() # add stuff to the test_part measure = stream.Measure() # In music21 beginning time signatures are preferably inserted in the first measure and a # timeSignature is needed to be able to calculate beatStrength measure.insert(0, m21_meter.TimeSignature('3/4')) for i in range(6): add_me = note.Note(u'C4', quarterLength=1.0) add_me.offset = i measure.append(add_me) test_part.insert(0, measure) # finished adding stuff to the test_part ip = IndexedPiece() ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = [test_part] # supply part_streams. actual = ip._get_beat_strength()['meter.NoteBeatStrengthIndexer'] self.assertTrue(actual.equals(expected))