diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-08-02 19:41:54 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-08-02 19:41:54 (GMT) |
commit | d2cf1ab0e27b3d794b28170fe745c84723209b86 (patch) | |
tree | 348ea61c81d7f14eaa86c4d044c76be20a2ff5c4 /Lib/test/test_heapq.py | |
parent | d9ea39db84a78b3b994943bc7490615dfe6b009d (diff) | |
download | cpython-d2cf1ab0e27b3d794b28170fe745c84723209b86.zip cpython-d2cf1ab0e27b3d794b28170fe745c84723209b86.tar.gz cpython-d2cf1ab0e27b3d794b28170fe745c84723209b86.tar.bz2 |
check_invariant(): Use the same child->parent "formula" used by heapq.py.
Diffstat (limited to 'Lib/test/test_heapq.py')
-rw-r--r-- | Lib/test/test_heapq.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py index 016fd3a..879899e 100644 --- a/Lib/test/test_heapq.py +++ b/Lib/test/test_heapq.py @@ -8,8 +8,8 @@ import random def check_invariant(heap): # Check the heap invariant. for pos, item in enumerate(heap): - parentpos = ((pos+1) >> 1) - 1 - if parentpos >= 0: + if pos: # pos 0 has no parent + parentpos = (pos-1) >> 1 verify(heap[parentpos] <= item) def test_main(): |