Closed mmenendezg closed 1 month ago
var array = nm.NDArray[nm.f32](data=List[Int](1,2,3,4,5,6), shape=List[Int](2,3))
The issue is that the data type of the NDArray is nm.f32
but the data type of the list is Int
. They are not compatible. The correct code is:
var array = nm.NDArray[nm.f32](data=List[Float32](1,2,3,4,5,6), shape=List[Int](2,3))
As @forFudan said it is a result of Mojo's type system, I think when we are closer to V1.0 the code you wrote should be usable. However, I suspect the time it takes to cast values will make it worth it to match the type of the lists used as data inputs for NDArray to the array type itself.
Thanks for trying out our library, if you want to make a PR or feature request to add type casting of the data list please feel free to do so. All PRs should be made on the experimental branch.
Hi @mmenendezg In the PR #81, an array can be initiated from a string representation of array. You do not need to indicate the type again. If you are willing to try the experimental branch, this might be of interest to you.
This seems really great! More flexibility is great for the devs!
Describe the bug Creating a
NDArray
by specifying thedata
andshape
raises an error that both keyword arguments are unknown.To Reproduce
Error raised:
Screenshots