本文整理汇总了Python中streamhist.StreamHist.merge方法的典型用法代码示例。如果您正苦于以下问题:Python StreamHist.merge方法的具体用法?Python StreamHist.merge怎么用?Python StreamHist.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类streamhist.StreamHist
的用法示例。
在下文中一共展示了StreamHist.merge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_missing_merge
# 需要导入模块: from streamhist import StreamHist [as 别名]
# 或者: from streamhist.StreamHist import merge [as 别名]
def test_missing_merge():
h1 = StreamHist(maxbins=8).update(None)
h2 = StreamHist(maxbins=8)
assert h1.merge(h2) is not None
h1 = StreamHist().update(None)
h2 = StreamHist().update(None)
merged = StreamHist().merge(h1.merge(h2))
assert merged.missing_count == 2
示例2: test_merge
# 需要导入模块: from streamhist import StreamHist [as 别名]
# 或者: from streamhist.StreamHist import merge [as 别名]
def test_merge():
assert len(StreamHist().merge(StreamHist()).bins) == 0
assert len(StreamHist().merge(StreamHist().update(1)).bins) == 1
assert len(StreamHist().update(1).merge(StreamHist()).bins) == 1
points = 1000
count = 10
hists = []
for c in range(count):
h = StreamHist()
for p in make_normal(points):
h.update(p)
hists.append(h)
merged = reduce(lambda a, b: a.merge(b), hists)
assert about(merged.sum(0), (points*count)/2.0, (points*count)/50.0)
h1 = StreamHist().update(1).update(None)
h2 = StreamHist().update(2).update(None)
merged = h1.merge(h2)
assert merged.total == 2
示例3: test_min_max
# 需要导入模块: from streamhist import StreamHist [as 别名]
# 或者: from streamhist.StreamHist import merge [as 别名]
def test_min_max():
h = StreamHist()
assert h.min() is None
assert h.max() is None
for _ in range(1000):
h.update(rand_int(10))
assert h.min() == 0
assert h.max() == 10
h1 = StreamHist()
h2 = StreamHist()
for p in range(4):
h1.update(p)
h2.update(p+2)
merged = h1.merge(h2)
assert merged.min() == 0
assert merged.max() == 5