Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
ebf43877
Commit
ebf43877
authored
May 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6b9ed5c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+11
-3
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+16
-2
No files found.
wcfs/internal/xbtree.py
View file @
ebf43877
...
...
@@ -52,7 +52,7 @@ The following example illustrates topology encoding represented by string
|| |7|8|9| B-B7,8,9 represents empty Bucket() and Bucket(7,8,9)
Topology encoding specification
follows
:
Topology encoding specification:
A Tree is encoded by depth-order traversal, delimiting layers with "/".
Inside a layer Tree and Bucket nodes are signalled as
...
...
@@ -71,8 +71,8 @@ represented as
"T-T1,3-B4,5" ; layer with Tree([]), Tree([1,3]) and Bucket([4,5])
XXX layer ->
layer
A layer consists of nodes that are followed by node-node links from upper
layer
in left-to-right order.
"""
from
__future__
import
print_function
,
absolute_import
...
...
@@ -181,6 +181,14 @@ def StructureOf(node):
# See top-level docstring for what topology is.
def
TopoEncode
(
tree
):
assert
isinstance
(
tree
,
Tree
)
topo
=
'zzz'
# XXX
if
1
:
# debug
t2
=
TopoDecode
(
topo
)
if
t2
!=
tree
:
panic
(
"BUG: TopoEncode: D(E(·)) != identity
\
n
· = %s
\
n
D(E(·) = %s"
%
(
tree
,
t2
))
return
topo
# TopoDecode decodes topology-encoded text into Tree structure.
...
...
wcfs/internal/xbtree_test.py
View file @
ebf43877
...
...
@@ -75,9 +75,23 @@ def test_structureOf():
def
test_topoEncoding
():
1
/
0
T
=
xbtree
.
Tree
B
=
xbtree
.
Bucket
def
X
(
tree
):
topo
=
xbtree
.
TopoEncode
(
tree
)
t2
=
xbtree
.
TopoDecode
(
topo
)
assert
t2
==
tree
return
topo
assert
X
(
T
([],
B
()))
==
'T/B'
assert
X
(
T
([],
B
(
1
)))
==
'T/B1'
assert
X
(
T
([],
B
(
1
,
3
)))
==
'T/B1,3'
assert
X
(
T
([],
T
([],
B
())))
==
'T/T/B'
#assert X(T(
def
test_
A
llStructs
():
def
test_
a
llStructs
():
T
=
xbtree
.
Tree
B
=
xbtree
.
Bucket
def
X
(
keys
,
maxdepth
,
maxsplit
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment