stdlib
stdlib copied to clipboard
[RFC]: improve type declarations for `@stdlib/ndarray/array`
Description
This RFC proposes improving the TypeScript type declarations for @stdlib/ndarray/array. Currently, type declarations do not account for dtype information.
Ideally, we'd improve declarations such that
- based on a provided
dtypeoption value, we return anndarrayof the corresponding type (e.g., ifdtype = 'float64', then return afloat64ndarray, etc). - when not provided a
dtypeoption value, we use thebufferargument/option to infer a corresponding outputndarraydtype.
Supporting the above is likely to require extensive use of function overloads in a manner to what we've done elsewhere in the project when a dtype can effect output results.
Related Issues
No.
Questions
No.
Other
No.
Checklist
- [X] I have read and understood the Code of Conduct.
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with
RFC:.
@kgryte I would like to work on this issue. Please assign to me.
@kgryte I want to work on this issue please assign this issue to me.
I'd like to pick this up!
Since the dtype (e.g: float64, int32 etc) are subsets of a primitive type number, wouldn't TS coerce these types back to number? Could you kindly give more information about the return type here?
The dtype concerns the dtype of the ndarray. They do not correspond to number primitives.
I suggest consulting the type definitions in @stdlib/types.