本文整理汇总了Python中pyphant.core.DataContainer.slice2ind方法的典型用法代码示例。如果您正苦于以下问题:Python DataContainer.slice2ind方法的具体用法?Python DataContainer.slice2ind怎么用?Python DataContainer.slice2ind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyphant.core.DataContainer
的用法示例。
在下文中一共展示了DataContainer.slice2ind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extract
# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import slice2ind [as 别名]
def extract(self, field, subscriber=0):
if not hasattr(self, 'paramDim0'):
self.refreshParams()
params = [str(eval('self.paramDim%i.value' %i))
for i in range(len(field.dimensions))]
for dim, arg in enumerate(params):
if arg.startswith('#'):
step = None
if arg == '#:':
start = 0
end = len(field.dimensions[dim].data)
elif arg[1] == ':':
start = 0
end = long(arg[2:]) + 1
elif arg[-1] == ':':
start = long(arg[1: -1])
end = len(field.dimensions[dim].data)
else:
ind = map(long, arg[1:].split(':'))
start = ind[0]
if len(ind) == 1:
end = ind[0] + 1
elif len(ind) >= 2:
end = ind[1] + 1
if len(ind) == 3:
step = ind[2]
if len(ind) > 3:
raise ValueError("Illegal slice with "
"more than two colons.")
params[dim] = slice(start, end, step)
else:
s = DataContainer.slice2ind(arg, field.dimensions[dim])
params[dim] = slice(s.start,
min(s.stop + 1,
len(field.dimensions[dim].data)),
s.step)
result = copy.deepcopy(field[params])
result.seal()
return result