-
Notifications
You must be signed in to change notification settings - Fork 15
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
[change + remove] Clean and uniform the array generation routines #127
[change + remove] Clean and uniform the array generation routines #127
Conversation
|
This is not aligned with numpy and would cause ambiguity, especially To avoid ambiguity, it is better to wrap shape in a different container (numpy uses tuple, we use NDArrayShape), and to wrap data in the list type.
Yes, but we should also remove these list and varadic list in other workload later. The reason is the same as above (avoid abiguity).
I think at the moment, we'd better keep it close to numpy, since numpy is the best practice for years. Another reason is that we should limit the way of using each function. Overload brings flexibility, but also makes users confused.
I am little bit hesitant for this. |
|
This is fine.
What I meant is that, if we remove any instances of List, VariadicList etc completely from NuMojo, anyone who uses NuMojo as part of their workflow, might have problems interpolating with native Mojo containers like List, VariadicList etc. So either we should allow for List, VariadicList input arguments in NDArray constructors (this pollutes the constructors), or allow for List, VariadicArguments input arguments in NDArrayShape constructors (This seems more simple, but the syntax becomes long), for example, var arr = NDArray[i16](List[Int](1,2,3)) # NDArray constructors -> This overloads the NDArray constructor, but simple syntax
var arr = NDArray[i16](shape(List[Int](1,2,3))) # NDArrayShape constructor -> simple, but long syntax |
@shivasankarka, Yes, I agree with you. In the case of Thus, we actually need something like I will make a change for this. |
@forFudan Should the alias be at the top |
…ankarka/main Fixed adjust slice
…an/changelog Update the change log for v0.3.1
…umerics-and-Algorithms-group/pre-0.4 Prepare for V0.3.1
@shivasankarka For |
…ack to `__init__`.
…os` and `ones`. The fill will be done in `full` function but not `__init__` of NDArray.
NDArrayShape
.48ca770
into
Mojo-Numerics-and-Algorithms-group:pre-0.4
It is a step towards cleaner and uniformed array generation routines. The core principle is to (1) Uniform the interface for each function by limiting the main argument to only one class and (2) align it with
numpy
.(1)
array()
function only reads in a "data object", e.g., string, PyObject, List. Other reloads are moved to standalone functions.(2) The argument
shape
only takes in the typeShapeLike
. See the following example:This is aligned with
numpy
. Innumpy
, theshape
parameter is wrapped in a tuple (or a single Int).Note that the following way of creating array is not possible anymore because it is not a
numpy
style, and will be confused with the potential keyword arguments, e.g.,order
.(3) Uniform the calling chains.
full
function will fill the memory directly, instead of via__init__
. This is a step towards makingNDArray
a pure container.zeros
andones
functions will call the functionfull
.List
andVariadicList
will call the function that reads inNDArrayShape
. The function hits will also reflect this. This is to significantly shrink the lines of code, make it less verbose, and make it more trackable. See figure below.(4) Next step.
Reduce the number of overloads in
NDArray.__init__
according to #110.