def test_measure_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('phony_file_location') # it doesn't matter what the string is becuase we supply part_streams ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = test_parts # supply part_streams. actual = ip._get_measure()['meter.MeasureIndexer'] self.assertTrue(actual.equals(expected))
def test_measure_indexer_2(self): # When the part has no Measure objects in it but a bunch of notes. expected = pandas.DataFrame({'0': pandas.Series()}) test_part = stream.Part() # add stuff to the test_part for i in range(0, 20, 2): add_me = note.Note('C#5', quarterLength=2.0) add_me.offset = i test_part.append(add_me) test_part = [test_part] # finished adding stuff to the test_part ip = IndexedPiece('phony_file_location') # it doesn't matter what the string is becuase we supply part_streams ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = test_part # supply part_streams. actual = ip._get_measure()['meter.MeasureIndexer'] self.assertTrue(actual.equals(expected))
def test_measure_indexer_3(self): # When there are a bunch of measures with a note in each one. expected = pandas.DataFrame({'0': pandas.Series(range(1, 11), index=[float(x) for x in range(10)])}) test_part = stream.Part() # add stuff to the test_part for i in range(1, 11): add_me = stream.Measure() add_me.number = i add_me.insert(note.Note('C#5', quarterLength=1.0)) add_me.offset = i test_part.append(add_me) test_part = [test_part] # finished adding stuff to the test_part ip = IndexedPiece('phony_file_location') # it doesn't matter what the string is becuase we supply part_streams ip.metadata('parts', expected.columns) ip._analyses['part_streams'] = test_part # supply part_streams. actual = ip._get_measure()['meter.MeasureIndexer'] self.assertTrue(actual.equals(expected))