Skip to content

Commit

Permalink
adds test for lex_size flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lacava committed Aug 2, 2017
1 parent be1b7e9 commit c647f16
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions few/tests/test_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,24 @@ def test_lexicase_survival_shapes():
i.fitness_vec = np.random.rand(10,1)
offspring,locs = few.lexicase(pop.individuals,num_selections=1,survival=True)
assert len(offspring) == 1;

def test_lex_size():
"""test_selection.py: lex_size flag on/off"""

few = FEW(seed_with_ml=False,population_size=257, lex_size=True)

Fitness_mat = np.random.rand(257,10)
size_mat = np.random.rand(257,1)

locs = few.epsilon_lexicase(Fitness_mat,size_mat,num_selections=100,
survival=True)
assert len(locs) == 100

few = FEW(seed_with_ml=False,population_size=257, lex_size=False)

Fitness_mat = np.random.rand(257,10)
size_mat = np.random.rand(257,1)

locs = few.epsilon_lexicase(Fitness_mat,size_mat,num_selections=100,
survival=True)
assert len(locs) == 100

0 comments on commit c647f16

Please sign in to comment.