test_histogram.py 文件源码

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

项目:Eskapade 作者: KaveIO 项目源码 文件源码
def test_bin_edges(self):

        # constructor
        cnt = Counter()
        for i in range(10):
            cnt[i*2] = i

        vc = ValueCounts(key='x', counts=cnt)
        bin_specs = { 'bin_width': 1, 'bin_offset': 0 }

        h = Histogram(vc, variable='x', bin_specs = bin_specs)

        # uniform
        bin_edges = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
        self.assertListEqual(h.get_uniform_bin_edges(), bin_edges)

        # truncated uniform bin edges
        truncated_bin_edges = [5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0]
        self.assertListEqual(h.truncated_bin_edges([5.5,12.5]), truncated_bin_edges)

        h_bin_edges = h.bin_edges()
        self.assertIsInstance(h_bin_edges, np.ndarray)
        self.assertListEqual(h_bin_edges.tolist(), bin_edges)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号