v2.1.4: complete the v2.1.3 hygiene cleanup follow-ups#8
Merged
Conversation
Three items deferred from v2.1.3, all bundled here as a single
follow-up patch release:
1. Examples/ String(format:) cleanup
- MultipleLinearRegressionExample.swift: 22 calls → value.number(N)
- LinearRegressionConvenienceExample.swift: 18 calls → value.number(N)
Both example files now consistent with the rest of the codebase.
2. generateRandomReturns seeded overload
- Add generateRandomReturns(count:mean:stdDev:using:) accepting any
RandomNumberGenerator
- The unseeded original wraps the new overload with a
SystemRandomNumberGenerator, so existing call sites are unchanged
- Fixed an edge case where u1 = 0 would cause log(-inf) in
Box-Muller; guarded with Double.leastNormalMagnitude
3. SeededRNG consolidation
- Add TestSupport.MMIXSeededRNG (struct, value-type) with the MMIX
LCG that 5 test files had inlined as local struct declarations
- Includes nextSigned() for the [-1, 1] mapping that DenseMatrixTests
was doing inline
- Bit-identical sequences preserved — no test assertions needed
re-tuning
- All 5 affected files updated to import TestSupport and use
MMIXSeededRNG; local struct declarations removed
- 2 files needed `import TestSupport` added (Descriptives Tests,
DenseMatrixTests)
All 4817 tests still pass, zero compiler warnings, no regressions.
DocC .md files still contain ~62 String(format:) instances in Swift
code samples — documented as a future v2.1.5 cleanup. Those files
aren't compiled so they don't break anything, but they propagate the
bad pattern to users copying from the docs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
Three follow-up cleanup items deferred from v2.1.3, all bundled here as a single follow-up patch release.
Changes (1 commit)
1.
Examples/String(format:)cleanupMultipleLinearRegressionExample.swift: 22 calls →value.number(N)interpolationLinearRegressionConvenienceExample.swift: 18 calls →value.number(N)interpolationBoth example files now consistent with the rest of the codebase. Examples are not part of the package build target so these violations didn't fail CI before, but they were user-facing reference code that propagated the bad pattern.
2.
generateRandomReturnsseeded overloadgenerateRandomReturns(count:mean:stdDev:using: inout some RandomNumberGenerator)SystemRandomNumberGeneratorand calls the seeded overload — same observable behavior, no breaking change for existing callersDouble.random(in: 0.0...1.0)returning exactly 0 would causelog(0) = -infin the Box-Muller transform (guarded withDouble.leastNormalMagnitude)3. SeededRNG consolidation
5 test files had inlined a local
struct SeededRNGusing the MMIX LCG (6364136223846793005). Consolidated into a single canonical type:TestSupport.MMIXSeededRNG— value type (struct),var state: UInt64,mutating func next() -> Doublereturning[0, 1],mutating func nextSigned() -> Doublereturning[-1, 1](the latter matches whatDenseMatrixTestswas doing inline)TestSupportand useMMIXSeededRNG; local struct declarations removedimport TestSupportadded (Descriptives Tests.swift,DenseMatrixTests.swift)Test plan
String(format:matches in Swift files (Sources/,Tests/,Examples/)struct SeededRNGlocal declarations remain inTests/(only the canonical TestSupport type)[-1, 1]mapping is preserved vianextSigned()Compatibility
generateRandomReturns(count:mean:stdDev:)signature unchangedgenerateRandomReturns(count:mean:stdDev:using:)overload addedTestSupport.MMIXSeededRNGtype addedTestSupport.SeededRNG(Numerical Recipes LCG) untouchedFuture cleanup not in this PR
DocC
.mdfiles inSources/BusinessMath/BusinessMath.docc/still contain ~62String(format:)instances in Swift code samples (12 files). These are documentation, not compiled, but they propagate the bad pattern to users who copy from the docs. Tracked as a future v2.1.5 cleanup.🤖 Generated with Claude Code