From d26dfdc977e48e188ff1e7ece065df2e56a23235 Mon Sep 17 00:00:00 2001 From: Rogier van der Geer Date: Fri, 13 Dec 2019 15:54:48 +0100 Subject: [PATCH 1/4] Fix the code in the example in the README and add a test to verify this --- README.md | 4 ++-- tests/test_readme.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/test_readme.py diff --git a/README.md b/README.md index ad7f495..69b5824 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tests/test_readme.py b/tests/test_readme.py new file mode 100644 index 0000000..159a920 --- /dev/null +++ b/tests/test_readme.py @@ -0,0 +1,21 @@ +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': + in_code_block = False + return ''.join(content) + else: + content.append(line) + elif line == '```python\n': + in_code_block = True + + +def test_readme(readme_code): + exec(readme_code, globals()) From 112ca6a9aad330e7a2ce8030ffa8e6dc8bb27af3 Mon Sep 17 00:00:00 2001 From: Rogier van der Geer Date: Fri, 13 Dec 2019 15:56:17 +0100 Subject: [PATCH 2/4] Fix the code in the example in the README and add a test to verify this --- tests/test_readme.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_readme.py b/tests/test_readme.py index 159a920..8ff82d6 100644 --- a/tests/test_readme.py +++ b/tests/test_readme.py @@ -9,7 +9,6 @@ def readme_code() -> str: for line in readme_file.readlines(): if in_code_block: if line == '```\n': - in_code_block = False return ''.join(content) else: content.append(line) From e21d352de7a1cce92ed6e4e1aed8daf79cd0ff10 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 14 Dec 2019 14:07:52 +0100 Subject: [PATCH 3/4] added moar flake --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5bab9a3..244eb28 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ flake: flake8 evol flake8 tests flake8 setup.py + flake8 examples/*.py install: pip install -e . From ee9e32164c9bb110d0cceef433770bf2d994e73c Mon Sep 17 00:00:00 2001 From: user Date: Sat, 14 Dec 2019 17:02:40 +0100 Subject: [PATCH 4/4] change to setup.py --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 244eb28..712150e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,7 @@ .PHONY: docs flake: - flake8 evol - flake8 tests - flake8 setup.py - flake8 examples/*.py + python setup.py flake8 install: pip install -e .