diff --git a/README.md b/README.md index d5ba3e93..e0ca851b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://app.travis-ci.com/CodeReclaimers/neat-python.svg?branch=master)](https://app.travis-ci.com/github/CodeReclaimers/neat-python) [![Coverage Status](https://coveralls.io/repos/CodeReclaimers/neat-python/badge.svg?branch=master&service=github)](https://coveralls.io/github/CodeReclaimers/neat-python?branch=master) +[![Downloads](https://static.pepy.tech/personalized-badge/neat-python?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/neat-python) ## About ## @@ -23,9 +24,9 @@ The documentation is available on [Read The Docs](http://neat-python.readthedocs ## Citing ## -Here are APA and Bibtex entries you can use to cite this project in a publication. The listed authors are the -maintainers of all iterations of the project up to this point. If you have contributed and would like your name added -to the citation, please submit an issue or email alan@codereclaimers.com. +Here are APA and Bibtex entries you can use to cite this project in a publication. The listed authors are the originators +and/or maintainers of all iterations of the project up to this point. If you have contributed and would like your name added +to the citation, please submit an issue or email alan@codereclaimers.com. APA ``` diff --git a/neat/attributes.py b/neat/attributes.py index 0853bbb7..5e5eef11 100644 --- a/neat/attributes.py +++ b/neat/attributes.py @@ -78,8 +78,11 @@ def mutate_value(self, value, config): return value - def validate(self, config): - pass + def validate(self, config): + min_value = getattr(config, self.min_value_name) + max_value = getattr(config, self.max_value_name) + if max_value < min_value: + raise RuntimeError("Invalid min/max configuration for {self.name}") class IntegerAttribute(BaseAttribute): @@ -121,7 +124,10 @@ def mutate_value(self, value, config): return value def validate(self, config): - pass + min_value = getattr(config, self.min_value_name) + max_value = getattr(config, self.max_value_name) + if max_value < min_value: + raise RuntimeError("Invalid min/max configuration for {self.name}") class BoolAttribute(BaseAttribute): @@ -163,7 +169,9 @@ def mutate_value(self, value, config): return value def validate(self, config): - pass + default = str(getattr(config, self.default_name)).lower() + if default not in ('1', 'on', 'yes', 'true', '0', 'off', 'no', 'false', 'random', 'none'): + raise RuntimeError("Invalid default value for {self.name}") class StringAttribute(BaseAttribute): @@ -200,6 +208,5 @@ def validate(self, config): if default not in ('none', 'random'): options = getattr(config, self.options_name) if default not in options: - raise RuntimeError(f'Invalid activation function name: {default}') + raise RuntimeError(f'Invalid initial value {default} for {self.name}') assert default in options - diff --git a/neat/nn/feed_forward.py b/neat/nn/feed_forward.py index 6a5485b5..df8fc967 100644 --- a/neat/nn/feed_forward.py +++ b/neat/nn/feed_forward.py @@ -36,13 +36,11 @@ def create(genome, config): for layer in layers: for node in layer: inputs = [] - node_expr = [] # currently unused for conn_key in connections: inode, onode = conn_key if onode == node: cg = genome.connections[conn_key] inputs.append((inode, cg.weight)) - node_expr.append("v[{}] * {:.7e}".format(inode, cg.weight)) ng = genome.nodes[node] aggregation_function = config.genome_config.aggregation_function_defs.get(ng.aggregation) diff --git a/tests/test_simple_run.py b/tests/test_simple_run.py index c59659a6..4a291e46 100644 --- a/tests/test_simple_run.py +++ b/tests/test_simple_run.py @@ -271,22 +271,18 @@ def test_serial_bad_config(): def test_serial_bad_configA(): - """Test if bad_configurationA causes a RuntimeError on trying to create the population.""" - # Load configuration. + """Test if bad_configurationA causes a RuntimeError on loading configuration.""" local_dir = os.path.dirname(__file__) config_path = os.path.join(local_dir, 'bad_configurationA') - config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, - neat.DefaultSpeciesSet, neat.DefaultStagnation, - config_path) try: - # Create the population, which is the top-level object for a NEAT run. - p = neat.Population(config) + config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, + neat.DefaultSpeciesSet, neat.DefaultStagnation, + config_path) except RuntimeError: pass else: - raise Exception( - "Should have had a RuntimeError with bad_configurationA") + raise Exception("Should have had a RuntimeError with bad_configurationA") def test_serial_extinction_exception():