Skip to content

Commit 6bd164f

Browse files
authored
PyGAD 2.14.2
Some bug fixes when the gene_type parameter is nested. Thanks to Rainer Engel (https://www.linkedin.com/in/rainer-matthias-engel-5ba47a9) for opening a discussion to report this bug: #43 (reply in thread) Rainer Engel (https://www.linkedin.com/in/rainer-matthias-engel-5ba47a9) helped a lot in suggesting new features and suggesting enhancements in 2.14.0 to 2.14.2 releases.
1 parent 04eaea4 commit 6bd164f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .pygad import * # Relative import.
22

3-
__version__ = "2.14.1"
3+
__version__ = "2.14.2"

pygad.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,9 @@ def initialize_population(self, low, high, allow_duplicate_genes, mutation_by_re
829829
size=1), dtype=self.gene_type[gene_idx])[0]
830830
self.population[sol_idx, gene_idx] = random.choice(self.gene_space[gene_idx])
831831
elif type(self.gene_space[gene_idx]) is dict:
832-
self.population[sol_idx, gene_idx] = numpy.random.uniform(low=self.gene_space[gene_idx]['low'],
833-
high=self.gene_space[gene_idx]['high'],
834-
size=1)
832+
self.population[sol_idx, gene_idx] = numpy.asarray(numpy.random.uniform(low=self.gene_space[gene_idx]['low'],
833+
high=self.gene_space[gene_idx]['high'],
834+
size=1), dtype=self.gene_type[gene_idx])[0]
835835
elif type(self.gene_space[gene_idx]) == type(None):
836836
self.gene_space[gene_idx] = numpy.asarray(numpy.random.uniform(low=low,
837837
high=high,
@@ -853,7 +853,7 @@ def initialize_population(self, low, high, allow_duplicate_genes, mutation_by_re
853853
self.population = numpy.asarray(numpy.random.uniform(low=self.gene_space['low'],
854854
high=self.gene_space['high'],
855855
size=self.pop_size),
856-
dtype=self.gene_type) # A NumPy array holding the initial population.
856+
dtype=self.gene_type) # A NumPy array holding the initial population.
857857
else:
858858
self.population = numpy.asarray(numpy.random.choice(self.gene_space,
859859
size=self.pop_size),

0 commit comments

Comments
 (0)