Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Aug 14, 2023
1 parent 652c055 commit bb9ce0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/p2lab/genetic/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def locus_swap(
team2: list[str],
num_pokemon: int,
allow_all: bool,
locus: int = None,
locus: int | None = None,
) -> tuple(list[str], list[str]):
"""
A method of performing the crossover. Pick a 'locus' point: this
Expand Down Expand Up @@ -194,7 +194,7 @@ def slot_swap(
team2: list[str],
num_pokemon: int,
allow_all: bool,
k: int = None,
k: int | None = None,
) -> tuple(list[str], list[str]):
"""
A method of performing the crossover. This method randomly
Expand Down Expand Up @@ -294,7 +294,7 @@ def mutate(
mutate_prob: float | np.ndarray,
pokemon_population: list[str],
allow_all: bool,
k: int = None,
k: int | None = None,
):
"""
A mutation operation. At random, k members of a team are swapped with k
Expand Down Expand Up @@ -362,7 +362,7 @@ def fitness_mutate(
fitness: np.array,
pokemon_population: list[str],
allow_all: bool,
k: int = None,
k: int | None = None,
):
"""
A mutation operation. Does the same as regular mutation, except that
Expand Down
12 changes: 6 additions & 6 deletions src/p2lab/pokemon/pokefactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, gen=1, drop_forms=True):
self.dex2mon = {
int(self.dex.pokedex[m]["num"]): m
for m in self.dex.pokedex
if "forme" not in self.dex.pokedex[m].keys()
if "forme" not in self.dex.pokedex[m]
}
else:
self.dex2mon = {
Expand Down Expand Up @@ -68,24 +68,24 @@ def make_pokemon(self, dexnum=None, generate_moveset=False, **kwargs):
raise ValueError(msg)
if dexnum is None:
dexnum = np.random.choice(list(self.dex2mon.keys()))
if generate_moveset or "moves" not in kwargs.keys():
if generate_moveset or "moves" not in kwargs:
poss_moves = self.get_allowed_moves(dexnum)
moves = (
np.random.choice(poss_moves, 4, replace=False)
if len(poss_moves) > 3
else poss_moves
)
kwargs["moves"] = moves
if "ivs" not in kwargs.keys():
if "ivs" not in kwargs:
ivs = [31] * 6
kwargs["ivs"] = ivs
if "evs" not in kwargs.keys():
if "evs" not in kwargs:
# TODO: implement EV generation better
evs = [510 // 6] * 6
kwargs["evs"] = evs
if "level" not in kwargs.keys():
if "level" not in kwargs:
kwargs["level"] = 100
if "ability" not in kwargs.keys():
if "ability" not in kwargs:
kwargs["ability"] = np.random.choice(
list(self.get_allowed_abilities(dexnum).values())
)
Expand Down

0 comments on commit bb9ce0e

Please sign in to comment.