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


Python BlockMatrix.fill方法代码示例

本文整理汇总了Python中hail.linalg.BlockMatrix.fill方法的典型用法代码示例。如果您正苦于以下问题:Python BlockMatrix.fill方法的具体用法?Python BlockMatrix.fill怎么用?Python BlockMatrix.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hail.linalg.BlockMatrix的用法示例。


在下文中一共展示了BlockMatrix.fill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fill

# 需要导入模块: from hail.linalg import BlockMatrix [as 别名]
# 或者: from hail.linalg.BlockMatrix import fill [as 别名]
    def test_fill(self):
        nd = np.ones((3, 5))
        bm = BlockMatrix.fill(3, 5, 1.0)
        bm2 = BlockMatrix.fill(3, 5, 1.0, block_size=2)

        self.assertTrue(bm.block_size == BlockMatrix.default_block_size())
        self.assertTrue(bm2.block_size == 2)
        self._assert_eq(bm, nd)
        self._assert_eq(bm2, nd)
开发者ID:tpoterba,项目名称:hail,代码行数:11,代码来源:test_linalg.py

示例2: test_sum

# 需要导入模块: from hail.linalg import BlockMatrix [as 别名]
# 或者: from hail.linalg.BlockMatrix import fill [as 别名]
    def test_sum(self):
        def sums_agree(bm, nd):
            self.assertAlmostEqual(bm.sum(), np.sum(nd))
            self._assert_close(bm.sum(axis=0), np.sum(nd, axis=0, keepdims=True))
            self._assert_close(bm.sum(axis=1), np.sum(nd, axis=1, keepdims=True))

        nd = np.random.normal(size=(11, 13))
        bm = BlockMatrix.from_numpy(nd, block_size=3)

        nd2 = np.zeros(shape=(5, 7))
        nd2[2, 4] = 1.0
        nd2[2, 5] = 2.0
        nd2[3, 4] = 3.0
        nd2[3, 5] = 4.0
        bm2 = BlockMatrix.from_numpy(nd2, block_size=2).sparsify_rectangles([[2, 4, 4, 6]])

        bm3 = BlockMatrix.from_numpy(nd2, block_size=2).sparsify_rectangles([[2, 4, 4, 6], [0, 5, 0, 1]])

        bm4 = BlockMatrix.from_numpy(nd2, block_size=2).sparsify_rectangles([[2, 4, 4, 6], [0, 1, 0, 7]])

        nd5 = np.zeros(shape=(5, 7))
        bm5 = BlockMatrix.fill(5, 7, value=0.0, block_size=2).sparsify_rectangles([])

        sums_agree(bm, nd)
        sums_agree(bm2, nd2)
        sums_agree(bm3, nd2)
        sums_agree(bm4, nd2)
        sums_agree(bm5, nd5)
开发者ID:bcajes,项目名称:hail,代码行数:30,代码来源:test_linalg.py

示例3: test_sum_with_sparsify

# 需要导入模块: from hail.linalg import BlockMatrix [as 别名]
# 或者: from hail.linalg.BlockMatrix import fill [as 别名]
    def test_sum_with_sparsify(self):
        nd = np.zeros(shape=(5, 7))
        nd[2, 4] = 1.0
        nd[2, 5] = 2.0
        nd[3, 4] = 3.0
        nd[3, 5] = 4.0
        bm = BlockMatrix.from_numpy(nd, block_size=2).sparsify_rectangles([[2, 4, 4, 6]])

        bm2 = BlockMatrix.from_numpy(nd, block_size=2).sparsify_rectangles([[2, 4, 4, 6], [0, 5, 0, 1]])

        bm3 = BlockMatrix.from_numpy(nd, block_size=2).sparsify_rectangles([[2, 4, 4, 6], [0, 1, 0, 7]])

        nd4 = np.zeros(shape=(5, 7))
        bm4 = BlockMatrix.fill(5, 7, value=0.0, block_size=2).sparsify_rectangles([])

        self.assert_sums_agree(bm, nd)
        self.assert_sums_agree(bm2, nd)
        self.assert_sums_agree(bm3, nd)
        self.assert_sums_agree(bm4, nd4)
开发者ID:tpoterba,项目名称:hail,代码行数:21,代码来源:test_linalg.py


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