[Biopython-dev] test_GASelection hangs

Peter biopython at maubp.freeserve.co.uk
Mon Nov 17 18:50:14 UTC 2008


On Mon, Nov 17, 2008 at 6:35 PM, Bruce Southey <bsouthey at gmail.com> wrote:
> Hi,
> I was just running the test under a very fresh cvs version and under
> Python2.3 the test was hanging with test_GASelection. Of course, there was
> no problem after killing it and rerunning the test. I think this also
> pertains to bug 2651 so I thought I would ask if there was a way to examine
> this further before doing anything else.  I understand that this is problem
> with randomization involved, but it does indicate a more subtle problem is
> present.  I would really like to track down the source of the problem.
>
> Does anyone have any ideas on how I could try to examine this further?

If you have installed CVS (or indeed any recent version of Biopython,
as the GA stuff hasn't changed recently IIRC), then in the Tests
directory you can just run:

$ python test_GASelection.py

You'll find sometimes it gets stuck.  I tried modifying the file so
that the end reads as follows:

if __name__ == "__main__":
    #sys.exit(run_tests(sys.argv))

    ALL_TESTS = [DiversitySelectionTest, TournamentSelectionTest,
                 RouletteWheelSelectionTest]

    runner = unittest.TextTestRunner(sys.stdout, verbosity = 2)
    test_loader = unittest.TestLoader()
    test_loader.testMethodPrefix = 't_'

    test=ALL_TESTS[1] #Edit me: 0, 1 or 2
    cur_suite = test_loader.loadTestsFromTestCase(test)
    count = 0
    while True :
        count += 1
        print "#"*50, count
        runner.run(cur_suite)

On my machine, DiversitySelectionTest and RouletteWheelSelectionTest
seem safe - the tests just run and run until you interrupt them with
ctrl+c.

However, this clearly gets stuck in TournamentSelectionTest - so we've
narrowed this down a bit.  Reading that bit of code, there is an
apparent risk of an infinite loop if by chance org_1 happens to be the
worst organism in the population.  Perhaps adding a simple counter to
break out of the loop if after 1000 tries org_1 is still the worst -
but I'm not sure what to do then.

Peter



More information about the Biopython-dev mailing list