Skip to content

[codex] Respect zero probability mutation#15

Merged
opensource-SantanderAI merged 2 commits into
SantanderAI:mainfrom
alerodriargui:codex/fix-zero-mutation-prob
Jul 16, 2026
Merged

[codex] Respect zero probability mutation#15
opensource-SantanderAI merged 2 commits into
SantanderAI:mainfrom
alerodriargui:codex/fix-zero-mutation-prob

Conversation

@alerodriargui

@alerodriargui alerodriargui commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the probability mutation defaulting logic so mutation_prob=0 is respected instead of being treated as omitted.

Previously, Chromosome.mutate() used a truthiness check, so passing 0 fell back to the default 1 / len(self.data) probability and could still mutate genes. The new check defaults only when mutation_prob is None.

Adds a regression test covering the zero-probability case.

Related issue

Closes #14

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only

Checklist

  • I have signed the CLA (the CLA Assistant bot will prompt external contributors)
  • My commit messages follow Conventional Commits
  • ruff check . and black --check . pass
  • mypy genetic_algorithm passes
  • pytest passes
  • The engine remains dependency-free (standard library only)
  • I have added/updated tests where relevant
  • I have updated documentation where relevant
  • No secrets, API keys, internal URLs, or proprietary content are included

@alerodriargui
alerodriargui requested review from a team as code owners July 3, 2026 15:29
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@opensource-SantanderAI

Copy link
Copy Markdown
Contributor

Hi @alerodriargui — thank you for this contribution!

We reviewed PR #15 ("Respect zero probability mutation"): the is not None fix and the added regression test are spot-on, and all CI checks are green except the CLA.

Signing the Contributor License Agreement is a mandatory step before we can merge any external contribution, and it takes about 30 seconds — no forms. Please post a new comment on this PR with exactly this text:

I have read the CLA Document and I hereby sign the CLA

As soon as the CLA Assistant re-runs and turns green, we'll merge right away. Thanks again!

@alerodriargui

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jul 16, 2026

@opensource-SantanderAI opensource-SantanderAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Correct upstream fix: mutation now uses an explicit is not None check so a configured mutation probability of 0.0 is respected instead of falling back to the default (the previous falsy check treated 0.0 as unset). The added regression test covers the zero-probability case. CLA is now signed and CI is green. Thanks @alerodriargui!

@opensource-SantanderAI
opensource-SantanderAI merged commit 07e7915 into SantanderAI:main Jul 16, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mutation_prob=0 is ignored by probability_mutation

2 participants