masked_subchunk.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:pershing 作者: qmn 项目源码 文件源码
def rot90(self, turns=1):
        """
        Rotates the blocks in the counter-clockwise direction. (As numpy
        does it.)
        """
        # Rotate the individual Y-layer matrices
        new_blocks = np.array([np.rot90(by, turns) for by in self.blocks])
        new_data = np.array([np.rot90(dy, turns) for dy in self.data])
        new_mask = np.array([np.rot90(my, turns) for my in self.mask])

        # Rotate the data (if applicable)
        for y in xrange(new_data.shape[0]):
            for z in xrange(new_data.shape[1]):
                for x in xrange(new_data.shape[2]):
                    b = new_blocks[y, z, x]
                    d = new_data[y, z, x]
                    new_data[y, z, x] = self.data_rot90(b, d, turns)

        return MaskedSubChunk(new_blocks, new_data, new_mask)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号