Drop brittle == 7 in Point Mutation test for Julia 1.11+ compat#135
Merged
ChrisRackauckas merged 1 commit intoMay 26, 2026
Merged
Conversation
The test in test/mutations.jl asserts `length(ex) == length(mex) == 7`, but the `== 7` was the tree length on Julia 1.10 only. Julia 1.11 reimplemented `rand(::AbstractRNG, ::Dict/Set/KeySet)` with a more efficient algorithm that consumes the RNG stream differently, so `rand(rng, tr, H)` in src/gp.jl produces a different-length tree on 1.11+ even with StableRNG (StableRNGs stabilizes the raw RNG number stream, not how Base's collection sampling consumes it). The behavioral invariant being tested is that point mutation preserves the node count of the input expression, which `length(ex) == length(mex)` already captures. Drop the hard-coded `== 7`. Verified locally: tests pass on both Julia 1.10.11 and 1.12.6. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Contributor
Author
|
Heads-up on the CI status: this PR's branch is based on master, so it runs the legacy The fix has been verified locally on:
Once #134 lands, I'll rebase this onto the new master and the modern Tests workflow will pick up the fix; alternatively, this can be merged on local-verification trust given the trivial nature of the change. |
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.
Summary
Please ignore this PR until reviewed by @ChrisRackauckas.
Fixes the 10 pre-existing
Point Mutationtest failures on Julia 1.11+ (visible in any recent CI run on master where the matrix includes Julia 1.x — and called out in #133).Root cause
The test in
test/mutations.jlasserts:The
== 7was the tree length produced byrand(rng, tr, 2)on Julia 1.10. Julia 1.11 reimplementedrand(::AbstractRNG, ::Dict/Set/KeySet)with a more efficient algorithm that consumes the RNG stream differently.Evolutionary.rand(rng, ::TreeGP, H)insrc/gp.jlcallsrand(rng, keys(t.terminals))/rand(rng, keys(t.functions))— i.e.randover aKeySet. On Julia 1.11+ that produces a different (length-5) tree even withStableRNG(42), becauseStableRNGsstabilizes the raw RNG number stream, not howBase's collection sampling consumes it.The behavioral invariant being tested is that point mutation preserves the node count of the input expression.
length(ex) == length(mex)already captures that; the== 7was hard-coding an implementation artifact specific to 1.10'sDict-sampling RNG sequence.Change
One-line test change plus a 4-line comment explaining the WHY (so a future reader doesn't re-add the constant):
No source code changes — this is a brittle test, not a bug.
Test plan
Pkg.test()on Julia 1.10.11 (was already passing) — still passes.Pkg.test()on Julia 1.12.6 (was failing with 10 Point Mutation failures) — now passes.Context
Discovered while modernizing CI infrastructure in #134 (which expanded the test matrix to include
pre/1/ltson multiple OSes and surfaced these failures consistently). This fix is split out as its own PR because it's a test correctness change, separate from CI-infra work.🤖 Generated with Claude Code