本文整理汇总了Python中vis.workflow.WorkflowManager._data[i]方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowManager._data[i]方法的具体用法?Python WorkflowManager._data[i]怎么用?Python WorkflowManager._data[i]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vis.workflow.WorkflowManager
的用法示例。
在下文中一共展示了WorkflowManager._data[i]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lilypond_4
# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _data[i] [as 别名]
def test_lilypond_4(self, mock_metadata, test_ip):
# make sure it works correctly with three pieces that have three parts
# ("voice combinations" is "all")
# 1: prepare
input_path = u'carpathia'
get_data_ret = lambda *x: ['** ' + str(x[1]) if len(x) == 2 else '** ' + str(x[2][0][-3:])]
num_parts = 3 # how many parts per piece? -- NB: diffferent from first test
piece_list = ['test_piece_1.mei', 'test_piece_2.mei', 'test_piece_3.mei']
test_wm = WorkflowManager(piece_list)
for i in xrange(len(piece_list)):
test_wm._data[i] = mock.MagicMock(spec_set=IndexedPiece)
test_wm._data[i].get_data.side_effect = get_data_ret
mock_metadata.return_value = ['part %i' % x for x in xrange(num_parts)]
# the results will be like this: [['fake result 0-0', 'fake result 0-1'],
# ['fake result 1-0', 'fake result 1-1']]
exp_results = [['fake result ' + str(i) + '-' + str(j) for j in xrange(num_parts)] \
for i in xrange(len(piece_list))]
test_wm._result = exp_results
test_wm.settings(None, 'count frequency', False)
test_wm.settings(0, 'voice combinations', 'all')
test_wm.settings(1, 'voice combinations', 'all')
test_wm.settings(2, 'voice combinations', 'all')
#exp_part_labels = [[[0, 2], [1, 2]] for _ in xrange(len(piece_list))]
# 2: run
test_wm._make_lilypond(input_path)
# 3: check
self.assertEqual(len(piece_list), test_ip.call_count) # even though we don't use them
lily_ind_list = [lilypond.AnnotationIndexer,
lilypond.AnnotateTheNoteIndexer,
lilypond.PartNotesIndexer]
for i, piece in enumerate(test_wm._data):
self.assertEqual(num_parts + 1, piece.get_data.call_count)
for j in xrange(num_parts):
piece.get_data.assert_any_call(lily_ind_list,
None, # {'part_names': exp_part_labels[j]},
[exp_results[i][j]])
# NB: the output_pathname is different from the previous two tests
sett_dict = {u'run_lilypond': True,
u'output_pathname': input_path + '-' + str(i) + '.ly',
u'annotation_part': [get_data_ret(0, 0, [z])[0] for z in exp_results[i]]}
piece.get_data.assert_any_call([lilypond.LilyPondIndexer], sett_dict)
示例2: test_lilypond_2
# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import _data[i] [as 别名]
def test_lilypond_2(self, test_ip):
# make sure it works correctly with one piece that has one part
# ("voice combinations" with literal_eval())
# 1: prepare
input_path = u'carpathia'
get_data_ret = lambda *x: ['** ' + str(x[1]) if len(x) == 2 else '** ' + str(x[2][0][-3:])]
num_parts = 1 # how many parts per piece?
piece_list = ['test_piece.mei']
test_wm = WorkflowManager(piece_list)
for i in xrange(len(piece_list)):
test_wm._data[i] = mock.MagicMock(spec_set=IndexedPiece)
test_wm._data[i].get_data.side_effect = get_data_ret
# the results will be like this: [['fake result 0-0', 'fake result 0-1'],
# ['fake result 1-0', 'fake result 1-1']]
exp_results = [['fake result ' + str(i) + '-' + str(j) for j in xrange(num_parts)] \
for i in xrange(len(piece_list))]
test_wm._result = exp_results
test_wm.settings(None, 'count frequency', False)
test_wm.settings(0, 'voice combinations', '[[0]]')
#exp_part_labels = [{'part_names': [[0]]}]
# 2: run
test_wm._make_lilypond(input_path)
# 3: check
self.assertEqual(len(piece_list), test_ip.call_count) # even though we don't use them
lily_ind_list = [lilypond.AnnotationIndexer,
lilypond.AnnotateTheNoteIndexer,
lilypond.PartNotesIndexer]
for i, piece in enumerate(test_wm._data):
self.assertEqual(num_parts + 1, piece.get_data.call_count)
for j in xrange(num_parts):
piece.get_data.assert_any_call(lily_ind_list,
None, # {'part_names': exp_part_labels[i]},
[exp_results[i][j]])
sett_dict = {u'run_lilypond': True,
u'output_pathname': input_path + '.ly',
u'annotation_part': [get_data_ret(0, 0, [z])[0] for z in exp_results[i]]}
piece.get_data.assert_any_call([lilypond.LilyPondIndexer], sett_dict)