@classmethod<EOL><INDENT>def create_random(cls, gene_length, n=<NUM_LIT:1>, gene_class=BinaryGene):<DEDENT>
assert issubclass(gene_class, BaseGene)<EOL>chromosomes = []<EOL>if not hasattr(gene_length, '<STR_LIT>'):<EOL><INDENT>gene_length = [gene_length]<EOL><DEDENT>for _ in range(n):<EOL><INDENT>genes = [gene_class.create_random(length) for length in gene_length]<EOL>chromosomes.append(cls(genes))<EOL><DEDENT>if n == <NUM_LIT:1>:<EOL><INDENT>return chromosomes[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return chromosomes<EOL><DEDENT>
Create 1 or more chromosomes with randomly generated DNA.

gene_length:  int (or sequence of ints) describing gene DNA length
n:  number of chromosomes to create (default=1); returns a list if n>1, else a single chromosome
gene_class:  subclass of ``ga.chromosomes.BaseGene`` to use for genes

return:  new chromosome