Repository navigation
NumPy parity: Sum/Prod over an empty axis, Slice with fewer indices; differential fuzzer - #25
Merged
Merged
Conversation
…nindexed axes whole; differential fuzzer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
Parity fixes (each checked against NumPy 2.5.3 on cfarm421)
SumAxis/ProdAxisalong a zero-length axis now return the identity:np.zeros((3,0)).sum(axis=1)is[0,0,0]and.prod(axis=1)is[1,1,1]. Before, both returned an error, which was inconsistent withSum()/Prod()of an empty array (0 and 1).Max/Min/ArgMax/ArgMinstill error, matching NumPy'sValueError.MeanAxisstill errors, matchingMean(): NumPy returns NaN with a RuntimeWarning, and Go has no warnings. The old docstring said the whole-array reductions "error on empty input", which was false for Sum/Prod; it is corrected. AMeanAxiserror branch that can no longer be reached was removed, since the coverage gate flagged it.Slicewith fewer indices than axes takes the remaining axes whole, asm[1]does in NumPy. This used to be an error. The padding never writes into the caller's index slice; a test covers this and fails when the guard is removed.MaskSelect: NumPy rejects a mask that only broadcasts to the array (verified). Here that is kept as a documented extension, and the docstring now states exactly where the two differ (leading-axes masks, 0-d masks).Differential fuzzer (
FuzzOps)Arbitrary bytes drive slices, reshapes, transposes, squeezes, broadcasting arithmetic, axis reductions,
Take,MaskSelect,Concatenate,MatMulandCumSum. Each result is compared element by element with an oracle written from NumPy's definitions (Python'sslice.indices, the broadcasting rule, and so on). The library must reject exactly the calls the oracle rejects.Copy, and it missed a deliberateSqueezestride bug in 31M executions. The oracle version catches it in 11 seconds (At = Copy = -3, oracle3). That input is kept as a seed.Docs
Outer,MatMuland summing the empty axis of(0, n)produce more than their operands hold.Version: v0.4.0. Calls that used to error now return results.
🤖 Generated with Claude Code