本文整理汇总了Python中vis.workflow.WorkflowManager类的典型用法代码示例。如果您正苦于以下问题:Python WorkflowManager类的具体用法?Python WorkflowManager怎么用?Python WorkflowManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorkflowManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_settings_2
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,代码行数:7,代码来源:test_workflow.py
示例2: test_intervs_1
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,代码行数:26,代码来源:test_workflow_experiments.py
示例3: test_interval_ngrams_2
def test_interval_ngrams_2(self, mock_two, mock_all, mock_var, mock_rfa):
# --> same as test_interval_ngrams_1(), but with "count frequency" set to False
# 1.) prepare mocks
ind_pieces = [MagicMock(spec=IndexedPiece) for _ in xrange(3)]
mock_rfa.return_value = u'mock_rfa() return value'
mock_two.return_value = [u'mock_two() return value']
mock_all.return_value = [u'mock_all() return value']
mock_var.return_value = [u'mock_var() return value']
expected = [mock_all.return_value, mock_two.return_value, mock_var.return_value]
# 2.) run the test
test_wm = WorkflowManager(ind_pieces)
test_wm.settings(0, u'voice combinations', u'all')
test_wm.settings(1, u'voice combinations', u'all pairs')
test_wm.settings(2, u'voice combinations', u'[[0, 1]]')
test_wm.settings(None, 'count frequency', False)
actual = test_wm._interval_ngrams()
# 3.) verify the mocks
# NB: in actual use, _run_freq_agg() would have the final say on the value of
# test_wm._result... but it's mocked out, which means we can test whether
# _interval_ngrams() puts the right stuff there
self.assertEqual(3, len(test_wm._result))
for ret_val in expected:
self.assertTrue(ret_val in test_wm._result)
mock_two.assert_called_once_with(1)
mock_all.assert_called_once_with(0)
mock_var.assert_called_once_with(2)
self.assertEqual(0, mock_rfa.call_count)
self.assertEqual(expected, actual)
self.assertSequenceEqual(expected, test_wm._result)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:29,代码来源:test_workflow_experiments.py
示例4: test_intervs_3
def test_intervs_3(self, mock_int, mock_nri, mock_rep, mock_rfa, mock_ror):
# --> test whether _intervs() when we specify an impossible voice pair ('[[0, 1, 2]]')
# 1.) prepare the test and mocks
test_settings = {u'simple or compound': u'compound', u'quality': False}
test_pieces = [MagicMock(IndexedPiece, name=x) for x in [u'test1', u'test2', u'test3']]
the_dicts = [MagicMock(dict, name=u'get_data() piece' + str(i), return_value=[4]) \
for i in xrange(3)]
returns = the_dicts
def side_effect(*args):
# NB: we need to accept "args" as a mock framework formality
# pylint: disable=W0613
return returns.pop(0)
for piece in test_pieces:
piece.get_data.side_effect = side_effect
mock_ror.return_value = [pandas.Series(['Rest', 'P5', 'm3']) for _ in xrange(len(test_pieces))]
expected = [pandas.Series(['Rest', 'P5', 'm3']) for _ in xrange(len(test_pieces))]
expected_pairs = [[0, 1, 2]]
expected_error_message = WorkflowManager._REQUIRE_PAIRS_ERROR % len(expected_pairs[0])
# 2.) run the test
test_wc = WorkflowManager(test_pieces)
# (have to set the voice-pair settings)
for i in xrange(len(test_pieces)):
test_wc._settings[i][u'voice combinations'] = unicode(expected_pairs)
# 3.) verify
self.assertRaises(RuntimeError, test_wc._intervs)
try:
test_wc._intervs()
except RuntimeError as runerr:
self.assertEqual(expected_error_message, runerr.message)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:29,代码来源:test_workflow_experiments.py
示例5: test_intervs_1
def test_intervs_1(self, mock_int, mock_nri, mock_rfa, mock_ror):
# --> test whether _intervs() calls all those things in the right order, with the right
# args, using all the default settings
# 1.) prepare the test and mocks
test_settings = {u'simple or compound': u'compound', u'quality': False}
test_pieces = [MagicMock(IndexedPiece, name=x) for x in [u'test1', u'test2', u'test3']]
returns = [MagicMock(dict, name=u'get_data() piece' + str(i), return_value=[4]) \
for i in xrange(3)]
def side_effect(*args):
# NB: we need to accept "args" as a mock framework formality
# pylint: disable=W0613
return returns.pop(0)
for piece in test_pieces:
piece.get_data.side_effect = side_effect
mock_ror.return_value = [pandas.Series(['Rest', 'P5', 'm3']) for _ in xrange(len(test_pieces))]
expected = [pandas.Series(['P5', 'm3'], index=[1, 2]) for _ in xrange(len(test_pieces))]
# 2.) run the test
test_wc = WorkflowManager(test_pieces)
actual = test_wc._intervs()
# 3.) confirm everything was called in the right order
for piece in test_pieces:
self.assertEqual(1, piece.get_data.call_count)
piece.get_data.assert_called_once_with([mock_nri, mock_int], test_settings)
self.assertEqual(len(test_pieces), mock_ror.call_count)
mock_rfa.assert_called_once_with()
self.assertEqual(len(test_pieces), len(expected), len(actual))
for i in xrange(len(actual)):
# NB: in real use, _run_freq_agg() would aggregate a piece's voice pairs, so we
# wouldn't need to ask for the [0] index here... but also, this experiment shouldn't
# call _run_freq_agg() anyway
self.assertSequenceEqual(list(expected[i]), list(actual[i][0]))
self.assertSequenceEqual(list(expected[i].index), list(actual[i][0].index))
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:32,代码来源:test_workflow_experiments.py
示例6: test_intervs_3
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,代码行数:30,代码来源:test_workflow_experiments.py
示例7: test_load_1
def test_load_1(self):
# that "get_data" is called correctly on each thing
test_wc = WorkflowManager([])
test_wc._data = [mock.MagicMock(spec=IndexedPiece) for _ in xrange(5)]
test_wc.load(u'pieces')
for mock_piece in test_wc._data:
mock_piece.get_data.assert_called_once_with([noterest.NoteRestIndexer])
self.assertTrue(test_wc._loaded)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:8,代码来源:test_workflow.py
示例8: test_output_4
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,代码行数:9,代码来源:test_workflow.py
示例9: test_lilypond_1a
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,代码行数:10,代码来源:test_workflow.py
示例10: test_get_dataframe_2
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,代码行数:10,代码来源:test_workflow.py
示例11: test_get_dataframe_4
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,代码行数:10,代码来源:test_workflow.py
示例12: test_filter_dataframe_3
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,代码行数:10,代码来源:test_workflow.py
示例13: test_settings_9
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,代码行数:10,代码来源:test_workflow.py
示例14: test_output_3
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,代码行数:11,代码来源:test_workflow.py
示例15: test_filter_dataframe_5
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,代码行数:12,代码来源:test_workflow.py
示例16: test_ngrams_1
def test_ngrams_1(self):
# test the two highest voices of bwv77; 2-grams
test_wm = WorkflowManager(['vis/tests/corpus/bwv77.mxl'])
test_wm.load('pieces')
test_wm.settings(0, 'voice combinations', '[[0, 1]]')
test_wm.settings(0, 'n', 2)
test_wm.settings(0, 'continuer', '_')
actual = test_wm.run('interval n-grams')
exp_ind = list(NGramsTests.EXPECTED_1.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_1[ind_item], actual[ind_item])
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:14,代码来源:test_workflow_integration.py
示例17: test_interval_ngrams_1
def test_interval_ngrams_1(self, mock_two, mock_all, mock_var, mock_rfa):
# --> test with three pieces, each of which requires a different helper
# 1.) prepare mocks
ind_pieces = [MagicMock(spec=IndexedPiece) for _ in xrange(3)]
mock_rfa.return_value = u'mock_rfa() return value'
mock_two.return_value = [u'mock_two() return value']
mock_all.return_value = [u'mock_all() return value']
mock_var.return_value = [u'mock_var() return value']
expected = [mock_all.return_value, mock_two.return_value, mock_var.return_value]
# 2.) run the test
test_wm = WorkflowManager(ind_pieces)
test_wm.settings(0, u'voice combinations', u'all')
test_wm.settings(1, u'voice combinations', u'all pairs')
test_wm.settings(2, u'voice combinations', u'[[0, 1]]')
actual = test_wm._interval_ngrams()
# 3.) verify the mocks
# NB: in actual use, _run_freq_agg() would have the final say on the value of
# test_wm._result... but it's mocked out, which means we can test whether
# _interval_ngrams() puts the right stuff there
mock_two.assert_called_once_with(1)
mock_all.assert_called_once_with(0)
mock_var.assert_called_once_with(2)
mock_rfa.assert_called_once_with()
self.assertSequenceEqual(expected, actual)
self.assertSequenceEqual(expected, test_wm._result)
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:25,代码来源:test_workflow_experiments.py
示例18: test_ngrams_2
def test_ngrams_2(self):
# test all two-part combinations of bwv77; 5-grams
test_wm = WorkflowManager(['vis/tests/corpus/bwv77.mxl'])
test_wm.load('pieces')
test_wm.settings(0, 'voice combinations', 'all pairs')
test_wm.settings(0, 'n', 5)
test_wm.settings(0, 'continuer', '_')
actual = test_wm.run('interval n-grams')[:10]
exp_ind = list(NGramsTests.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(NGramsTests.EXPECTED_2[ind_item], actual[ind_item])
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:14,代码来源:test_workflow_integration.py
示例19: test_ngrams_9c
def test_ngrams_9c(self):
# same as 9b but 'interval quality' is set to False (by default).
test_wm = WorkflowManager(['vis/tests/corpus/Kyrie_short.krn'])
test_wm.load()
test_wm.settings(0, 'voice combinations', '[[1,3]]')
test_wm.settings(0, 'n', 2)
test_wm.settings(0, 'offset interval', 2.0)
actual = test_wm.run('interval n-grams')
exp_ind = list(NGramsTests.EXPECTED_9c.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_9c[ind_item], actual[ind_item])
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:14,代码来源:test_workflow_integration.py
示例20: test_ngrams_6
def test_ngrams_6(self):
# test madrigal51 with all-voice 2-grams and rests
test_wm = WorkflowManager(['vis/tests/corpus/madrigal51.mxl'])
test_wm.settings(0, 'voice combinations', 'all')
test_wm.settings(None, 'include rests', True)
test_wm.load('pieces')
test_wm.settings(0, 'continuer', '_')
actual = test_wm.run('interval n-grams')
exp_ind = list(NGramsTests.EXPECTED_6.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_6[ind_item], actual[ind_item])
开发者ID:ELVIS-Project,项目名称:fiddle-tunes,代码行数:14,代码来源:test_workflow_integration.py
注:本文中的vis.workflow.WorkflowManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论