Mojo-Numerics-and-Algorithms-group / NuMojo

NuMojo is a library for numerical computing in Mojo 🔥 similar to numpy in Python.
Apache License 2.0
112 stars 15 forks source link

NDArray Initialization from UnsafePointer #111

Closed mmenendezg closed 1 month ago

mmenendezg commented 1 month ago

New initialization method from an UnsafePointer. Additionally, removed the initialization for random arrays from the ndarray.mojo file.

shivasankarka commented 1 month ago

@mmenendezg I am not sure if we should expose a UnsafePointer constructor method to user. Do you have any specific use cases for such constructor? Is there something similar in numpy?

forFudan commented 1 month ago

@mmenendezg I am not sure if we should expose a UnsafePointer constructor method to user. Do you have any specific use cases for such constructor? Is there something similar in numpy?

I don't think that we should do this. It looks quite unsafe.

mmenendezg commented 1 month ago

Got it

@mmenendezg I am not sure if we should expose a UnsafePointer constructor method to user. Do you have any specific use cases for such constructor? Is there something similar in numpy?

I totally missed the safety implications on this, and I rather looked at possible initialization alternatives. I will reverse that and only remove the redundant initialization methods.

forFudan commented 1 month ago

I totally missed the safety implications on this, and I rather looked at possible initialization alternatives. I will reverse that and only remove the redundant initialization methods.

@mmenendezg The function itself is still useful. I think you can put this into the array creation routine, and rename the function as, e.g., "from_unsafepointer()".

mmenendezg commented 1 month ago

I totally missed the safety implications on this, and I rather looked at possible initialization alternatives. I will reverse that and only remove the redundant initialization methods.

@mmenendezg The function itself is still useful. I think you can put this into the array creation routine, and rename the function as, e.g., "from_unsafepointer()".

That's a good idea. I will make the changes.