Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
BTrees
Commits
912b0a2e
Commit
912b0a2e
authored
May 25, 2013
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pure-Python impl. of 'OOBTree.byValue' match semantics of C impl.
Items must be in reversed-sorted order.
parent
2472f6b5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
+19
-6
BTrees/_base.py
BTrees/_base.py
+2
-1
BTrees/tests/test_OOBTree.py
BTrees/tests/test_OOBTree.py
+10
-4
BTrees/tests/test__base.py
BTrees/tests/test__base.py
+1
-1
CHANGES.rst
CHANGES.rst
+6
-0
No files found.
BTrees/_base.py
View file @
912b0a2e
...
...
@@ -1171,7 +1171,8 @@ class Tree(_Tree):
return
iter
(
self
.
items
(
min
,
max
,
excludemin
,
excludemax
))
def
byValue
(
self
,
min
):
return
sorted
((
v
,
k
)
for
(
k
,
v
)
in
self
.
iteritems
()
if
v
>=
min
)
return
reversed
(
sorted
((
v
,
k
)
for
(
k
,
v
)
in
self
.
iteritems
()
if
v
>=
min
))
def
insert
(
self
,
key
,
value
):
return
bool
(
self
.
_set
(
key
,
value
,
True
)[
0
])
...
...
BTrees/tests/test_OOBTree.py
View file @
912b0a2e
...
...
@@ -99,9 +99,15 @@ class OOSetPyTest(ExtendedSetTests, unittest.TestCase):
class
OOBTreeTest
(
BTreeTests
,
unittest
.
TestCase
):
def
_makeOne
(
self
):
def
_makeOne
(
self
,
*
args
):
from
BTrees.OOBTree
import
OOBTree
return
OOBTree
()
return
OOBTree
(
*
args
)
def
test_byValue
(
self
):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
tree
=
self
.
_makeOne
(
ITEMS
)
self
.
assertEqual
(
list
(
tree
.
byValue
(
22
)),
[(
y
,
x
)
for
x
,
y
in
reversed
(
ITEMS
[
22
:])])
def
testRejectDefaultComparison
(
self
):
# Check that passing int keys w default comparison fails.
...
...
@@ -146,9 +152,9 @@ class OOBTreePyTest(OOBTreeTest):
# default 'object' comparison semantics.
#class OOBTreePyTest(BTreeTests, unittest.TestCase):
def
_makeOne
(
self
):
def
_makeOne
(
self
,
*
args
):
from
BTrees.OOBTree
import
OOBTreePy
return
OOBTreePy
()
return
OOBTreePy
(
*
args
)
...
...
BTrees/tests/test__base.py
View file @
912b0a2e
...
...
@@ -2334,7 +2334,7 @@ class TreeTests(unittest.TestCase):
ITEMS
=
[(
y
,
x
)
for
x
,
y
in
enumerate
(
'abcdefghijklmnopqrstuvwxyz'
)]
tree
=
self
.
_makeOne
(
ITEMS
)
self
.
assertEqual
(
list
(
tree
.
byValue
(
min
=
22
)),
[(
y
,
x
)
for
x
,
y
in
ITEMS
[
22
:]
])
[(
y
,
x
)
for
x
,
y
in
reversed
(
ITEMS
[
22
:])
])
def
test_insert_new_key
(
self
):
tree
=
self
.
_makeOne
()
...
...
CHANGES.rst
View file @
912b0a2e
``BTrees`` Changelog
====================
Unreleased
----------
- Ensure that pure-Python implementation of ``OOBTree.byValue`` matches
semantics (reversed-sort) of C implementation.
4.0.7 (2013-05-22)
------------------
...
...
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