Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_GAMutation.SafeFitnessTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_keep_higher
def test_keep_new

Public Attributes

 alphabet
 org
 test_mutator

Detailed Description

Test mutation which does not allow decreases in fitness.

Definition at line 142 of file test_GAMutation.py.


Member Function Documentation

Definition at line 145 of file test_GAMutation.py.

00145 
00146     def setUp(self):
00147         self.alphabet = TestAlphabet()
00148         genome = MutableSeq("2", self.alphabet)
00149         self.org = Organism(genome, test_fitness)
00150 
00151         self.test_mutator = TestMutator()

Make sure we always keep the higher fitness.

Definition at line 152 of file test_GAMutation.py.

00152 
00153     def test_keep_higher(self): 
00154         """Make sure we always keep the higher fitness.
00155         """
00156         mutator = SafeFitnessMutation(self.test_mutator)
00157 
00158         self.test_mutator.type = "same"
00159         new_org = mutator.mutate(self.org)
00160         assert (new_org == self.org), \
00161                "Did not retain organism for same fitness."
00162 
00163         self.test_mutator.type = "lower"
00164         new_org = mutator.mutate(self.org)
00165         assert (new_org == self.org), \
00166                "Did not retain organism when crossover had lower fitness."
00167 
00168         self.test_mutator.type = "higher"
00169         new_org = mutator.mutate(self.org)
00170         assert (new_org.fitness > self.org.fitness), \
00171                 "Did not get new organism when it had higher fitness."

Make sure we always keep the new organism when specified.

Definition at line 172 of file test_GAMutation.py.

00172 
00173     def test_keep_new(self):
00174         """Make sure we always keep the new organism when specified.
00175         """
00176         mutator = SafeFitnessMutation(self.test_mutator, 1.0)
00177 
00178         self.test_mutator.type = "same"
00179         new_org = mutator.mutate(self.org)
00180         assert (new_org == self.org), \
00181                "Did not retain organism for same fitness."
00182 
00183         self.test_mutator.type = "lower"
00184         new_org = mutator.mutate(self.org)
00185         assert (new_org.fitness < self.org.fitness), \
00186                "Did not get new organism when it had lower fitness."
00187 
00188         self.test_mutator.type = "higher"
00189         new_org = mutator.mutate(self.org)
00190         assert (new_org.fitness > self.org.fitness), \
00191                 "Did not get new organism under higher fitness conditions."


Member Data Documentation

Definition at line 146 of file test_GAMutation.py.

Definition at line 148 of file test_GAMutation.py.

Definition at line 150 of file test_GAMutation.py.


The documentation for this class was generated from the following file: