当前位置: 首页>>代码示例>>Python>>正文


Python WorkflowManager.settings方法代码示例

本文整理汇总了Python中vis.workflow.WorkflowManager.settings方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowManager.settings方法的具体用法?Python WorkflowManager.settings怎么用?Python WorkflowManager.settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vis.workflow.WorkflowManager的用法示例。


在下文中一共展示了WorkflowManager.settings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_settings_2

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_settings_2(self, mock_ip):
     # - if index is None, field and value are valid, it'll set for all IPs
     test_wm = WorkflowManager([u'a', u'b', u'c'])
     self.assertEqual(3, mock_ip.call_count)  # to make sure we're using the mock, not real IP
     test_wm.settings(None, u'filter repeats', True)
     for i in xrange(3):
         self.assertEqual(True, test_wm._settings[i][u'filter repeats'])
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:9,代码来源:test_workflow.py

示例2: test_intervs_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
    def test_intervs_3(self, mock_guc, mock_rfa, mock_rep):
        """Ensure _intervs() calls everything in the right order, with the right args & settings.
           This uses the default *except* requires removing rests, so it's more complex."""
        test_settings = {'simple or compound': 'compound', 'quality': False}
        test_pieces = [MagicMock(spec_set=IndexedPiece) for _ in range(3)]
        returns = [pandas.DataFrame([pandas.Series(['3', 'Rest', '5'])],
                                    index=[['interval.IntervalIndexer'], ['0,1']]).T
                   for i in range(len(test_pieces))]
        for piece in test_pieces:
            piece.get_data.side_effect = lambda *x: returns.pop(0)
        exp_series_ind = ('interval.IntervalIndexer', '0,1')
        expected_df = pandas.DataFrame({exp_series_ind: pandas.Series(['3', '5'], index=[0, 2])})
        exp_analyzers = [noterest.NoteRestIndexer, interval.IntervalIndexer]

        test_wc = WorkflowManager(test_pieces)
        test_wc.settings(None, 'count frequency', False)
        actual = test_wc._intervs()  # pylint: disable=protected-access

        self.assertEqual(0, mock_guc.call_count)
        self.assertEqual(len(test_pieces), len(actual))
        self.assertEqual(0, mock_rfa.call_count)
        self.assertEqual(0, mock_rep.call_count)
        for piece in test_pieces:
            piece.get_data.assert_called_once_with(exp_analyzers, test_settings)
        for i in range(len(actual)):
            self.assertSequenceEqual(list(expected_df.columns), list(actual[i].columns))
            self.assertSequenceEqual(list(expected_df[exp_series_ind].index),
                                     list(actual[i][exp_series_ind].index))
            self.assertSequenceEqual(list(expected_df[exp_series_ind].values),
                                     list(actual[i][exp_series_ind].values))
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:32,代码来源:test_workflow_experiments.py

示例3: test_table_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
    def test_table_3(self):
        '''
        _make_table():

        - "count frequency" is False
        - file extension not on "pathname"
        - there are several IndexedPiece objects
        '''
        test_wm = WorkflowManager([])
        test_wm.settings(None, 'count frequency', False)
        test_wm._result = [mock.MagicMock(spec_set=pandas.DataFrame) for _ in range(5)]
        test_wm._data = ['boop' for _ in range(len(test_wm._result))]
        top_x = None
        threshold = None
        pathname = 'test_path'

        test_wm._make_table('CSV', pathname, top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Excel', pathname, top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Stata', pathname, top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('HTML', pathname, top_x, threshold)  # pylint: disable=protected-access

        for i in range(len(test_wm._result)):
            test_wm._result[i].to_csv.assert_called_once_with('{}-{}{}'.format(pathname, i, '.csv'))
            test_wm._result[i].to_excel.assert_called_once_with('{}-{}{}'.format(pathname, i, '.xlsx'))
            test_wm._result[i].to_stata.assert_called_once_with('{}-{}{}'.format(pathname, i, '.dta'))
            test_wm._result[i].to_html.assert_called_once_with('{}-{}{}'.format(pathname, i, '.html'))
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:28,代码来源:test_workflow.py

示例4: test_table_1

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
    def test_table_1(self, mock_fdf):
        '''
        _make_table():

        - "count frequency" is True
        - file extension on "pathname" with period
        '''
        test_wm = WorkflowManager([])
        test_wm.settings(None, 'count frequency', True)  # just to be 100% clear
        mock_fdf.return_value = mock.MagicMock(spec_set=pandas.DataFrame)
        test_wm._result = mock_fdf.return_value  # to avoid a RuntimeError
        test_wm._previous_exp = 'intervals'  # to get the proper "exp_name"
        top_x = None
        threshold = None
        exp_name = 'Interval Frequency'
        pathname = 'test_path'

        test_wm._make_table('CSV', pathname + '.csv', top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Excel', pathname + '.xlsx', top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Stata', pathname + '.dta', top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('HTML', pathname + '.html', top_x, threshold)  # pylint: disable=protected-access

        mock_fdf.return_value.to_csv.assert_called_once_with('test_path.csv')
        mock_fdf.return_value.to_stata.assert_called_once_with('test_path.dta')
        mock_fdf.return_value.to_excel.assert_called_once_with('test_path.xlsx')
        mock_fdf.return_value.to_html.assert_called_once_with('test_path.html')
        self.assertSequenceEqual([mock.call(top_x=top_x, threshold=threshold, name=exp_name) for _ in range(4)],
                                 mock_fdf.call_args_list)
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:30,代码来源:test_workflow.py

示例5: test_lilypond_2

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
    def test_lilypond_2(self):
        """one piece with one part; specified pathname; and there's a NaN in the Series!"""
        mock_ips = [MagicMock(spec_set=IndexedPiece)]
        mock_ips[0].get_data.return_value = ['ready for LilyPond']
        result = [pandas.DataFrame({('analyzer', 'clarinet'): pandas.Series(range(10))})]
        result[0][('analyzer', 'clarinet')].iloc[0] = NaN
        exp_series = pandas.Series(range(1, 10), index=range(1, 10))  # to test dropna() was run
        pathname = 'this_path'
        expected = ['this_path.ly']
        exp_get_data_calls = [mock.call([lilypond_ind.AnnotationIndexer,
                                         lilypond_exp.AnnotateTheNoteExperimenter,
                                         lilypond_exp.PartNotesExperimenter],
                                        {'part_names': ['analyzer: clarinet'],
                                         'column': 'lilypond.AnnotationIndexer'},
                                        [mock.ANY]),
                              mock.call([lilypond_exp.LilyPondExperimenter],
                                        {'run_lilypond': True,
                                         'annotation_part': ['ready for LilyPond'],
                                         'output_pathname': expected[0]})]

        test_wm = WorkflowManager(mock_ips)
        test_wm._result = result
        test_wm.settings(None, 'count frequency', False)
        test_wm._make_lilypond(pathname)

        self.assertEqual(2, mock_ips[0].get_data.call_count)
        self.assertSequenceEqual(exp_get_data_calls, mock_ips[0].get_data.call_args_list)
        # check that dropna() was run
        actual_series = mock_ips[0].get_data.call_args_list[0][0][2][0]
        self.assertSequenceEqual(list(exp_series.index), list(actual_series.index))
        self.assertSequenceEqual(list(exp_series.values), list(actual_series.values))
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:33,代码来源:test_workflow.py

示例6: test_intervs_1

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
    def test_intervs_1(self, mock_guc, mock_rfa, mock_rep):
        """Ensure _intervs() calls everything in the right order, with the right args & settings.
           This test uses all the default settings."""
        test_settings = {'simple or compound': 'compound', 'quality': False}
        test_pieces = [MagicMock(spec_set=IndexedPiece) for _ in range(3)]
        returns = ['get_data() {}'.format(i) for i in range(len(test_pieces))]
        for piece in test_pieces:
            piece.get_data.side_effect = lambda *x: returns.pop(0)
        expected = ['get_data() {}'.format(i) for i in range(len(test_pieces))]
        exp_analyzers = [noterest.NoteRestIndexer, interval.IntervalIndexer]

        test_wc = WorkflowManager(test_pieces)
        test_wc.settings(None, 'include rests', True)
        actual = test_wc._intervs()  # pylint: disable=protected-access

        self.assertEqual(0, mock_guc.call_count)
        self.assertEqual(len(test_pieces), len(expected), len(actual))
        self.assertEqual(0, mock_rep.call_count)
        mock_rfa.assert_called_once_with('interval.IntervalIndexer')
        for piece in test_pieces:
            piece.get_data.assert_called_once_with(exp_analyzers, test_settings)
        for i in range(len(actual)):
            # NB: in real use, _run_freq_agg() would aggregate a piece's voice pairs and save it in
            #     self._result... but since that method's mocked out, we have to check here the
            #     return of each piece's get_data() call
            self.assertSequenceEqual(expected[i], actual[i])
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:28,代码来源:test_workflow_experiments.py

示例7: test_lilypond_1b

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_lilypond_1b(self):
     """error conditions: if the lengths are different, (but 'count frequency' is okay)"""
     test_wm = WorkflowManager(['fake piece'])
     test_wm._data = ['fake IndexedPiece']
     test_wm._result = ['fake results', 'more fake results', 'so many fake results']
     test_wm.settings(None, 'count frequency', False)
     with self.assertRaises(RuntimeError) as run_err:
         test_wm._make_lilypond(['paths'])
     self.assertEqual(WorkflowManager._COUNT_FREQUENCY_MESSAGE, run_err.exception.args[0])
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:11,代码来源:test_workflow.py

示例8: test_settings_9

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_settings_9(self, mock_ip):
     # - if trying to set 'offset interval' to 0, it should actually be set to None
     test_wm = WorkflowManager([u'a', u'b', u'c'])
     self.assertEqual(3, mock_ip.call_count)  # to make sure we're using the mock, not real IP
     # "None" is default value, so first set to non-zero
     test_wm.settings(1, u'offset interval', 4.0)
     self.assertEqual(4.0, test_wm._settings[1][u'offset interval'])
     # now run our test
     test_wm.settings(1, u'offset interval', 0)
     self.assertEqual(None, test_wm._settings[1][u'offset interval'])
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:12,代码来源:test_workflow.py

示例9: test_lilypond_1b

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_lilypond_1b(self):
     # error conditions: if the lengths are different, (but 'count frequency' is okay)
     test_wm = WorkflowManager(['fake piece'])
     test_wm._data = ['fake IndexedPiece']
     test_wm._result = ['fake results', 'more fake results', 'so many fake results']
     test_wm.settings(None, 'count frequency', False)
     self.assertRaises(RuntimeError, test_wm._make_lilypond, ['paths'])
     try:
         test_wm._make_lilypond(['paths'])
     except RuntimeError as the_err:
         self.assertEqual(WorkflowManager._COUNT_FREQUENCY_MESSAGE, the_err.message)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:13,代码来源:test_workflow.py

示例10: test_intervals_2

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_intervals_2(self):
     # test all combinations of bwv77
     test_wm = WorkflowManager(['vis/tests/corpus/bwv77.mxl'])
     test_wm.load('pieces')
     test_wm.settings(0, 'voice combinations', 'all pairs')
     actual = test_wm.run('intervals')
     exp_ind = list(IntervalsTests.EXPECTED_2.index)
     act_ind = list(actual.index)
     for ind_item in exp_ind:
         self.assertTrue(ind_item in act_ind)
     for ind_item in exp_ind:
         self.assertEqual(IntervalsTests.EXPECTED_2[ind_item], actual[ind_item])
开发者ID:willingc,项目名称:vis,代码行数:14,代码来源:test_workflow_integration.py

示例11: test_intervals_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_intervals_3(self):
     # test all combinations of madrigal51 without rests
     test_wm = WorkflowManager(['vis/tests/corpus/madrigal51.mxl'])
     test_wm.load('pieces')
     test_wm.settings(0, 'voice combinations', 'all pairs')
     test_wm.settings(None, 'include rests', False)
     actual = test_wm.run('intervals')
     exp_ind = list(IntervalsTests.EXPECTED_3.index)
     act_ind = list(actual.index)
     for ind_item in exp_ind:
         self.assertTrue(ind_item in act_ind)
     for ind_item in exp_ind:
         self.assertEqual(IntervalsTests.EXPECTED_3[ind_item], actual[ind_item])
开发者ID:willingc,项目名称:vis,代码行数:15,代码来源:test_workflow_integration.py

示例12: test_ngrams_8

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_ngrams_8(self):
     # test_ngrams_7 *but* with part combinations specified rather than 'all pairs'
     test_wm = WorkflowManager(['vis/tests/corpus/vis_Test_Piece.xml'])
     test_wm.load('pieces')
     test_wm.settings(0, 'voice combinations', '[[0,1], [0,2], [0,3], [1,2], [1,3], [2,3]]')
     test_wm.settings(0, 'n', 2)
     actual = test_wm.run('interval n-grams')
     exp_ind = list(NGramsTests.EXPECTED_7.index)  # yes, this *should* be EXPECTED_7
     act_ind = list(actual.index)
     self.assertEqual(len(exp_ind), len(act_ind))
     for ind_item in exp_ind:
         self.assertTrue(ind_item in act_ind)
         self.assertEqual(NGramsTests.EXPECTED_7[ind_item], actual[ind_item])
开发者ID:willingc,项目名称:vis,代码行数:15,代码来源:test_workflow_integration.py

示例13: test_ngrams_7

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_ngrams_7(self):
     # test all two-part combinations of the test piece; 2-grams
     test_wm = WorkflowManager(['vis/tests/corpus/vis_Test_Piece.xml'])
     test_wm.load('pieces')
     test_wm.settings(0, 'voice combinations', 'all pairs')
     test_wm.settings(0, 'n', 2)
     actual = test_wm.run('interval n-grams')
     exp_ind = list(NGramsTests.EXPECTED_7.index)
     act_ind = list(actual.index)
     self.assertEqual(len(exp_ind), len(act_ind))
     for ind_item in exp_ind:
         self.assertTrue(ind_item in act_ind)
         self.assertEqual(NGramsTests.EXPECTED_7[ind_item], actual[ind_item])
开发者ID:willingc,项目名称:vis,代码行数:15,代码来源:test_workflow_integration.py

示例14: test_ngrams_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_ngrams_3(self):
     # test all voices of bwv77; 1-grams
     test_wm = WorkflowManager(['vis/tests/corpus/bwv77.mxl'])
     test_wm.load('pieces')
     test_wm.settings(0, 'voice combinations', 'all')
     test_wm.settings(0, 'n', 1)
     actual = test_wm.run('interval n-grams')
     exp_ind = list(NGramsTests.EXPECTED_3.index)
     act_ind = list(actual.index)
     for ind_item in exp_ind:
         self.assertTrue(ind_item in act_ind)
     for ind_item in exp_ind:
         self.assertEqual(NGramsTests.EXPECTED_3[ind_item], actual[ind_item])
开发者ID:willingc,项目名称:vis,代码行数:15,代码来源:test_workflow_integration.py

示例15: test_run_off_rep_1

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import settings [as 别名]
 def test_run_off_rep_1(self):
     """run neither indexer"""
     # setup
     workm = WorkflowManager(['', '', ''])
     workm._data = [None, MagicMock(spec=IndexedPiece), None]
     workm.settings(1, 'offset interval', 0)
     workm.settings(1, 'filter repeats', False)
     in_val = 42
     # run
     actual = workm._run_off_rep(1, in_val)
     # test
     self.assertEqual(in_val, actual)
     self.assertEqual(0, workm._data[1].get_data.call_count)
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:15,代码来源:test_workflow.py


注:本文中的vis.workflow.WorkflowManager.settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。