Fix crash on generation when a big mutation draws a size-1 array delta - #62
Open
SAY-5 wants to merge 1 commit into
Open
Fix crash on generation when a big mutation draws a size-1 array delta#62SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #61.
When a big mutation happens in
getMutatedDNA,deltais drawn withnp.random.normal(0.0, 1.0, 1), which returns a length-1 array instead of a scalar. Assigning that back into a single slot withresult[big_mut_loc+i] += deltafails 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 thewhile abs(delta) < 0.5check 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.