Skip to content

Commit

Permalink
Return first element of numpy.random.choice()
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedfgad committed Dec 9, 2024
1 parent b760c3e commit 01eee85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pygad/helper/unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def unique_genes_by_space(self,
Args:
new_solution (list): A solution containing genes with duplicate values.
gene_type (type): The data type of the gene (e.g., int, float).
gene_type (type): The data type of the all the genes (e.g., int, float).
not_unique_indices (list): The indices of genes with duplicate values.
num_trials (int): The maximum number of attempts to resolve duplicates for each gene. Only works for floating-point numbers.
Expand Down Expand Up @@ -417,7 +417,7 @@ def unique_gene_by_space(self,
value_from_space = numpy.random.choice(numpy.arange(start=curr_gene_space['low'],
stop=curr_gene_space['high'],
step=curr_gene_space['step']),
size=1)
size=1)[0]
else:
value_from_space = numpy.random.uniform(low=curr_gene_space['low'],
high=curr_gene_space['high'],
Expand Down Expand Up @@ -479,7 +479,7 @@ def unique_gene_by_space(self,
value_from_space = numpy.random.choice(numpy.arange(start=self.gene_space['low'],
stop=self.gene_space['high'],
step=self.gene_space['step']),
size=1)
size=1)[0]
else:
value_from_space = numpy.random.uniform(low=self.gene_space['low'],
high=self.gene_space['high'],
Expand Down

0 comments on commit 01eee85

Please sign in to comment.