diff --git a/src/p2lab/genetic/operations.py b/src/p2lab/genetic/operations.py index a117fc7..ebf814a 100644 --- a/src/p2lab/genetic/operations.py +++ b/src/p2lab/genetic/operations.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/p2lab/pokemon/pokefactory.py b/src/p2lab/pokemon/pokefactory.py index 9837e49..96406f8 100644 --- a/src/p2lab/pokemon/pokefactory.py +++ b/src/p2lab/pokemon/pokefactory.py @@ -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 = { @@ -68,7 +68,7 @@ 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) @@ -76,16 +76,16 @@ def make_pokemon(self, dexnum=None, generate_moveset=False, **kwargs): 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()) )