Skip to content

Commit

Permalink
fixed bug for ordinal parameters (second round)
Browse files Browse the repository at this point in the history
added if clause for more than two given ordinal parameters
  • Loading branch information
JanisHe committed Nov 28, 2024
1 parent 61762f7 commit 73e873d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion propulate/propagators/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def __call__(self, ind: Individual) -> Individual: # type: ignore[override]
for i in to_mutate:
if isinstance(ind[i], int):
# Return randomly selected element from int range(start, stop, step).
ind[i] = self.rng.randint(*self.limits[i])
if len(self.limits[i]) == 2:
ind[i] = self.rng.randint(*self.limits[i])
else:
ind[i] = self.rng.choice(self.limits[i])
elif isinstance(ind[i], float):
# Return random floating point number within limits.
ind[i] = self.rng.uniform(*self.limits[i])
Expand Down

0 comments on commit 73e873d

Please sign in to comment.