Commit 17bcbc1a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ca32f0c0
...@@ -45,9 +45,9 @@ class Tree: ...@@ -45,9 +45,9 @@ class Tree:
def __init__(t, keyv, *children): def __init__(t, keyv, *children):
assert len(children) == len(keyv) + 1, (keyv, children) assert len(children) == len(keyv) + 1, (keyv, children)
_assertIncv(keyv) _assertIncv(keyv)
# XXX assert children keys consistent?
# XXX assert all children are of the same type # XXX assert all children are of the same type
# XXX assert type(child) is Tree | Bucket # XXX assert type(child) is Tree | Bucket
# XXX assert children keys consistent
t.keyv = tuple(keyv) t.keyv = tuple(keyv)
t.children = tuple(children) t.children = tuple(children)
...@@ -159,20 +159,19 @@ def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit): ...@@ -159,20 +159,19 @@ def _iterAllStructPermutations(klo, khi, keyv, maxdepth, maxsplit):
assert klo <= khi assert klo <= khi
# XXX assert keyv sorted, in [klo, khi) # XXX assert keyv sorted, in [klo, khi)
for nsplit in range(0, maxsplit): for nsplit in range(0, maxsplit):
for ksplitv in _iterSplitByN(klo, khi, nsplit) for ksplitv in _iterSplitByN(klo, khi, nsplit)
# child_i # child_i
xlo, xhi xlo, xhi
# just Tree + Buckets # emit Tree -> Buckets
children = [] children = []
for xlo, xhi in ...: for xlo, xhi in ...:
children.append(Bucket(*_keyvSliceBy(keyv, xlo, xhi))) children.append(Bucket(*_keyvSliceBy(keyv, xlo, xhi)))
yield Tree(ksplitv, children) # FIXME ksplitv wo klo/khi yield Tree(ksplitv, children) # FIXME ksplitv wo klo/khi
# Tree + ...(Trees) + Buckets # emit Tree -> Trees -> ...
if maxdepth == 0: if maxdepth == 0:
continue continue
ichildren = [] # of _iterAllStructPermutations for each child link ichildren = [] # of _iterAllStructPermutations for each child link
......
...@@ -50,12 +50,14 @@ def test_topologyOf(): ...@@ -50,12 +50,14 @@ def test_topologyOf():
T([], B(7)), T([], B(7)),
T([], B(11))) )) T([], B(11))) ))
"""
#assert btree.TopoEncodingOf(t) == ((4,), (2,), ø(4), (6,10), ø(5?), ø(7), ø(11), x(5?)) #assert btree.TopoEncodingOf(t) == ((4,), (2,), ø(4), (6,10), ø(5?), ø(7), ø(11), x(5?))
assert btree.TopoEncodingOf(t) == \ assert btree.TopoEncodingOf(t) == \
(4,), (2,),(), (),(),(6,10), B(1),B(3),(),(),(), (),B(7),B(11), B(5) (4,), (2,),(), (),(),(6,10), B(1),B(3),(),(),(), (),B(7),B(11), B(5)
# T4 T2-T T-T-T6,10 B1-B3-T-T-T T-B7-B11 B5 # T4 T2-T T-T-T6,10 B1-B3-T-T-T T-B7-B11 B5 <-- good
"""
""" """
assert xbtree.TopologyOf(t) == ( (4,), assert xbtree.TopologyOf(t) == ( (4,),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment