mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Add more ruff rules (#8767)
* Add more ruff rules * Add more ruff rules * pre-commit: Update ruff v0.0.269 -> v0.0.270 * Apply suggestions from code review * Fix doctest * Fix doctest (ignore whitespace) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -96,13 +96,13 @@ def basic(target: str, genes: list[str], debug: bool = True) -> tuple[int, int,
|
||||
|
||||
# Verify if N_POPULATION is bigger than N_SELECTED
|
||||
if N_POPULATION < N_SELECTED:
|
||||
raise ValueError(f"{N_POPULATION} must be bigger than {N_SELECTED}")
|
||||
msg = f"{N_POPULATION} must be bigger than {N_SELECTED}"
|
||||
raise ValueError(msg)
|
||||
# Verify that the target contains no genes besides the ones inside genes variable.
|
||||
not_in_genes_list = sorted({c for c in target if c not in genes})
|
||||
if not_in_genes_list:
|
||||
raise ValueError(
|
||||
f"{not_in_genes_list} is not in genes list, evolution cannot converge"
|
||||
)
|
||||
msg = f"{not_in_genes_list} is not in genes list, evolution cannot converge"
|
||||
raise ValueError(msg)
|
||||
|
||||
# Generate random starting population.
|
||||
population = []
|
||||
|
Reference in New Issue
Block a user