Skip to content
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

New additions and fixed typos #91

Conversation

shivasankarka
Copy link
Collaborator

@shivasankarka shivasankarka commented Aug 16, 2024

  • Magic 🪄 is here! Added .lock and .toml files with magic, the new modular package manager. Some useful tasks that are available are

    • magic run final - This command runs tests, performs formatting and packages NuMojo. This is useful before making the final commit to ensure everything works.
    • magic run test - This command runs test, packages NuMojo.
    • magic run format - This command does the same as mojo format ./
    • magic run package - This command does the same as mojo package numojo
  • some functions such as sort, flatten are done inplace for internal methods so that we have the following,

import numojo as nj
var arr = NDArray[i32](10, 10)
arr.sort() # sorts it in place
var arr_sorted = nj.sort(arr) # creates a new array and sorts it
  • Added some other basic functions such as diagflat, tri, trace etc.

  • Added Transpose T() method to transpose inplace (support only 2D arrays for now)

var arr = NDArray(2,2)
arr.T()
  • Added a new constructor to initialize arrays from numpy arrays (works only for float64 currently).
var np = Python.import_module("numpy")
var np_arr = np.arange(1, 10, 1).reshape(3,3)
var nj_array = NDArray(data = np_arr)

@shivasankarka shivasankarka changed the title New additions and fixed typos for V0.2 New additions and fixed typos Aug 17, 2024
@shivasankarka shivasankarka marked this pull request as draft August 17, 2024 06:43
@forFudan
Copy link
Collaborator

I have one suggestion on the name of the function: use numojo.sort() instead of numojo.sorted(). This means that when the function is a function, it first creates a copy and then make the in-place sort; when the function is a method of NDArray, it just conduct an in-place sort of the array itself. That is:

var arr_sorted = nj.sort(ar) # creates a new array and sorts it

@shivasankarka
Copy link
Collaborator Author

@forFudan Yes, you are right, I forgot to make that change. I will change it in the PR.

MadAlex1997
MadAlex1997 previously approved these changes Sep 8, 2024
@MadAlex1997 MadAlex1997 dismissed their stale review September 8, 2024 13:20

Draft status and failing tests on Linux

@forFudan forFudan added the enhancement New feature or request label Sep 9, 2024
@forFudan forFudan linked an issue Sep 9, 2024 that may be closed by this pull request
@shivasankarka shivasankarka marked this pull request as ready for review September 9, 2024 17:07
@MadAlex1997 MadAlex1997 merged commit 504b9dd into Mojo-Numerics-and-Algorithms-group:experimental Sep 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make sort() method an inplace method
3 participants