From 21a709f5d07311799089b9294441582351efaa85 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Sun, 6 Dec 2020 11:17:15 -0500 Subject: [PATCH] Added chromosome comparison by their genes --- src/structure/chromosome.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/structure/chromosome.py b/src/structure/chromosome.py index fba5a75..f38e0ce 100644 --- a/src/structure/chromosome.py +++ b/src/structure/chromosome.py @@ -100,6 +100,17 @@ class Chromosome: return self.gene_list.index(searched_gene) + def __eq__(self, chromosome): + """ + Allows the user to use + chromosome_1 == chromosome_2 + chromosome_1 != chromosome_2 + to compare two chromosomes based on their genes. + """ + + return all(gene_1 == gene_2 for gene_1, gene_2 in zip(self, chromosome)) + + def __repr__(self): """ Allows the user to use