本文整理汇总了Python中fipy.tools.numerix.MA.reshape方法的典型用法代码示例。如果您正苦于以下问题:Python MA.reshape方法的具体用法?Python MA.reshape怎么用?Python MA.reshape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fipy.tools.numerix.MA
的用法示例。
在下文中一共展示了MA.reshape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cellToCellIDs
# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import reshape [as 别名]
def _cellToCellIDs(self):
ids = MA.zeros((4, self.nx, self.ny), 'l')
indices = numerix.indices((self.nx, self.ny))
ids[0] = indices[0] + (indices[1] - 1) * self.nx
ids[1] = (indices[0] + 1) + indices[1] * self.nx
ids[2] = indices[0] + (indices[1] + 1) * self.nx
ids[3] = (indices[0] - 1) + indices[1] * self.nx
if self.ny > 0:
ids[0, ..., 0] = MA.masked
ids[2, ..., -1] = MA.masked
if self.nx > 0:
ids[1, -1, ...] = MA.masked
ids[3, 0, ...] = MA.masked
return MA.reshape(ids.swapaxes(1, 2), (4, self.numberOfCells))
示例2: _cellToCellIDs
# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import reshape [as 别名]
def _cellToCellIDs(self):
ids = MA.zeros((6, self.nx, self.ny, self.nz), 'l')
indices = numerix.indices((self.nx, self.ny, self.nz))
ids[0] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx - 1
ids[1] = indices[0] + (indices[1] + indices[2] * self.ny) * self.nx + 1
ids[2] = indices[0] + (indices[1] + indices[2] * self.ny - self.nz) * self.nx
ids[3] = indices[0] + (indices[1] + indices[2] * self.ny + self.nz) * self.nx
ids[4] = indices[0] + (indices[1] + (indices[2] - 1) * self.ny) * self.nx
ids[5] = indices[0] + (indices[1] + (indices[2] + 1) * self.ny) * self.nx
ids[0, 0, ...] = MA.masked
ids[1,-1, ...] = MA.masked
ids[2,..., 0,...] = MA.masked
ids[3,...,-1,...] = MA.masked
ids[4,..., 0] = MA.masked
ids[5,..., -1] = MA.masked
return MA.reshape(ids.swapaxes(1,3), (6, self.numberOfCells))
示例3: _cellToCellIDs
# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import reshape [as 别名]
def _cellToCellIDs(self):
ids = MA.zeros((6, self.nx, self.ny, self.nz), 'l')
indices = numerix.indices((self.nx, self.ny, self.nz))
nxy = self.nx * self.ny
same = indices[0] + indices[1] * self.nx + indices[2] * nxy
ids[0] = same - 1
ids[1] = same + 1
ids[2] = same - self.nx
ids[3] = same + self.nx
ids[4] = same - nxy
ids[5] = same + nxy
if self.nx > 0:
ids[0, 0, ...] = MA.masked
ids[1, -1, ...] = MA.masked
if self.ny > 0:
ids[2,:, 0,:] = MA.masked
ids[3,:, -1,:] = MA.masked
if self.nz > 0:
ids[4, ..., 0] = MA.masked
ids[5, ..., -1] = MA.masked
return MA.reshape(ids.swapaxes(1, 3), (6, self.numberOfCells))