[RFC]: Improve zero-dimensional ndarray creation in tests and examples
メンテナーはふだん 1 日以内に返信
@Vijay431 がすでに取り組んでいます。
2026年11月16日 から。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 67/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
Study the two example commits linked in the issue, then find one package with examples, benchmarks, or tests using @stdlib/ndarray/from-scalar for zero-dimensional arrays. Inspect that package’s README, examples, tests, and benchmarks individually, and update only that package where a typed constructor improves clarity. Done means the existing behavior is preserved and only zero-dimensional construction is changed.
索引モデルが issue の本文から書いたものです。
説明
Instructions
- Read the issue description below.
- Read the issue comment which follows the description.
- Search the code base for a package having an example, benchmark, and/or test which needs updating according to the description below.
- Follow any additional guidance specified in this issue.
Description
This RFC proposes updating zero-dimensional ndarray construction in package tests, benchmarks, and/or examples. This is best conveyed through an example.
Consider the following snippet:
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var x = scalar2ndarray( 3.0, {
'dtype': 'float64'
});
// <ndarray>[ 3.0 ]
Compare to the example after updating in commit https://github.com/stdlib-js/stdlib/commit/3757981ba9ac1c1debc571b5f0edaea47fb2a367
var Float64Tensor0D = require( '@stdlib/ndarray/tensor0d/float64' );
var x = new Float64Tensor0D( 3.0 );
// <ndarray>[ 3.0 ]
Notice how, in the updated example, we migrate from an imperative expression using scalar2ndarray to a declarative expression with new Float64Tensor0D.
Moving to using the dedicated float64 zero-dimensional ndarray constructor eliminates some of the common { 'dtype': '<dtype>' } boilerplate which is often found in scalar2ndarray usage. This becomes more obvious after considering the following example
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var x = scalar2ndarray( new Complex64( 3.0, 4.0 ), {
'dtype': 'complex64'
});
// <ndarray>[ <Complex64>[ 3.0, 4.0 ] ]
where the { 'dtype': 'complex64' } options object is not strictly necessary; however, we often include it to make explicit the output ndarray data type. Compare then to the example after updating in commit https://github.com/stdlib-js/stdlib/commit/37c95c00da3ceb98668c063fe0e6322a436b056a
var Complex64Tensor0D = require( '@stdlib/ndarray/tensor0d/complex64' );
var x = new Complex64Tensor0D( 3.0, 4.0 );
// <ndarray>[ <Complex64>[ 3.0, 4.0 ] ]
Notice how the options boilerplate is no longer present and that we can directly create a zero-dimensional ndarray from real and imaginary components without needing to create an intermediate Complex64 instance.
Accordingly, this RFC seeks to leverage recent improvements in zero-dimensional ndarray construction in order to more succinctly (and declaratively) create zero-dimensional ndarrays.
Steps
Given the relatively widespread practice of using @stdlib/ndarray/from-scalar to convert a scalar value to a zero-dimensional ndarray, this RFC aims to be an open call for any contributor wanting to contribute to the project to do the following:
-
Study the changes made in commits https://github.com/stdlib-js/stdlib/commit/3757981ba9ac1c1debc571b5f0edaea47fb2a367 and https://github.com/stdlib-js/stdlib/commit/37c95c00da3ceb98668c063fe0e6322a436b056a, as these commits contain the sort of changes that we are looking for.
-
Find a package containing documentation examples, benchmarks, and/or tests which use
@stdlib/ndarray/from-scalarto create zero-dimensional ndarrays. -
Assess whether migrating away from
@stdlib/ndarray/from-scalarwould make a meaningful improvement to tests, benchmarks, and/or examples. -
Update the documentation (and possibly tests and benchmarks) for that package, and only that package, to migrate to using dedicated typed zero-dimensional ndarray constructors. Examples may be found in the following package files (note: not all files may require updating; you should inspect each file individually):
README.mddocs/index.d.tsdocs/test.tsdocs/repl.txtexamples/index.jslib/*JSDoc examplesbenchmark/*benchmarkstest/*unit tests
-
Submit a PR updating the files for that package (and only that package).
-
For the PR title, use the following template
docs: use dedicated zero-dimensional tensor constructor in `<package_name>`where
<package_name>is the name of the package you updated (e.g.,blas/ext/base/ndarray/daxpby).
Please do NOT make extraneous changes to examples, tests, or benchmarks. We are not interested in changing examples, tests, and/or benchmarks wholesale. We are only interested in replacing zero-dimensional ndarray construction logic.
Related Issues
None.
Questions
No.
Other
- If you are interested in working on this RFC, for each pull request, please only update the examples, tests, and/or benchmarks for a single package.
- As mentioned above, please do NOT make extraneous changes to examples, tests, or benchmarks. We are not interested in changing examples, tests, or benchmarks wholesale. Nor are we interested in new "creative" changes. We are only interested in replacing zero-dimensional ndarray creation. Failure to match the behavior of the existing examples, tests, and benchmarks and to respect this guidance will result in your PRs being automatically closed without review.
- As this is a "Good First Issue", you are strongly encouraged to avoid using AI when authoring your contribution. One of the primary intents of Good First Issues is to help introduce you to stdlib, its development environment, and the contribution process, as documented in the contributing guide. Most new contributors are unfamiliar with stdlib and its conventions, and thus fail to appropriately use LLMs and AI when authoring contributions, most often generating AI slop and leading to wasted time. Don't be one of those people. :) Take the time to manually author your first several PRs, and, once you are intimately familiar with project conventions, you can consider leveraging AI to augment your dev tasks.
Checklist
- I have read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
- The issue name begins with
RFC:.
- 主要言語
- JavaScript
- スター
- 6k
- フォーク
- 1.3k
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 224
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stdlib-js/stdlib のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
stdlib-js/stdlib#16655 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Fix JavaScript lint errors対応中かも @protestershankar が 5 日前に担当しました。 オープンGood First Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
stdlib-js/stdlib#16563 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Fix C lint errors対応中かも @raus7n が 14 日前に担当しました。 オープンGood First Issue
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
stdlib-js/stdlib#16454 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Fix JavaScript lint errors対応中かも @Devansh-18155 が 39 日前に担当しました。 オープンGood First Issue
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
stdlib-js/stdlib#15970 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Fix JavaScript lint errors対応中かも @lb1192176991-lab が 44 日前に担当しました。 オープンGood First Issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
stdlib-js/stdlib#15831 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
stdlib-js/stdlib の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信
-
automation chore ci-cd consistency developer-experience difficulty: easy discoverability documentation enhancement github-actions good first issue help wanted hygiene priority: P3 seo shell yaml
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
swc-project/swc-next-issues#394 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
githubnext/gh-aw-workshop#5790 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
adobe/helix-tools-website#480 ·
メンテナーはふだん 1 日以内に返信