Skip to content

Commit

Permalink
revert loop in test more understandable formula, aesthetic changes in…
Browse files Browse the repository at this point in the history
… examples
  • Loading branch information
Henrik Mettler committed Jun 30, 2020
1 parent 0d773c4 commit 6cfe9c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/example_differential_evo_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def recording_callback(pop):

history, champion = evolution()

print(f"Final expression {champion.to_sympy()[0]} with fitness {champion.fitness}")
print(f"Final expression {champion.to_sympy()[0]} " f"with fitness {champion.fitness}")

history_fitness = np.array(history["fitness_parents"])
ax_fitness.plot(np.max(history_fitness, axis=1), label="Champion")
Expand Down
3 changes: 2 additions & 1 deletion examples/example_evo_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def recording_callback(pop):

f_graph = champion.to_func()
x_0_range = np.linspace(-5.0, 5.0, 20)
x_1_range = np.ones_like(x_0_range) * 2.0 # fix x_1 such than 1d plot makes sense
x_1_range = np.ones_like(x_0_range) * 2.0
# fix x_1 such than 1d plot makes sense
y = [f_graph([x_0, x_1_range[0]]) for x_0 in x_0_range]
y_target = target_function(np.hstack([x_0_range.reshape(-1, 1), x_1_range.reshape(-1, 1)]))

Expand Down
4 changes: 3 additions & 1 deletion test/test_genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,9 @@ def test_correct_number_of_mutations(mutation_rate, rng_seed):
n_mutations = 0
genome_new = genome.clone()
genome_new.mutate(mutation_rate, rng)
n_mutations = len([1 for gene0, gene1 in zip(genome.dna, genome_new.dna) if gene0 != gene1])
for (gene_0, gene_1) in zip(genome.dna, genome_new.dna):
if gene_0 != gene_1:
n_mutations += 1

n_mutations_expected = int(mutation_rate * len(genome.dna))
assert n_mutations == n_mutations_expected

0 comments on commit 6cfe9c7

Please sign in to comment.