diff --git a/geppy/core/entity.py b/geppy/core/entity.py index 0b8b7b4..4e97d2d 100644 --- a/geppy/core/entity.py +++ b/geppy/core/entity.py @@ -454,7 +454,8 @@ def __init__(self, gene_gen, n_genes, linker=None): .. note: If a linker is specified, then it must accept *n_genes* arguments, each produced by one gene. If the *linker* parameter is the default value ``None``, then for a monogenic chromosome, no linking is applied, - while for a multigenic chromosome, the ``tuple`` function is used. + while for a multigenic chromosome, the ``tuple`` function is used, i.e., a tuple of values of all genes + is returned. """ list.__init__(self, (gene_gen() for _ in range(n_genes))) self._linker = linker @@ -522,10 +523,13 @@ def kexpressions(self): @property def linker(self): """ - Get the linking function. + Get the linking function. + + .. note: + If linker is `None`, then the actual linking function during evaluation of an individual + returns the value of the single gene for a single-gene (monogenic) chromosome or a tuple of values of all + genes for a multi-gene chromosome. """ - if self._linker is None and len(self) > 1: - return tuple return self._linker def __repr__(self): diff --git a/geppy/support/visualization.py b/geppy/support/visualization.py index 9319c03..ababee3 100644 --- a/geppy/support/visualization.py +++ b/geppy/support/visualization.py @@ -72,7 +72,8 @@ def graph(genome, label_renaming_map=None): for gene in genome: expr = gene.kexpression sub_roots.append(starting_index) - sub_nodes, sub_edges, sub_labels = _graph_kexpression(expr, starting_index) + sub_nodes, sub_edges, sub_labels = _graph_kexpression( + expr, starting_index) nodes.extend(sub_nodes) edges.extend(sub_edges) labels.update(sub_labels) @@ -114,7 +115,7 @@ def export_expression_tree(genome, label_renaming_map=None, file='tree.png'): import graphviz as gv import os.path - nodes, edges, labels = graph(genome, label_renaming_map) + _, edges, labels = graph(genome, label_renaming_map) file_name, ext = os.path.splitext(file) ext = ext.lstrip('.') g = gv.Graph(format=ext) @@ -125,4 +126,4 @@ def export_expression_tree(genome, label_renaming_map=None, file='tree.png'): g.render(file_name) -__all__ = ['graph', 'export_expression_tree'] \ No newline at end of file +__all__ = ['graph', 'export_expression_tree'] diff --git a/geppy/tools/parser.py b/geppy/tools/parser.py index 7de8ee4..25a33e4 100644 --- a/geppy/tools/parser.py +++ b/geppy/tools/parser.py @@ -42,7 +42,7 @@ def compile_(individual, pset): """ fs = [_compile_gene(gene, pset) for gene in individual] linker = individual.linker - if linker is None: + if linker is None: # return the gene itself for a monogenic one or tuple of all genes if len(fs) == 1: return fs[0] else: @@ -50,4 +50,4 @@ def compile_(individual, pset): return lambda *x: linker(*(f(*x) for f in fs)) -__all__ = ['compile_'] \ No newline at end of file +__all__ = ['compile_']