test_util.py 文件源码

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

项目:nn_dataflow 作者: stanford-mast 项目源码 文件源码
def test_perm(self):
        ''' Permutations. '''
        fs_ord = set()
        fs_unord = set()
        for fs in util.factorize(512, 3):
            fs_ord.add(fs)
            fs_unord.add(frozenset(fs))

        cnt = 0
        for fs in fs_unord:
            if len(fs) == 3:
                # Permutations.
                cnt += math.factorial(3)
            elif len(fs) == 2:
                # Permutations of a, a, b.
                cnt += 3
            else:
                # Pattern a, a, a.
                cnt += 1
        self.assertEqual(len(fs_ord), cnt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号