stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

[RFC]: improve type declarations for `@stdlib/ndarray/array`

Open kgryte opened this issue 2 years ago • 6 comments

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 dtype option value, we return an ndarray of the corresponding type (e.g., if dtype = 'float64', then return a float64ndarray, etc).
  • when not provided a dtype option value, we use the buffer argument/option to infer a corresponding output ndarray dtype.

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 avatar Aug 22 '23 21:08 kgryte

@kgryte I would like to work on this issue. Please assign to me.

itsspriyansh avatar Feb 22 '24 20:02 itsspriyansh

@kgryte I want to work on this issue please assign this issue to me.

iItachiUchiha avatar Feb 22 '24 20:02 iItachiUchiha

I'd like to pick this up!

prajwalkulkarni avatar Feb 26 '24 18:02 prajwalkulkarni

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?

prajwalkulkarni avatar Mar 25 '24 18:03 prajwalkulkarni

The dtype concerns the dtype of the ndarray. They do not correspond to number primitives.

kgryte avatar Mar 25 '24 19:03 kgryte

I suggest consulting the type definitions in @stdlib/types.

kgryte avatar Mar 25 '24 19:03 kgryte