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
46509a57
Commit
46509a57
authored
May 26, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d2172906
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+6
-4
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+14
-1
No files found.
wcfs/internal/xbtree.py
View file @
46509a57
...
...
@@ -259,8 +259,10 @@ def Restructure(ztree, newStructure):
assert
_
.
is_ztree
assert
isinstance
(
newStructure
,
Tree
)
newStructOnlyKeys
=
newStructure
.
copy
(
onlyKeys
=
True
)
from_
=
TopoEncode
(
StructureOf
(
ztree
,
onlyKeys
=
True
))
to_
=
TopoEncode
(
newStruct
ure
)
to_
=
TopoEncode
(
newStruct
OnlyKeys
)
"""
def _():
exc = recover() # FIXME for panic - returns unwrapped arg, not PanicError
...
...
@@ -304,7 +306,7 @@ def Restructure(ztree, newStructure):
# we will modify nodes from new set:
# - node.Z will point to associated znode
# - bucket.next_bucket will point to bucket that is coming with next keys in the tree
tnew
=
newStructure
.
copy
()
tnew
=
newStructure
.
copy
()
# NOTE _with_ values
# assign assigns tree nodes from RNv to ztree nodes from RZv in optimal way.
# Bj ∈ RNv is mapped into Ai ∈ RZv such that that sum_j D(A_i, Bj) is minimal.
...
...
@@ -520,9 +522,9 @@ def Restructure(ztree, newStructure):
_zbcheck
(
ztree
)
# verify ztree after our tweaks
tstruct
=
StructureOf
(
ztree
,
onlyKeys
=
True
)
if
tstruct
!=
newStruct
ure
:
if
tstruct
!=
newStruct
OnlyKeys
:
panic
(
"BUG: result structure is not what was"
" requested:
\
n
%s
\
n
\
n
want:
\
n
%s"
%
(
tstruct
,
newStruct
ure
))
" requested:
\
n
%s
\
n
\
n
want:
\
n
%s"
%
(
tstruct
,
newStruct
OnlyKeys
))
# AllStructs generates subset of all possible BTree structures for BTrees with
...
...
wcfs/internal/xbtree_test.py
View file @
46509a57
...
...
@@ -482,7 +482,8 @@ def test_restructure():
newStructure
=
newtopo
xbtree
.
Restructure
(
ztree
,
newStructure
)
assert
xbtree
.
StructureOf
(
ztree
,
onlyKeys
=
True
)
==
newStructure
assert
xbtree
.
StructureOf
(
ztree
,
onlyKeys
=
True
)
==
\
newStructure
.
copy
(
onlyKeys
=
True
)
# verify iteration producess the same [] of (key, v)
assert
list
(
ztree
.
items
())
==
items
...
...
@@ -677,6 +678,18 @@ def test_restructure():
assertB
(
b8
,
8
)
# ---- new strucure given with values ----
z
=
Z
(
0
,
2
)
R
(
z
,
T
([
1
],
Bv
([
0
],
X
[
0
]),
Bv
([
2
],
X
[
2
])))
b0
,
b2
=
assertT
(
z
,
[
1
],
'B'
,
'B'
)
assertB
(
b0
,
0
)
assertB
(
b2
,
2
)
assert
b0
[
0
]
is
X
[
0
]
assert
b2
[
2
]
is
X
[
2
]
# XXX raises if k->v different
# ---- tricky cases
z
=
Z
(
0
,
1
,
2
,
3
)
...
...
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