-
-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC]: achieve ndarray API parity with built-in JavaScript arrays #2656
Comments
I want to work on this issue @kgryte and could you elaborate on the specific goals of aligning ndarray APIs with JavaScript arrays? How will this benefit users and developers? |
This is already addressed in the OP. Second paragraph. |
Yup! Starting work on this! |
@SarthakPaandey Before you begin, it would be best to communicate what you're planning to work on. Some of the above routines are easier than others and should be addressed first. Reductions require R&D and should only be worked on once we've determined the best approach. |
"Understood, @kgryte. I'll prioritize the routines that are comparatively easier and communicate my plan before starting. I'll defer work on reductions until we've established the best approach. Thanks for the guidance! |
@kgryte I have started to work on the |
@headlessNode That makes sense. I am currently working on |
@headlessNode I suggest working a "base" implementation of |
@kgryte The
|
@headlessNode Pushed up a POC implementation of |
Thanks! |
PR-URL: #2715 Ref: #2656 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
Heads up. I have started to work on |
Sounds good, @headlessNode! Thanks for the heads up! |
PR-URL: stdlib-js#2715 Ref: stdlib-js#2656 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
PR-URL: #2861 Ref: #2656 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
PR-URL: #2817 Ref: #2656 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Muhammad Haris <[email protected]>
Description
This RFC proposes achieving ndarray API parity with built-in JavaScript arrays. Built-in JavaScript
Array
andTypedArray
objects have a number of methods for searching, manipulating, sorting, and transforming array data.The goal of this RFC is to add functional APIs providing equivalent functionality for ndarrays. By providing these APIs, stdlib can offer a powerful toolset using a similar vocabulary and interface design as existing art for working with ndarrays. This should help reduce the barrier to ndarray adoption and encourage their more widespread use.
Note, however, that ndarrays have considerable additional complexity due to their multi-dimensional nature, and, in particular, element-wise iteration requires specialized kernels for handling non-contiguous underlying data.
There does exist precedent in stdlib for such kernels (e.g.,
ndarray/base/assign
,ndarray/base/nullary
, andndarray/base/unary
). Those packages also provide C APIs which may or may not be relevant to the functional APIs proposed in this RFC.What follows is an initial list of
Array.prototype.*
methods and notes regarding whether an equivalent already exists or what constraints we need to consider when designing ndarray equivalent packages.Top-level:
ndarray/*
Array.prototype.at
ndarray/at
Array.prototype.concat
Array.prototype.copyWithin
Array.prototype.entries
ndarray/iter/entries
Array.prototype.every
Array.prototype.fill
ndarray/base/assign
Array.prototype.filter
Array.prototype.find
Array.prototype.findIndex
Array.prototype.findLast
Array.prototype.findLastIndex
Array.prototype.flat
flatten
Array.prototype.flatMap
flatten-by
Array.prototype.forEach
(in-progress)Array.prototype.includes
Array.prototype.indexOf
Array.prototype.join
Array.prototype.keys
ndarray/iter/indices
Array.prototype.lastIndexOf
Array.prototype.map
(in progress)Array.prototype.pop
slice(0,axis.length-1)
Array.prototype.push (???)
Array.prototype.reduce
Array.prototype.reduceRight
Array.prototype.reverse
Array.prototype.shift
slice(1)
Array.prototype.slice
ndarray/slice
Array.prototype.some
Array.prototype.sort
to-sorted
by the copy version.Array.prototype.splice
Array.prototype.toLocaleString
Array.prototype.toReversed
Array.prototype.toSorted
Array.prototype.toSpliced
Array.prototype.toString
ndarray.toString()
?Array.prototype.unshift
Array.prototype.values
ndarray/iter/values
Array.prototype.with
assign
in order to copy, and then set the individual elementndarray/base/assign
for acceleration in Node.jsBase:
ndarray/base/*
Array.prototype.fill
ndarray/base/fill
Array.prototype.forEach
ndarray/base/for-each
Array.prototype.map
ndarray/base/map
Array.prototype.reverse
ndarray/base/reverse
Array.prototype.slice
ndarray/base/slice
Array.prototype.toReversed
ndarray/base/to-reversed
Related Issues
None.
Questions
No.
Other
No.
Checklist
RFC:
.The text was updated successfully, but these errors were encountered: