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)
评论列表
文章目录