Skip to content

Fix crash on generation when a big mutation draws a size-1 array delta - #62

Open
SAY-5 wants to merge 1 commit into
carykh:mainfrom
SAY-5:fix-big-mutation-scalar-delta
Open

Fix crash on generation when a big mutation draws a size-1 array delta#62
SAY-5 wants to merge 1 commit into
carykh:mainfrom
SAY-5:fix-big-mutation-scalar-delta

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 20, 2026

Copy link
Copy Markdown

Fixes #61.

When a big mutation happens in getMutatedDNA, delta is drawn with np.random.normal(0.0, 1.0, 1), which returns a length-1 array instead of a scalar. Assigning that back into a single slot with result[big_mut_loc+i] += delta fails on newer NumPy: it used to be a deprecation warning but is now an error (ValueError "setting an array element with a sequence", or the TypeError from the issue on some versions). That is why "Do Generation" crashes on the first big mutation.

Dropping the size argument makes np.random.normal(0.0, 1.0) return a plain float, so both the while abs(delta) < 0.5 check and the in-place add work again. The draw is unchanged otherwise.

I reproduced the crash on NumPy 2.5.1 by running the inner mutation loop, and confirmed it completes cleanly after the change.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValueError and TypeError on new generation, full crash.

1 participant