stdlib-js / stdlib-js/stdlib

[RFC]: add `ndarray/base/scalar-dtype`

Open
#11,002 0 comments 0 reactions 0 assignees View on GitHub
Accepted difficulty: 2 Feature JavaScript RFC
Dominant language
JavaScript
Stars
6k
Forks
1.3k
Avg merge
1d 3h
Merged PRs (30d)
611

Description

### Description

This RFC proposes to add `ndarray/base/scalar-dtype` that encapsulates the logic for resolving a default ndarray data type from a scalar value.

The scalar-to-dtype resolution logic is currently duplicated across multiple packages (e.g., `ndarray/base/atleastnd`, `ndarray/from-scalar`) and should be extracted into a dedicated reusable package.

### Related Issues

- TODO comment in `ndarray/base/atleastnd/lib/main.js`

> ```javascript
> // For scalar values, resolve a corresponding ndarray data type...
> if ( isNumber( v ) ) { // TODO: consider abstracting this logic to an `ndarray/base/scalar-dtype` (???) package, as this logic is found elsewhere (e.g., `ndarray/from-scalar`) and it would be good to avoid duplication, especially as we add support for more ndarray data types
> ```

### Questions

No.

### Other

No.

### Checklist

- [x] I have read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [x] Searched for existing issues and pull requests.
- [x] The issue name begins with `RFC:`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.