本文整理汇总了Python中org.meteoinfo.data.ArrayMath.setSection_List方法的典型用法代码示例。如果您正苦于以下问题:Python ArrayMath.setSection_List方法的具体用法?Python ArrayMath.setSection_List怎么用?Python ArrayMath.setSection_List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.meteoinfo.data.ArrayMath
的用法示例。
在下文中一共展示了ArrayMath.setSection_List方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setitem__
# 需要导入模块: from org.meteoinfo.data import ArrayMath [as 别名]
# 或者: from org.meteoinfo.data.ArrayMath import setSection_List [as 别名]
def __setitem__(self, indices, value):
#print type(indices)
if isinstance(indices, MIArray):
if isinstance(value, MIArray):
value = value.asarray()
ArrayMath.setValue(self.array, indices.array, value)
return None
if not isinstance(indices, tuple):
inds = []
inds.append(indices)
indices = inds
if self.ndim == 0:
self.array.setObject(0, value)
return None
if len(indices) != self.ndim:
print 'indices must be ' + str(self.ndim) + ' dimensions!'
raise IndexError()
ranges = []
flips = []
onlyrange = True
alllist = True
for i in range(0, self.ndim):
k = indices[i]
if isinstance(k, int):
sidx = k
if sidx < 0:
sidx = self._shape[i] + sidx
eidx = sidx
step = 1
alllist = False
elif isinstance(k, (list, tuple, MIArray)):
if isinstance(k, MIArray):
k = k.aslist()
onlyrange = False
ranges.append(k)
continue
else:
sidx = 0 if k.start is None else k.start
if sidx < 0:
sidx = self._shape[i] + sidx
eidx = self._shape[i] if k.stop is None else k.stop
if eidx < 0:
eidx = self._shape[i] + eidx
eidx -= 1
step = 1 if k.step is None else k.step
alllist = False
if step < 0:
step = abs(step)
flips.append(i)
rr = Range(sidx, eidx, step)
ranges.append(rr)
if isinstance(value, (list,tuple)):
value = ArrayUtil.array(value)
if isinstance(value, MIArray):
value = value.asarray()
if onlyrange:
r = ArrayMath.setSection(self.array, ranges, value)
else:
if alllist:
r = ArrayMath.setSection_List(self.array, ranges, value)
else:
r = ArrayMath.setSection_Mix(self.array, ranges, value)
self.array = r