Skip to content

Commit bb9ce0e

Browse files
style: pre-commit fixes
1 parent 652c055 commit bb9ce0e

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/p2lab/genetic/operations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def locus_swap(
146146
team2: list[str],
147147
num_pokemon: int,
148148
allow_all: bool,
149-
locus: int = None,
149+
locus: int | None = None,
150150
) -> tuple(list[str], list[str]):
151151
"""
152152
A method of performing the crossover. Pick a 'locus' point: this
@@ -194,7 +194,7 @@ def slot_swap(
194194
team2: list[str],
195195
num_pokemon: int,
196196
allow_all: bool,
197-
k: int = None,
197+
k: int | None = None,
198198
) -> tuple(list[str], list[str]):
199199
"""
200200
A method of performing the crossover. This method randomly
@@ -294,7 +294,7 @@ def mutate(
294294
mutate_prob: float | np.ndarray,
295295
pokemon_population: list[str],
296296
allow_all: bool,
297-
k: int = None,
297+
k: int | None = None,
298298
):
299299
"""
300300
A mutation operation. At random, k members of a team are swapped with k
@@ -362,7 +362,7 @@ def fitness_mutate(
362362
fitness: np.array,
363363
pokemon_population: list[str],
364364
allow_all: bool,
365-
k: int = None,
365+
k: int | None = None,
366366
):
367367
"""
368368
A mutation operation. Does the same as regular mutation, except that

src/p2lab/pokemon/pokefactory.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, gen=1, drop_forms=True):
2121
self.dex2mon = {
2222
int(self.dex.pokedex[m]["num"]): m
2323
for m in self.dex.pokedex
24-
if "forme" not in self.dex.pokedex[m].keys()
24+
if "forme" not in self.dex.pokedex[m]
2525
}
2626
else:
2727
self.dex2mon = {
@@ -68,24 +68,24 @@ def make_pokemon(self, dexnum=None, generate_moveset=False, **kwargs):
6868
raise ValueError(msg)
6969
if dexnum is None:
7070
dexnum = np.random.choice(list(self.dex2mon.keys()))
71-
if generate_moveset or "moves" not in kwargs.keys():
71+
if generate_moveset or "moves" not in kwargs:
7272
poss_moves = self.get_allowed_moves(dexnum)
7373
moves = (
7474
np.random.choice(poss_moves, 4, replace=False)
7575
if len(poss_moves) > 3
7676
else poss_moves
7777
)
7878
kwargs["moves"] = moves
79-
if "ivs" not in kwargs.keys():
79+
if "ivs" not in kwargs:
8080
ivs = [31] * 6
8181
kwargs["ivs"] = ivs
82-
if "evs" not in kwargs.keys():
82+
if "evs" not in kwargs:
8383
# TODO: implement EV generation better
8484
evs = [510 // 6] * 6
8585
kwargs["evs"] = evs
86-
if "level" not in kwargs.keys():
86+
if "level" not in kwargs:
8787
kwargs["level"] = 100
88-
if "ability" not in kwargs.keys():
88+
if "ability" not in kwargs:
8989
kwargs["ability"] = np.random.choice(
9090
list(self.get_allowed_abilities(dexnum).values())
9191
)

0 commit comments

Comments
 (0)