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
f954213c
Commit
f954213c
authored
May 06, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f6724b5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+9
-5
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+9
-0
No files found.
wcfs/internal/xbtree.py
View file @
f954213c
...
...
@@ -51,12 +51,14 @@ class Tree:
t
.
keyv
=
tuple
(
keyv
)
t
.
children
=
tuple
(
children
)
def
__hash__
(
t
):
return
hash
(
t
.
keyv
)
^
hash
(
t
.
children
)
def
__ne__
(
a
,
b
):
return
not
(
a
==
b
)
def
__eq__
(
a
,
b
):
if
not
isinstance
(
b
,
Tree
):
return
False
return
(
a
.
keyv
==
b
.
keyv
)
and
(
a
.
children
==
b
.
children
)
# XXX don't compare .children here?
def
__hash__
(
t
):
return
hash
(
t
.
keyv
)
^
hash
(
t
.
children
)
# XXX children ^^^
return
(
a
.
keyv
==
b
.
keyv
)
and
(
a
.
children
==
b
.
children
)
def
__str__
(
t
):
s
=
"T(["
+
","
.
join
([
'%s'
%
_
for
_
in
t
.
keyv
])
+
"]"
...
...
@@ -79,12 +81,14 @@ class Bucket:
_assertIncv
(
keyv
)
b
.
keyv
=
tuple
(
keyv
)
def
__hash__
(
b
):
return
hash
(
b
.
keyv
)
def
__ne__
(
a
,
b
):
return
not
(
a
==
b
)
def
__eq__
(
a
,
b
):
if
not
isinstance
(
b
,
Bucket
):
return
False
return
a
.
keyv
==
b
.
keyv
def
__hash__
(
b
):
return
hash
(
b
.
keyv
)
def
__str__
(
b
):
return
"B("
+
','
.
join
([
'%s'
%
_
for
_
in
b
.
keyv
])
+
")"
...
...
wcfs/internal/xbtree_test.py
View file @
f954213c
...
...
@@ -115,6 +115,15 @@ def test_AllStructs():
]
print
(
'
\
n
\
n
AAA
\
n
\
n
'
)
q
=
X
([
1
,
3
],
1
,
1
)
print
()
r
=
q
[
0
]
print
(
r
)
z
=
T
([],
B
(
1
,
3
))
print
(
z
)
print
(
r
==
z
)
print
()
1
/
0
assert
X
([
1
,
3
],
1
,
1
)
==
[
# nsplit=0, depth=0
T
([],
B
(
1
,
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