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


Python WorkflowManager._result方法代码示例

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


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

示例1: test_table_1

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [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

示例2: test_table_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [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

示例3: test_lilypond_2

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [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

示例4: test_lilypond_1b

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [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

示例5: test_output_4

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_output_4(self):
     """ensure RuntimeError if self._result is None"""
     test_wc = WorkflowManager([])
     test_wc._result = None  # just in case
     self.assertRaises(RuntimeError, test_wc.output, 'R histogram')
     try:
         test_wc.output('R histogram')
     except RuntimeError as run_err:
         self.assertEqual(WorkflowManager._NO_RESULTS_ERROR, run_err.args[0])
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:11,代码来源:test_workflow.py

示例6: test_get_dataframe_4

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_get_dataframe_4(self):
     # test with name=auto, top_x=5, threshold=7 (so threshold leaves fewer than 3 results)
     test_wc = WorkflowManager([])
     test_wc._result = pandas.Series([i for i in xrange(10, 0, -1)])
     expected = pandas.DataFrame({'data': pandas.Series([10, 9, 8])})
     actual = test_wc._get_dataframe(top_x=5, threshold=7)
     self.assertEqual(len(expected.columns), len(actual.columns))
     for i in expected.columns:
         self.assertSequenceEqual(list(expected.loc[:,i].index), list(actual.loc[:,i].index))
         self.assertSequenceEqual(list(expected.loc[:,i].values), list(actual.loc[:,i].values))
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:12,代码来源:test_workflow.py

示例7: test_lilypond_1a

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_lilypond_1a(self):
     """error conditions: if 'count frequency' is True (but the lengths are okay)"""
     test_wm = WorkflowManager(['fake piece'])
     test_wm._data = ['fake IndexedPiece']
     test_wm._result = ['fake results']
     # test twice like this to make sure (1) the try/except will definitely catch something, and
     # (2) we're not getting hit by another RuntimeError, of which there could be many
     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,代码行数:12,代码来源:test_workflow.py

示例8: test_filter_dataframe_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_filter_dataframe_3(self):
     """test with top_x=3, threshold=5 (so the top_x still removes after threshold), name=auto"""
     test_wc = WorkflowManager([])
     test_wc._result = pandas.DataFrame({'data': pandas.Series([i for i in range(10, 0, -1)])})
     expected = pandas.DataFrame({'data': pandas.Series([10, 9, 8])})
     actual = test_wc._filter_dataframe(top_x=3, threshold=5)
     self.assertEqual(len(expected.columns), len(actual.columns))
     for i in expected.columns:
         self.assertSequenceEqual(list(expected[i].index), list(actual[i].index))
         self.assertSequenceEqual(list(expected[i].values), list(actual[i].values))
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:12,代码来源:test_workflow.py

示例9: test_get_dataframe_2

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_get_dataframe_2(self):
     # test with name='asdf', top_x=3, threshold=auto
     test_wc = WorkflowManager([])
     test_wc._result = pandas.Series([i for i in xrange(10, 0, -1)])
     expected = pandas.DataFrame({'asdf': pandas.Series([10, 9, 8])})
     actual = test_wc._get_dataframe('asdf', 3)
     self.assertEqual(len(expected.columns), len(actual.columns))
     for i in expected.columns:
         self.assertSequenceEqual(list(expected.loc[:,i].index), list(actual.loc[:,i].index))
         self.assertSequenceEqual(list(expected.loc[:,i].values), list(actual.loc[:,i].values))
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:12,代码来源:test_workflow.py

示例10: test_output_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_output_3(self):
     """ensure RuntimeError if there's an invalid instruction"""
     test_wc = WorkflowManager([])
     test_wc._result = [5]  # make sure that's not what causes it
     bad_instruction = 'eat dirt'
     self.assertRaises(RuntimeError, test_wc.output, bad_instruction)
     try:
         test_wc.output(bad_instruction)
     except RuntimeError as run_err:
         self.assertEqual(WorkflowManager._UNRECOGNIZED_INSTRUCTION.format(bad_instruction),
                          run_err.args[0])
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:13,代码来源:test_workflow.py

示例11: test_lilypond_1b

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [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

示例12: test_filter_dataframe_5

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_filter_dataframe_5(self):
     """test with top_x=3, threshold=auto, name='asdf'; many input columns"""
     test_wc = WorkflowManager([])
     test_wc._result = pandas.DataFrame({('1', 'b'): pandas.Series([i for i in range(10, 0, -1)]),
                                         ('1', 'z'): pandas.Series([i for i in range(10, 20)]),
                                         ('2', 'e'): pandas.Series([i for i in range(40, 900)])})
     expected = pandas.DataFrame({'asdf': pandas.Series([10, 9, 8])})
     actual = test_wc._filter_dataframe(top_x=3, name='asdf')
     self.assertEqual(len(expected.columns), len(actual.columns))
     for i in expected.columns:
         self.assertSequenceEqual(list(expected[i].index), list(actual[i].index))
         self.assertSequenceEqual(list(expected[i].values), list(actual[i].values))
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:14,代码来源:test_workflow.py

示例13: test_export_3

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_export_3(self, mock_gdf):
     # --> the method works as expected for CSV, Excel, and Stata when _result is a DataFrame
     test_wm = WorkflowManager([])
     test_wm._result = mock.MagicMock(spec=pandas.DataFrame)
     test_wm.export(u'CSV', u'test_path')
     test_wm.export(u'Excel', u'test_path')
     test_wm.export(u'Stata', u'test_path')
     test_wm.export(u'HTML', u'test_path')
     test_wm._result.to_csv.assert_called_once_with(u'test_path.csv')
     test_wm._result.to_stata.assert_called_once_with(u'test_path.dta')
     test_wm._result.to_excel.assert_called_once_with(u'test_path.xlsx')
     test_wm._result.to_html.assert_called_once_with(u'test_path.html')
     self.assertEqual(0, mock_gdf.call_count)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:15,代码来源:test_workflow.py

示例14: test_export_4

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_export_4(self, mock_gdf):
     # --> test_export_3() with a valid extension already on
     test_wm = WorkflowManager([])
     test_wm._result = mock.MagicMock(spec=pandas.DataFrame)
     test_wm.export(u'CSV', u'test_path.csv')
     test_wm.export(u'Excel', u'test_path.xlsx')
     test_wm.export(u'Stata', u'test_path.dta')
     test_wm.export(u'HTML', u'test_path.html')
     test_wm._result.to_csv.assert_called_once_with(u'test_path.csv')
     test_wm._result.to_stata.assert_called_once_with(u'test_path.dta')
     test_wm._result.to_excel.assert_called_once_with(u'test_path.xlsx')
     test_wm._result.to_html.assert_called_once_with(u'test_path.html')
     self.assertEqual(0, mock_gdf.call_count)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:15,代码来源:test_workflow.py

示例15: test_histogram_1

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _result [as 别名]
 def test_histogram_1(self, mock_call, mock_gdf, mock_join):
     # with specified pathname; last experiment was intervals with 20 pieces; self._result is DF
     test_wc = WorkflowManager([])
     test_wc._previous_exp = u'intervals'
     test_wc._data = [1 for _ in xrange(20)]
     test_wc._result = MagicMock(spec=pandas.DataFrame)
     path = u'pathname!'
     actual = test_wc._make_histogram(path)
     self.assertEqual(0, mock_gdf.call_count)
     expected_args = [u'Rscript', u'--vanilla', mock_join.return_value,
                      path + u'.dta', path + u'.png', u'int', u'20']
     mock_call.assert_called_once_with(expected_args)
     self.assertEqual(path + u'.png', actual)
     self.assertEqual(1, mock_join.call_count)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:16,代码来源:test_workflow.py


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