[Biopython-dev] test_GASelection hangs

Peter biopython at maubp.freeserve.co.uk
Mon Nov 17 23:18:12 UTC 2008


> This needs to be:
> if org_1.fitness > 0 : break

Yeah.  I've checked in a fix based on this approach, could you try
test_GASelection.py revision 1.3 just to make sure I've not done
something silly.

> Also, when looping the test, I occasionally get
> Test not getting an organism already in the new population. ... FAIL
> Test basic selection on a small population. ... ok
>
> ======================================================================
> FAIL: Test not getting an organism already in the new population.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "test_GASelection.py", line 130, in t_no_retrive_organism
>   assert new_org != org, "Got organism already in the new population."
> AssertionError: Got organism already in the new population.

Confirmed - when I was just looking for the hanging sub-test, I didn't
spot this.

>From my reading of the GA code there is no guarantee that
DiversitySelection will return a completely new organism.  If it has
to generate one at random, there is a small chance it will match
something already in the population.  i.e. the test itself is flawed.
We could try this say 10 times, but even then the test could fail.

I've fixed this in test_GASelection.py revision 1.4 by simply
commenting out the assert in
DiversitySelectionTest.t_no_retrive_organism.  However, maybe the
underlying Bio.GA.Selection.Diversity code could be altered instead to
guarantee this possibly desirable behaviour?

Peter



More information about the Biopython-dev mailing list