[Python-bugs-list] [ python-Bugs-457399 ] bisect module broken in 2.1.1 ?

noreply@sourceforge.net noreply@sourceforge.net
Fri, 31 Aug 2001 13:40:33 -0700


Bugs item #457399, was opened at 2001-08-31 13:40
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=457399&group_id=5470

Category: Python Library
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Daniel Mahler (dmahler)
Assigned to: Nobody/Anonymous (nobody)
Summary: bisect module broken in 2.1.1 ?

Initial Comment:
given the function:

def findClause(C, SS):
    for j in range(1,len(SS)):
        assert SS[j-1] <= SS[j], (j, SS[j-1], SS[j])
    C2 = map(abs, C)
    i = bisect.bisect_left(C2, SS)
    assert C2 >= SS[i], (i, C, C2, [C3 for C3 in SS if
C3 <= C2], SS[0:4])
    return i

I get:

    i = findClause(C, SS)
  File "/home/mahler/code/scripts/oshl.py", line 248,
in findClause
    assert C2 >= SS[i], (i, C, C2, [C3 for C3 in SS if
C3 <= C2], SS[0:4])
AssertionError: (3, [5, -2, 1], [5, 2, 1], [], [[5, 3,
1], [5, 3, 2], [6, 4, 2], [7, 3, 2]])

As far as I can tell this must be a bug:
the first loop ensures that the list is sorted.
It is the bottom asertion that is throwing the
exception
The values returned with the exception show that we
were
looking for an element smaller than any in the list.
I would therefore expect 0 to be returned,
but I get 3.

Daniel Mahler
mahler@cyc.com

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=457399&group_id=5470