refactor: normalize dimension-check error construction across ndarray/iter#12985
Closed
Planeshifter wants to merge 6 commits into
Closed
refactor: normalize dimension-check error construction across ndarray/iter#12985Planeshifter wants to merge 6 commits into
ndarray/iter#12985Planeshifter wants to merge 6 commits into
Conversation
…er/columns` Wrap the existing plain-string `TypeError` for the `ndims < 2` check in `format()`, matching the construction style already used by every other throw in `lib/main.js` (including the `format()`-with-no-arguments call for the read-only `Error`). All 14 packages in `@stdlib/ndarray/iter` use `format()` for the bulk of their throws (89% of throws across the namespace); this normalizes the one residual plain-string throw in this package to the canonical convention. The error message text and `TypeError` class are unchanged, so the change is invisible to consumers.
…er/column-entries` Wrap the existing plain-string `TypeError` for the `ndims < 2` check in `format()`, matching the construction style already used by every other throw in `lib/main.js` (including the `format()`-with-no-arguments call for the read-only `Error`). All 14 packages in `@stdlib/ndarray/iter` use `format()` for the bulk of their throws (89% of throws across the namespace); this normalizes the one residual plain-string throw in this package to the canonical convention. The error message text and `TypeError` class are unchanged, so the change is invisible to consumers.
…er/rows` Wrap the existing plain-string `TypeError` for the `ndims < 2` check in `format()`, matching the construction style already used by every other throw in `lib/main.js` (including the `format()`-with-no-arguments call for the read-only `Error`). All 14 packages in `@stdlib/ndarray/iter` use `format()` for the bulk of their throws (89% of throws across the namespace); this normalizes the one residual plain-string throw in this package to the canonical convention. The error message text and `TypeError` class are unchanged, so the change is invisible to consumers.
…er/row-entries` Wrap the existing plain-string `TypeError` for the `ndims < 2` check in `format()`, matching the construction style already used by every other throw in `lib/main.js` (including the `format()`-with-no-arguments call for the read-only `Error`). All 14 packages in `@stdlib/ndarray/iter` use `format()` for the bulk of their throws (89% of throws across the namespace); this normalizes the one residual plain-string throw in this package to the canonical convention. The error message text and `TypeError` class are unchanged, so the change is invisible to consumers.
…er/matrices` Wrap the existing plain-string `TypeError` for the `ndims < 3` check in `format()`, matching the construction style already used by every other throw in `lib/main.js` (including the `format()`-with-no-arguments call for the read-only `Error`). All 14 packages in `@stdlib/ndarray/iter` use `format()` for the bulk of their throws (89% of throws across the namespace); this normalizes the one residual plain-string throw in this package to the canonical convention. The error message text and `TypeError` class are unchanged, so the change is invisible to consumers.
…er/matrix-entries` Wrap the existing plain-string `TypeError` for the `ndims < 3` check in `format()`, matching the construction style already used by every other throw in `lib/main.js` (including the `format()`-with-no-arguments call for the read-only `Error`). All 14 packages in `@stdlib/ndarray/iter` use `format()` for the bulk of their throws (89% of throws across the namespace); this normalizes the one residual plain-string throw in this package to the canonical convention. The error message text and `TypeError` class are unchanged, so the change is invisible to consumers.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
8 tasks
kgryte
requested changes
Jun 20, 2026
kgryte
left a comment
Member
There was a problem hiding this comment.
None of the changes in this PR are necessary, as format is not needed. There are no placeholders in the error messages to interpolate.
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
Six packages in
@stdlib/ndarray/iterhave a single residual plain-stringthrow new TypeError( '...' )at the dimension-count check that was missed during the migration to the canonicalformat()error-construction style. Every other throw in each of these same files — including a no-argumentthrow new Error( format( 'invalid option. Cannot write to read-only array.' ) );for the read-only check — already wraps the message informat(). This pull request wraps the dimension-count throws informat()to match. Error message text andTypeErrorclass are unchanged.Namespace summary
package.jsonshape, README section order, top-levelmanifest.jsonshape,test//benchmark//examples/filenames, JSDoc shape, return kind, validation prologue, error construction, dependency setpackage.jsonkeys,directorieskeys, README section sequence (## Usage→## Notes→## Examples→## See Also), JSDoc@examplepresent,returnKind: iteratorentries,indices,interleave-subarrays,select-dimension,stacks,subarrays,to-array-each,values) useformat()for every throw; the 6 outliers below each have one residual plain-string throw. At the throw-site level, 50 of 56 throws across the namespace (89%) already useformat().@paramcount,@throwscount — each varies with the underlying function (some packages take(x), others(x, dim),(x, dims),(arrays, ndims), etc.), so cross-package vote does not apply.@stdlib/ndarray/iter/columnsThe
ndims < 2check throws a plain-stringTypeError. Every other throw inlib/main.js— including the no-argumentformat()call guarding the read-onlyError— already usesformat(). Wrap the dimension-check message informat()so the file is internally consistent.@stdlib/ndarray/iter/column-entriesSame drift as
columns: a single plain-stringTypeErrorat thendims < 2check, surrounded byformat()-wrapped throws. Wrap the message informat().@stdlib/ndarray/iter/rowsTwin of
columnsand carries the same drift at thendims < 2check. Wrap the message informat().@stdlib/ndarray/iter/row-entriesTwin of
column-entriesand carries the same drift at thendims < 2check. Wrap the message informat().@stdlib/ndarray/iter/matricesSame drift, three-dimension variant: the
ndims < 3check throws a plain-stringTypeErrorwhile every other throw usesformat(). Wrap the message informat().@stdlib/ndarray/iter/matrix-entriesSame drift as
matricesat thendims < 3check. Wrap the message informat().Related Issues
None.
Questions
No.
Other
Validation
package.jsonkeys,scripts/stdlib/directoriesshapes, README heading sequences, andtest//benchmark//examples/filenames compared across all 14 members. No structural drift.lib/main.jsandlib/index.jsand returned a strict-schema JSON bundle covering public signature, return kind, validation prologue, error-construction style, JSDoc shape, and the@stdlib/*dependency set.confirmed-driftfor all 6 outliers. Tests rely on theTypeErrorclass only — no assertions on message text. No@throwsannotation, REPL doc, README example, or TypeScript declaration depends on the construction call.@stdlib/ndarray/itersearched; no collision (PR docs: improve examples ofndarray/iternamespace #1686 touches namespace examples only; PR docs: updatendarray/iterTypeScript declarations #12661 updates TypeScript declarations only; PR docs: propagate recent develop fixes to sibling packages #12642 touchesinterleave-subarrays/docs/repl.txtonly).Deliberately excluded
@throws-count features: vary with the underlying function and have no cross-namespace majority. Per-package corrections to these would require human judgement and are out of scope for an automated drift pass.nditerColumnsS0/nditerRowsS1variable-naming difference: the two functions iterate over the trailing and second-to-last dimensions respectively, so the two-letter suffix encodes a deliberate dimension index — not drift.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code on behalf of @Planeshifter as an automated cross-package API-drift audit of
@stdlib/ndarray/iter. Candidate corrections were located via per-package semantic-feature extraction (one sonnet agent per package), validated by three parallel reviewer agents (opus semantic-review, opus cross-reference, sonnet structural-review), then applied as one mechanical patch per package in the primary worktree. A human will audit and promote the PR out of draft.@stdlib-js/reviewers
Generated by Claude Code