Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.PHONY: docs

flake:
flake8 evol
flake8 tests
flake8 setup.py
python setup.py flake8

install:
pip install -e .
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ pop = Population(chromosomes=[random_start() for _ in range(200)],
evo1 = (Evolution()
.survive(fraction=0.5)
.breed(parent_picker=pick_random_parents, combiner=make_child)
.mutate(func=add_noise, sigma=1))
.mutate(mutate_function=add_noise, sigma=1))

# We define another sequence of steps to change these candidates
evo2 = (Evolution()
.survive(n=1)
.breed(parent_picker=pick_random_parents, combiner=make_child)
.mutate(func=add_noise, sigma=0.2))
.mutate(mutate_function=add_noise, sigma=0.2))

# We are combining two evolutions into a third one. You don't have to
# but this approach demonstrates the flexibility of the library.
Expand Down
20 changes: 20 additions & 0 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from pytest import fixture


@fixture(scope='function')
def readme_code() -> str:
content = []
in_code_block = False
with open('../README.md') as readme_file:
for line in readme_file.readlines():
if in_code_block:
if line == '```\n':
return ''.join(content)
else:
content.append(line)
elif line == '```python\n':
in_code_block = True


def test_readme(readme_code):
exec(readme_code, globals())