本文整理汇总了Python中nipype.MapNode.get_output方法的典型用法代码示例。如果您正苦于以下问题:Python MapNode.get_output方法的具体用法?Python MapNode.get_output怎么用?Python MapNode.get_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nipype.MapNode
的用法示例。
在下文中一共展示了MapNode.get_output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mapnode_nested
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import get_output [as 别名]
def test_mapnode_nested():
cwd = os.getcwd()
wd = mkdtemp()
os.chdir(wd)
from nipype import MapNode, Function
def func1(in1):
return in1 + 1
n1 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=True,
name='n1')
n1.inputs.in1 = [[1, [2]], 3, [4, 5]]
n1.run()
print(n1.get_output('out'))
yield assert_equal, n1.get_output('out'), [[2, [3]], 4, [5, 6]]
n2 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=False,
name='n1')
n2.inputs.in1 = [[1, [2]], 3, [4, 5]]
error_raised = False
try:
n2.run()
except Exception as e:
from nipype.pipeline.engine.base import logger
logger.info('Exception: %s' % str(e))
error_raised = True
yield assert_true, error_raised
示例2: test_mapnode_nested
# 需要导入模块: from nipype import MapNode [as 别名]
# 或者: from nipype.MapNode import get_output [as 别名]
def test_mapnode_nested(tmpdir):
tmpdir.chdir()
from nipype import MapNode, Function
def func1(in1):
return in1 + 1
n1 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=True,
name='n1')
n1.inputs.in1 = [[1, [2]], 3, [4, 5]]
n1.run()
print(n1.get_output('out'))
assert n1.get_output('out') == [[2, [3]], 4, [5, 6]]
n2 = MapNode(Function(input_names=['in1'],
output_names=['out'],
function=func1),
iterfield=['in1'],
nested=False,
name='n1')
n2.inputs.in1 = [[1, [2]], 3, [4, 5]]
with pytest.raises(Exception) as excinfo:
n2.run()
assert "can only concatenate list" in str(excinfo.value)