Skip to content

fix: skip unimplemented dtypes in from-scalar example#13061

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-random-examples-ndarray-from-scalar-2026-06-22
Draft

fix: skip unimplemented dtypes in from-scalar example#13061
Planeshifter wants to merge 1 commit into
developfrom
philipp/ci-fix-random-examples-ndarray-from-scalar-2026-06-22

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

This pull request:

  • Adds a guard in @stdlib/ndarray/from-scalar example to skip float16 and complex32 dtypes, whose buffer constructors in @stdlib/ndarray/base/buffer-ctors are placeholder notImplemented functions that throw Error: not implemented when invoked as constructors.

The example iterates over all dtypes returned by dtypes() (which includes every registered dtype in dtypes.json). For float16 and complex32, the internal call chain is:

scalar2ndarray(i, { dtype: 'float16' })
  → buffer('float16', 1)
    → bufferCtors('float16')   // returns notImplemented (truthy)
      → new notImplemented(1)  // throws Error: not implemented

The if (buf === null) guard in from-scalar/lib/main.js never fires because the throw happens before buffer() can return. The fix skips these two dtypes in the example until their constructors are implemented (tracked by the FIXME comments in buffer-ctors/lib/ctors.js).

This resolves the random_examples CI job failure seen in workflow run 27923327635.

Related Issues

  • No dedicated issue; failure surfaced via CI job random_examples on develop.

Questions

No.

Other

No.

Checklist

AI Assistance

  • Yes

  • Code generation (e.g., when writing an implementation or fixing a bug)

  • Research and understanding

Disclosure

This PR was written primarily by Claude Code as part of an automated CI failure investigation routine. The root cause was identified by tracing the call chain from the failing example through @stdlib/ndarray/base/buffer and @stdlib/ndarray/base/buffer-ctors. The fix was validated by running the example locally and by three independent automated reviewers (correctness, regression, and style checks).


@stdlib-js/reviewers


Generated by Claude Code

The example iterates over all ndarray dtypes, including `float16` and
`complex32`, whose buffer constructors in `@stdlib/ndarray/base/buffer-ctors`
are placeholder `notImplemented` functions that throw `Error: not implemented`
when invoked. Add a guard to skip these two dtypes until their constructors are
implemented.

Fixes CI job `random_examples` failure.
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
ndarray/from-scalar $\\color{red}230/232$
$\\color{green}+99.14\\%$
$\\color{red}30/31$
$\\color{green}+96.77\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{red}230/232$
$\\color{green}+99.14\\%$

The above coverage report was generated for the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants