[RFC]: Improve zero-dimensional ndarray creation in tests and examples
Los mantenedores suelen responder en 1 día
@Vijay431 ya está trabajando en esto.
Desde el 16/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 67/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
- Área
- developer-experience
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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:.
- Lenguaje dominante
- JavaScript
- Estrellas
- 6k
- Forks
- 1.3k
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 224
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stdlib-js/stdlib
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
stdlib-js/stdlib#16655 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Fix JavaScript lint errorsPosiblemente ocupada @protestershankar la tomó hace 5 días. AbiertoGood First Issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
stdlib-js/stdlib#16563 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Fix C lint errorsPosiblemente ocupada @raus7n la tomó hace 14 días. AbiertoGood First Issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
stdlib-js/stdlib#16454 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Fix JavaScript lint errorsPosiblemente ocupada @Devansh-18155 la tomó hace 39 días. AbiertoGood First Issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
stdlib-js/stdlib#15970 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Fix JavaScript lint errorsPosiblemente ocupada @lb1192176991-lab la tomó hace 44 días. AbiertoGood First Issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
stdlib-js/stdlib#15831 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de stdlib-js/stdlib
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día
-
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
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
swc-project/swc-next-issues#394 ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
githubnext/gh-aw-workshop#5790 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
adobe/helix-tools-website#480 ·
Los mantenedores suelen responder en 1 día