当前位置: 首页>>代码示例>>Python>>正文


Python MA.reshape方法代码示例

本文整理汇总了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))
开发者ID:usnistgov,项目名称:fipy,代码行数:18,代码来源:uniformGrid2D.py

示例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))
开发者ID:LWhitson2,项目名称:fipy,代码行数:20,代码来源:uniformGrid3D.py

示例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))
开发者ID:usnistgov,项目名称:fipy,代码行数:26,代码来源:uniformGrid3D.py


注:本文中的fipy.tools.numerix.MA.reshape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。