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
1cbf4b33
Commit
1cbf4b33
authored
4 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
54b635dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+21
-1
No files found.
wcfs/internal/xbtree.py
View file @
1cbf4b33
...
...
@@ -241,7 +241,11 @@ def Restructure(ztree, newStructure):
assert
isinstance
(
rzn
.
node
,
(
ztreeType
,
zbucketType
))
for
rn
in
RNv
:
assert
isinstance
(
rn
,
_NodeInRange
)
assert
isinstance
(
rn
.
node
,
(
Tree
|
Bucket
)
assert
isinstance
(
rn
.
node
,
(
Tree
|
Bucket
))
assert
not
hasattr
(
rn
.
node
,
'Z'
)
rn
.
node
.
Z
=
None
# prepare cost matrix
C
=
np
.
zeros
((
len
(
RNv
),
len
(
RZv
)))
...
...
@@ -254,6 +258,22 @@ def Restructure(ztree, newStructure):
# property of D function so that if B2 > B1 (all keys in B2 > all keys
# in B1) and A < B1.hi, then D(B2, A) > D(B1, A).
jv
,
iv
=
scipy
.
optimize
.
linear_sum_assignment
(
C
)
for
(
j
,
i
)
in
zip
(
jv
,
iv
):
RNv
[
j
].
node
.
Z
=
RZv
.
node
# if N(old) > N(new) - some old nodes won't be linked to (it is ok)
# if N(old) < N(new) - some new nodes won't be linked from - link them
# to newly created Z nodes.
for
j2
in
range
(
len
(
RNv
)):
if
j2
not
in
jv
:
n
=
RNv
[
j2
].
node
assert
n
.
Z
is
None
assert
isinstance
(
n
,
(
Tree
,
Bucket
))
if
isinstance
(
n
,
Tree
):
zn
=
ztreeType
()
else
:
zn
=
zbucketType
()
n
.
Z
=
zn
if
len
(
Av
)
==
len
(
Bv
):
# XXX assert the result is 1-1 mapping
...
...
This diff is collapsed.
Click to expand it.
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