Skip to content

Commit

Permalink
Fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedfgad committed Dec 8, 2024
1 parent c6949e1 commit b760c3e
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 @@ -173,14 +173,14 @@ def unique_int_gene_from_range(self,
"""

# The gene_type is of the form [type, precision]
dtype = gene_type[0]
dtype = gene_type

# For non-integer steps, the numpy.arange() function returns zeros if the dtype parameter is set to an integer data type. So, this returns zeros if step is non-integer and dtype is set to an int data type: numpy.arange(min_val, max_val, step, dtype=gene_type[0])
# To solve this issue, the data type casting will not be handled inside numpy.arange(). The range is generated by numpy.arange() and then the data type is converted using the numpy.asarray() function.
all_gene_values = numpy.asarray(numpy.arange(min_val,
max_val,
step),
dtype=dtype)
dtype=dtype[0])

# If mutation is by replacement, do not add the current gene value into the list.
# This is to avoid replacing the value by itself again. We are doing nothing in this case.
Expand All @@ -191,7 +191,7 @@ def unique_int_gene_from_range(self,

# After adding solution[gene_index] to the list, we have to change the data type again.
all_gene_values = numpy.asarray(all_gene_values,
dtype)
dtype[0])

values_to_select_from = list(set(list(all_gene_values)) - set(solution))

Expand Down

0 comments on commit b760c3e

Please sign in to comment.