get_target_nodes() could be generalised for any target symbol.
At present it is called, for example, during a tree mutation, and passed in the non-terminal symbols from the grammar as the target. From mutation.py...
Of course it could be used differently to search for a specific node (e.g., a specific NT) to mutate by passing in a different target. The current implementation needlessly prevents this however by hard-coding a search for non-terminal symbols in the child nodes...
NT_kids = [kid for kid in self.children if kid.root in
params['BNF_GRAMMAR'].non_terminals]
...instead of simply specifying the input target....
NT_kids = [kid for kid in self.children if kid.root in target]
def get_target_nodes(self, array, target=None)
get_target_nodes() could be generalised for any target symbol.
At present it is called, for example, during a tree mutation, and passed in the non-terminal symbols from the grammar as the target. From mutation.py...
targets = ind_tree.get_target_nodes([], target=params[ 'BNF_GRAMMAR'].non_terminals)
Of course it could be used differently to search for a specific node (e.g., a specific NT) to mutate by passing in a different target. The current implementation needlessly prevents this however by hard-coding a search for non-terminal symbols in the child nodes...
...instead of simply specifying the input target.... NT_kids = [kid for kid in self.children if kid.root in target]