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
04f722ae
Commit
04f722ae
authored
May 22, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ba86a886
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
24 deletions
+51
-24
wcfs/testprog/treedelta-genallstructs.py
wcfs/testprog/treedelta-genallstructs.py
+51
-24
No files found.
wcfs/testprog/treedelta-genallstructs.py
View file @
04f722ae
...
...
@@ -148,7 +148,7 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
zblk
=
ZBlk
()
zblk
.
setblkdata
(
v
)
valdict
[
v
]
=
zblk
commit
(
'treedelta/values %
s'
%
(
list
(
valv
),)
)
commit
(
'treedelta/values %
r'
%
valv
)
# vdecode(vtxt) -> vobj decodes value text into value object, e.g. 'a' -> ZBlk(a)
# vencode(vobj) -> vtxt encodes value object into value text, e.g. ZBlk(a) -> 'a'
...
...
@@ -176,16 +176,16 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
commit
(
'treedelta/tree'
)
for
k
in
sorted
(
kv1
):
ztree
[
k
]
=
kv1
[
k
]
z
txt
=
treetxt
(
ztree
)
commit
(
z
txt
)
t
txt
=
treetxt
(
ztree
)
commit
(
t
txt
)
# XXX print txnδ
t1struct0
=
xbtree
.
StructureOf
(
ztree
)
# emit initial kv2 state prepared as ZODB would natively
patch
(
ztree
,
diff12
,
verify
=
kv2
)
ztxt_prev
=
z
txt
z
txt
=
treetxt
(
ztree
)
commit
(
'%s -> %s'
%
(
ztxt_prev
,
z
txt
))
ttxt_prev
=
t
txt
t
txt
=
treetxt
(
ztree
)
commit
(
'%s -> %s'
%
(
ttxt_prev
,
t
txt
))
# XXX printδ
t2struct0
=
xbtree
.
StructureOf
(
ztree
)
...
...
@@ -194,27 +194,54 @@ def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n):
t2structv
=
[
t2struct0
]
+
random
.
sample
(
t2AllStructs
,
min
(
n
,
len
(
t2AllStructs
)))
# emit tree1->tree2 and tree1<-tree2 transitions for all combinations of tree1 and tree2.
for
i
in
range
(
len
(
t1structv
)):
for
j
in
range
(
len
(
t2structv
)):
tree1
=
t1structv
[
i
]
tree2
=
t2structv
[
j
]
# tree1->tree2
if
not
(
i
==
0
and
j
==
0
):
# tree1₀->tree2₀ was already emitted while initializing.
patch
(
ztree
,
diff12
,
verify
=
kv2
)
xbtree
.
Restructure
(
ztree
,
tree2
)
transaction
.
commit
()
# XXX printδ
# tree1<-tree2
patch
(
ztree
,
diff21
,
verify
=
kv1
)
xbtree
.
Restructure
(
ztree
,
tree1
)
transaction
.
commit
()
# XXX printδ
# tree1₀->tree2₀ was already emitted.
t12travel
=
list
(
bitravel2Way
(
t1structv
,
t2structv
))
assert
t12travel
[
0
]
is
t1struct0
assert
t12travel
[
1
]
is
t2struct0
for
i
,
tstruct
in
enumerate
(
t12travel
[
2
:]):
if
i
%
2
==
0
:
delta
=
diff21
verify
=
kv1
assert
tstruct
in
t1structv
else
:
delta
=
diff12
verify
=
kv2
assert
tstruct
in
t2structv
patch
(
ztree
,
delta
,
verify
)
xbtree
.
Restructure
(
ztree
,
tstruct
)
ttxt_prev
=
ttxt
ttxt
=
xbtree
.
TopoEncode
(
tstruct
)
# XXX with values
commit
(
'%s -> %s'
%
(
ttxt_prev
,
ttxt
))
# XXX printδ
# bitravel2Way generates travel path through all A<->B edges such
# that all edges a->b and a<-b are traveled and exactly once.
#
# The travel starts from A[0].
def
bitravel2Way
(
A
,
B
):
# -> i[] of node
na
=
len
(
A
);
assert
na
>
0
nb
=
len
(
B
);
assert
nb
>
0
yield
A
[
0
]
# A₀
for
j
in
range
(
nb
):
yield
B
[
j
]
# A₀ -> Bj
for
i
in
range
(
1
,
na
):
yield
A
[
i
]
# Ai <- Bj
yield
B
[
j
]
# Ai -> Bj
yield
A
[
0
]
# A₀ <- Bj
def
test_bitravel2Way
():
a
,
b
,
c
=
'a'
,
'b'
,
'c'
A
=
[
a
,
b
,
c
]
B
=
[
1
,
2
]
assert
list
(
bitravel2Way
(
A
,
B
))
==
[
a
,
1
,
b
,
1
,
c
,
1
,
a
,
2
,
b
,
2
,
c
,
2
,
a
,
3
,
b
,
3
,
c
,
3
,
a
]
test_bitravel2Way
()
@
func
def
main
():
if
len
(
sys
.
argv
)
!=
5
:
...
...
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