From 32dc66f857b1a9aef1ce3869f64c04264bec4cbe Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Thu, 26 Nov 2020 21:31:26 -0500 Subject: [PATCH] Cleaned up spacing and added gene_value_iter --- src/structure/chromosome.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/structure/chromosome.py b/src/structure/chromosome.py index 89b0b22..dcf8dbf 100644 --- a/src/structure/chromosome.py +++ b/src/structure/chromosome.py @@ -28,6 +28,12 @@ class Chromosome: return [gene.value for gene in self] + @property + def gene_value_iter(self): + """Returns an iterable of gene values""" + return (gene.value for gene in self) + + def __iter__(self): """ Allows the user to use @@ -38,6 +44,10 @@ class Chromosome: for gene in chromosome to loop through the chromosome. + + Note: using list(chromosome) creates a copy of + the gene_list. Altering this will not + alter the original gene_list. """ return iter(self.gene_list)