fix(@stdlib/blas/ext/circshift): validate k broadcast shape - #14747
Closed
Planeshifter wants to merge 1 commit into
Closed
fix(@stdlib/blas/ext/circshift): validate k broadcast shape#14747Planeshifter wants to merge 1 commit into
k broadcast shape#14747Planeshifter wants to merge 1 commit into
Conversation
The job `Node.js v16` on workflow `macos_test` has failed deterministically on develop for weeks, with 6 assertion failures in `circshift`'s own test suite. Root cause: when `k` is provided as an ndarray and no `dims` option is given, `main.js` passed `k` straight through to the base implementation without validating that it is zero-dimensional, so a `k` with shape `[4]`, `[2,2,2]`, or `[0]` was silently accepted instead of raising an error. This commit routes `k` through the already-imported `maybeBroadcastArray` helper (already used for the `dims`-provided branch) so that a non-zero-dimensional `k` throws, matching the function's documented "`k` is assumed to be a zero-dimensional ndarray" semantics. Ref: https://github.com/stdlib-js/stdlib/actions/runs/33173054715
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Member
|
Isn't this a duplicate? |
Member
Author
|
Confirmed — #14228 already covers this exact fix for Generated by Claude Code |
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.
Description
This pull request:
@stdlib/blas/ext/circshiftsilently accepting a non-zero-dimensional ndarraykargument instead of throwing, which has been failing theNode.js v16job on themacos_testworkflow deterministically ondevelopfor weeks.kis provided as an ndarray and nodimsoption is given,main.jspassedkstraight through to the base implementation without validating that it is zero-dimensional, contradicting the package's own documented contract ("an ndarray forkmust be a zero-dimensional ndarray") and its own test suite.kthrough the already-importedmaybeBroadcastArrayhelper (already used for thedims-provided branch) in both previously-unvalidated call paths, so akwith a non-zero-dimensional shape now throws instead of being silently accepted.Related Issues
This pull request has the following related issues: none. Discovered via automated monitoring of scheduled CI failures on
develop, not a filed issue.Questions
No.
Other
Failing run: https://github.com/stdlib-js/stdlib/actions/runs/33173054715 (job
Node.js v16, workflowmacos_test; the same failure reproduces on every scheduled run of this workflow going back weeks — not a flake).Symptom:
circshift's own test suite reports 6 failing assertions:circshift(x, k)andcircshift(x, k, {})do not throw whenkis an ndarray with shape[4],[2,2,2], or[0]against anxof shape[2,2].Root cause: in
lib/main.js, whenkis ndarray-like and nodimsoption is supplied, the function assumed (per an inline comment) thatkwas already zero-dimensional and passed it straight tobase()with no validation — in both the 2-argument call form and the 3-argument form whenoptslacks adimsproperty.Fix: route
kthroughmaybeBroadcastArray( k, [] )in both unvalidated branches — the same helper already used one branch over for thedims-provided case, just against a fixed target shape of[](zero dimensions) instead of the non-core shape. For an already-valid zero-dimensionalk,maybeBroadcastArrayreturns the identical object reference, so the happy path is unchanged; for any higher-rankk, it throws.Validation: local
node_modulesare not installed in this environment, somake test/make lint-pkgcould not be run directly. Three independent adversarial reviews were performed against the diff and the package's own test suite, docs, and TypeScript declarations:maybe-broadcast-arrayandbroadcast-arrayby hand and by direct execution (no test runner available, so the module was exercised directly), confirming all 6 previously-failing assertions now throw and no currently-passing assertion in the package's test suite regresses.kwithoutdims; README anddocs/repl.txtalready document the enforced invariant; no public API change.Reviewer notes: non-blocking — the broadcast helper raises a generic
Errorrather than a more specificTypeError, and the top-of-file JSDoc@throwslist doesn't enumerate the broadcast-incompatibility error (a pre-existing gap on the neighboringdimsbranch, not introduced by this change). Left as-is for consistency with the existingdims-provided branch.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was found, diagnosed, fixed, and validated autonomously by Claude Code as part of a scheduled CI-failure-monitoring routine, including an independent three-reviewer adversarial validation pass. A human should still review before merging.
@stdlib-js/reviewers
Generated by Claude Code