test_block.py 文件源码

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

项目:bifrost 作者: ledatelescope 项目源码 文件源码
def test_header_output(self):
        """Output a header for a ring explicitly"""
        def generate_array_and_header():
            """Output the desired header of an array"""
            header = {'dtype': 'complex128', 'nbit': 128}
            yield np.array([1, 2, 3, 4]), header
        def assert_expectation(array):
            "Assert that the array has a complex datatype"
            np.testing.assert_almost_equal(array, [1, 2, 3, 4])
            self.assertEqual(array.dtype, np.dtype('complex128'))
            self.occurences += 1
        blocks = []
        blocks.append((
            NumpySourceBlock(generate_array_and_header, grab_headers=True),
            {'out_1': 0}))
        blocks.append((NumpyBlock(assert_expectation, outputs=0), {'in_1': 0}))
        Pipeline(blocks).main()
        self.assertEqual(self.occurences, 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号