November 2018
Intermediate to advanced
360 pages
9h 36m
English
Take a look at the following steps:
from collections import OrderedDictnum_loci = 10pop_size = 100num_gens = 10init_ops = OrderedDict()pre_ops = OrderedDict()post_ops = OrderedDict()
Here, we specify that we want to simulate 10 loci, a population size of 100, and just 10 generations. We then prepare three ordered dictionaries. These will maintain our operators.
Note that we use OrderedDict(). Ordered dictionaries will return keys in the order that they were inserted. This is important because the order of operators is relevant, for example, if we print the result of a statistic—this will be dependent on it having been computed before.