Skip to content

Commit

Permalink
fixed ruff errors, that were not found in the pre-commit hook for som…
Browse files Browse the repository at this point in the history
…e reason
  • Loading branch information
oskar-taubert committed Aug 4, 2024
1 parent b9056e4 commit 03289f3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions propulate/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def __getitem__(self, key: str) -> Union[float, int, str]:
return self.mapping[key]
else:
# continuous variable
if self.types[key] == float:
if self.types[key] is float:
return float(self.position[self.offsets[key]].item())
elif self.types[key] == int:
elif self.types[key] is int:
return int(np.rint(self.position[self.offsets[key]]).item())
elif self.types[key] == str:
elif self.types[key] is str:
offset = self.offsets[key]
upper = self.offsets[key] + len(self.limits[key])
return str(
Expand All @@ -121,13 +121,13 @@ def __setitem__(self, key: str, newvalue: Union[float, int, str, Any]) -> None:
else:
if key not in self.limits:
raise ValueError("Unknown gene.")
if self.types[key] == float:
if self.types[key] is float:
assert isinstance(newvalue, float)
self.position[self.offsets[key]] = newvalue
elif self.types[key] == int:
elif self.types[key] is int:
assert isinstance(newvalue, int)
self.position[self.offsets[key]] = float(newvalue)
elif self.types[key] == str:
elif self.types[key] is str:
assert newvalue in self.limits[key]
offset = self.offsets[key]
upper = len(self.limits[key])
Expand Down

0 comments on commit 03289f3

Please sign in to comment.