Share

Probability and Stastics for python

Tracker: Bugs

5 Permutation does not iterate over whole set - ID: 1637933
Last Update: Comment added ( timcoote )

I'm not getting complete permutations. if I try to get all of the
permutations of the numbers from 1 to 14, using a simple script, it
terminates early. I've tried this on fc5 native and fc6 as a vmware guest
and get the same result. it appears to stop cleanly, just early.

Have I built the code wrongly or something? I took that standard _0.912
tarball. I cannot even work out how to debug this. The reproduceability on
different platforms makes me think it's an overflow problem, but I don't
see anything obvious in that loop value. I see no symptoms of memory
leakage.

this program:

---cut here---
import probstat

values = [i+1 for i in range (14)]

gen = probstat.Permutation (values)
loop = 1
for i in gen:
if loop %1000000 == 0: print loop
loop += 1

-- cut here --
stops after it has printed 1278000000. loop is 1278945281, i is:
[1, 4, 11, 2, 8, 7, 13, 14, 12, 5, 9, 6, 10, 3]

loop should be around 87 billion, not 1.27 billion


Tim Coote ( timcoote ) - 2007-01-17 18:02

5

Open

None

Nobody/Anonymous

None

None

Public


Comment ( 1 )




Date: 2007-01-24 21:45
Sender: timcoote


diving into gdb, the issue seems to arise between probstat and the
underlying gsl code. The function permute_smart_item (which is in the
version of probstat, but not the current one) returns an index out of range
error (I get a break at line 107 of python/permutation.c), which the python
interface does not seem to propagate through. I don't spk C very well, but
the code looks correct, so I cannot see why it's not propagating. Neither
do I understand why the gsl code runs out of indices. But I thought it
useful to put out what I found.

No doubt I'll find that I'm just doing something really stupid.


Log in to comment.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.