def test_interval_indexer_1b(self):
     # BWV7.7: first 26 things in soprano part (no settings specified)
     test_parts = pandas.concat([self.bwv77_soprano], axis=1)
     test_parts.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_short_noqual['a']
     actual = HorizontalIntervalIndexer(test_parts).run().iloc[:26, 0]
     self.assertTrue(actual.equals(expected))
 def test_interval_indexer_1d(self):
     # BWV7.7: first 26 things in soprano part (simple; no quality)
     test_parts = [self.bwv77_soprano]
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_short_noqual['a']
     setts = {u'simple or compound': u'simple', u'quality': False}
     int_indexer = HorizontalIntervalIndexer(test_parts, setts)
     actual = int_indexer.run()[u'interval.HorizontalIntervalIndexer']['0'].iloc[:26]
     self.assertSequenceEqual(list(expected.index), list(actual.index))
     self.assertSequenceEqual(list(expected), list(actual))
 def test_interval_indexer_2(self):
     # BWV7.7: whole soprano part
     # NB: this test is more rigourous than the others, since it actually uses the DataFrame
     test_parts = pandas.concat([self.bwv77_soprano], axis=1)
     test_parts.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_basis['a']
     setts = {'simple or compound': 'compound', 'quality': True}
     actual = HorizontalIntervalIndexer(test_parts, setts).run().iloc[:, 0]
     self.assertTrue(actual.equals(expected))
 def test_interval_indexer_1c(self):
     # BWV7.7: first 26 things in soprano part (simple; no quality)
     test_parts = pandas.concat([self.bwv77_soprano], axis=1)
     test_parts.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_short_noqual['a']
     setts = {'simple or compound': 'simple', 'quality': False}
     actual = HorizontalIntervalIndexer(test_parts, setts).run().iloc[:26,
                                                                      0]
     self.assertTrue(actual.equals(expected))
Example #5
0
 def test_interval_indexer_1c(self):
     # BWV7.7: first 26 things in soprano part (simple; quality)
     test_parts = pandas.concat([self.bwv77_soprano], axis=1)
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_short['a']
     setts = {'simple or compound': 'simple', 'quality': True}
     int_indexer = HorizontalIntervalIndexer(test_parts, setts)
     actual = int_indexer.run()['interval.HorizontalIntervalIndexer']['0'].iloc[:26]
     self.assertSequenceEqual(list(expected.index), list(actual.index))
     self.assertSequenceEqual(list(expected), list(actual))
Example #6
0
 def test_interval_indexer_2(self):
     # BWV7.7: whole soprano part
     test_parts = [self.bwv77_soprano]
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_basis
     setts = {u'simple or compound': u'compound', u'quality': True}
     int_indexer = HorizontalIntervalIndexer(test_parts, setts)
     res = int_indexer.run()
     actual = res[0]
     self.assertEqual(len(expected), len(actual))
     for i, ind in enumerate(list(actual.index)):
         self.assertEqual(expected[i][0], ind)
         self.assertEqual(expected[i][1], actual[ind])
Example #7
0
 def test_interval_indexer_1d(self):
     # BWV7.7: first 26 things in soprano part (simple; no quality)
     test_parts = [self.bwv77_soprano]
     expected = TestHorizIntervalIndexerLong.bwv77_S_B_short_noqual
     setts = {u'simple or compound': u'simple', u'quality': False}
     int_indexer = HorizontalIntervalIndexer(test_parts, setts)
     res = int_indexer.run()
     actual = res[0].iloc[:26]
     self.assertEqual(len(expected), len(actual))
     for i, ind in enumerate(list(actual.index)):
         self.assertEqual(expected[i][0], ind)
         self.assertEqual(expected[i][1], actual[ind])
 def test_interval_indexer_2(self):
     # BWV7.7: whole soprano part
     # NB: this test is more rigourous than the others, since it actually uses the DataFrame
     test_parts = [self.bwv77_soprano]
     expected = {'0': TestHorizIntervalIndexerLong.bwv77_S_B_basis['a']}
     setts = {u'simple or compound': u'compound', u'quality': True}
     int_indexer = HorizontalIntervalIndexer(test_parts, setts)
     actual = int_indexer.run()[u'interval.HorizontalIntervalIndexer']
     self.assertEqual(len(expected), len(actual.columns))
     for key in expected.iterkeys():
         self.assertTrue(key in actual)
         self.assertSequenceEqual(list(expected[key].index), list(actual[key].index))
         self.assertSequenceEqual(list(expected[key]), list(actual[key]))
 def test_interval_indexer_3(self):
     """BWV7.7: whole bass part; 'horiz_attach_later' is True"""
     test_parts = pandas.concat([self.bwv77_bass], axis=1)
     test_parts.columns = pandas.MultiIndex.from_product([('A', ), ('0', )])
     setts = {
         'simple or compound': 'compound',
         'quality': True,
         'horiz_attach_later': True
     }
     expected = pandas.read_pickle(
         os.path.join(VIS_PATH, 'tests', 'corpus',
                      'data_horiz_int_ind_3.pickle'))
     actual = HorizontalIntervalIndexer(test_parts, setts).run()
     self.assertTrue(actual.equals(expected))
    def run_my_task(self, inputs, settings, outputs):

        # Set execution settings.
        wrapper_settings = dict( [(k, settings[k]) for k in ('Simple or Compound Intervals', 'Interval Quality', 'Directed', 'Horizontal attach later')] )
        execution_settings = dict()
        if wrapper_settings['Simple or Compound Intervals'] == 0:
            execution_settings['simple or compound'] = 'simple'
        else:
            execution_settings['simple or compound'] = 'compound'
        execution_settings['quality'] = wrapper_settings['Interval Quality']
        execution_settings['mp'] = False
        execution_settings['horiz_attach_later'] = wrapper_settings['Horizontal attach later']
        execution_settings['directed'] = wrapper_settings['Directed']
        
        # Run.
        infile = inputs['NoteRest Interval Indexer Result'][0]['resource_path']
        outfile = outputs['Horizontal Interval Indexer Result'][0]['resource_path']
        data = DataFrame.from_csv(infile, header = [0, 1]) # We know the first two rows constitute a MultiIndex
        horizontal_intervals = HorizontalIntervalIndexer(data, execution_settings).run()
        horizontal_intervals.to_csv(outfile)

        return True