Skip to content

Commit 4229b76

Browse files
authored
[release] Merge pre-0.5 branch to main branch for release (#197)
Merge pre-0.5 branch to main branch for release of V0.5. See `docs/changelog.md` for differences.
2 parents 5599b1a + c27ba14 commit 4229b76

File tree

161 files changed

+34156
-4476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+34156
-4476
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
docs/readthedocs/docs.json -diff -merge -text
2+
docs/readthedocs/docs.json linguist-generated=true
3+
docs/readthedocs/docs/autodocs/*.md -diff -merge -text
4+
docs/readthedocs/docs/autodocs/*.md linguist-generated=true

.github/workflows/run_tests.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: ["ubuntu-22.04", "macos-14"]
16+
# os: ["ubuntu-22.04", "macos-14"]
17+
os: ["ubuntu-22.04"]
1718

1819
runs-on: ${{ matrix.os }}
1920
timeout-minutes: 30

.gitignore

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/build
33
/dist
44
/local
5-
/.vscode
6-
.DS_Store
7-
*.html
8-
*.css
9-
*.py
105
*.egg-info
11-
*.pyc
6+
7+
# VSCode files
8+
/.vscode
9+
10+
# MacOs Desktop Service file
11+
*.DS_Store
1212

1313
# magic environments
1414
.magic
@@ -17,10 +17,20 @@
1717
.pixi
1818
/venv
1919

20+
21+
# Irrelevant files
22+
*.html
23+
*.css
24+
*.py
25+
*.pyc
26+
2027
# Miscellaneous files
2128
mojo
2229
numojo.mojopkg
2330
bench.mojo
2431
test_ndarray.ipynb
2532
test.mojo
26-
tempCodeRunnerFile.mojo
33+
tempCodeRunnerFile.mojo
34+
35+
# Auto docs
36+
docs/readthedocs/docs.json

.pre-commit-config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ repos:
66
entry: magic run mojo format
77
language: system
88
files: '\.(mojo|🔥|py)$'
9-
stages: [pre-commit]
9+
stages: [pre-commit]
10+
# - id: autodoc
11+
# name: mautodoc
12+
# entry: magic run doc_pages
13+
# language: system
14+
# files: '\.(mojo|🔥|py)$'
15+
# stages: [pre-commit]

.readthedocs.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
# Read the Docs configuration file
4+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
5+
6+
# Required
7+
version: 2
8+
9+
# Set the OS, Python version, and other tools you might need
10+
build:
11+
os: ubuntu-24.04
12+
tools:
13+
python: "3.12"
14+
15+
# Build documentation with Mkdocs
16+
mkdocs:
17+
configuration: docs/readthedocs/mkdocs.yml
18+
19+
# Optionally, but recommended,
20+
# declare the Python requirements required to build your documentation
21+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
22+
python:
23+
install:
24+
- requirements: docs/readthedocs/.requirements.txt
25+
26+

README.MD

Lines changed: 82 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
NuMojo is a library for numerical computing in Mojo 🔥 similar to NumPy, SciPy in Python.
66

7-
**[Explore the docs»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo-Examples-and-Benchmarks/blob/main/docs/README.md)** **[Changelog»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/docs/changelog.md)** **[Check out our Discord»](https://discord.com/channels/1149778565756366939/1149778566603620455)**
8-
9-
**[中文·简»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/docs/readme_zhs.md)** **[中文·繁»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/docs/readme_zht.md)** **[日本語»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/docs/readme_jp.md)**
7+
**[Explore the docs»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo-Examples-and-Benchmarks/blob/main/docs/README.md)** | **[Changelog»](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/docs/changelog.md)** | **[Check out our Discord»](https://discord.gg/NcnSH5n26F)**
108

119
**Table of Contents**
1210

@@ -22,65 +20,47 @@ NuMojo is a library for numerical computing in Mojo 🔥 similar to NumPy, SciPy
2220

2321
## About the project
2422

25-
***What NuMojo is***
23+
NuMojo aims to encompass the extensive numerics capabilities found in Python packages such as NumPy, SciPy, and Scikit-learn.
2624

27-
NuMojo intends to capture a wide swath of numerics capability present in the Python packages NumPy, SciPy, and Scikit.
25+
=======
2826

29-
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration (once available). Currently, NuMojo extends (most of) the standard library math functions to work on array inputs.
27+
***What NuMojo is***
3028

31-
We intend NuMojo to be a building block for other Mojo packages that need fast math under the hood without the added weight of a ML back and forward propagation system
29+
We seek to harness the full potential of Mojo, including vectorization, parallelization, and GPU acceleration (when available). Currently, NuMojo extends most (if not all) standard library math functions to support array inputs.
3230

33-
***What NuMojo is not***
31+
Our vision for NuMojo is to serve as an essential building block for other Mojo packages needing fast math operations, without the additional weight of a machine learning back-propagation system.
3432

35-
NuMojo is not a machine learning library, it will never include back-propagation in the base library.
33+
***What NuMojo is not***
3634

37-
## Goals and features
35+
NuMojo is not a machine learning library and will never include back-propagation as part of the base library.
3836

39-
Our main goal is to implement a fast, comprehensive numerics library in Mojo.
37+
## Features and goals
4038

41-
Following are some brief long-term goals. Some of them have already been implemented or partially implemented.
39+
Our primary objective is to develop a fast, comprehensive numerics library in Mojo. Below are some features and long-term goals. Some have already been implemented, either fully or partially.
4240

4341
Core data types:
4442

4543
- Native n-dimensional array (`numojo.core.ndarray.NDArray`).
46-
- Native 2-dimensional array, i.e., matrix (`numojo.mat.matrix.Matrix`).
44+
- Native 2-dimensional array, i.e., matrix (`numojo.core.matrix.Matrix`).
45+
- Native n-dimensional complex array (`numojo.core.complex_ndarray.ComplexNDArray`)
4746
- Native fixed-dimension array (to be implemented when trait parameterization is available).
4847

4948
Routines and objects:
5049

5150
- Array creation routines (`numojo.routines.creation`)
5251
- Array manipulation routines (`numojo.routines.manipulation`)
53-
- Bit-wise operations (`numojo.routines.bitwise`)
54-
- Constants (`numojo.routines.constants`)
5552
- Input and output (`numojo.routines.io`)
56-
- Text files (`numojo.routines.files`)
57-
- Text formatting options (`numojo.routines.formatting`)
5853
- Linear algebra (`numojo.routines.linalg`)
59-
- Decompositions (`numojo.routines.decompositions`)
60-
- Products of matrices and vectors (`numojo.routines.products`)
61-
- Solving (`numojo.routines.solving`)
6254
- Logic functions (`numojo.routines.logic`)
63-
- Comparison (`numojo.routines.comparison`)
64-
- Array contents (`numojo.routines.contents`)
65-
- Truth value testing (`numojo.routines.truth`)
6655
- Mathematical functions (`numojo.routines.math`)
67-
- Arithmetic operations (`numojo.routines.arithmetic`)
6856
- Exponents and logarithms (`numojo.routines.exponents`)
6957
- Extrema finding (`numojo.routines.extrema`)
70-
- Floating point routines (`numojo.routines.floating`)
71-
- Hyperbolic functions (`numojo.routines.hyper`)
72-
- Indexing (`numojo.routines.indexing`)
73-
- Miscellaneous (`numojo.routines.misc`)
7458
- Rounding (`numojo.routines.rounding`)
75-
- Sums, products, differences (`numojo.routines.sums`, `numojo.routines.products`, `numojo.routines.differences`)
7659
- Trigonometric functions (`numojo.routines.trig`)
7760
- Random sampling (`numojo.routines.random`)
7861
- Sorting, searching, and counting (`numojo.routines.sorting`, `numojo.routines.searching`)
7962
- Statistics (`numojo.routines.statistics`)
80-
- Averages and variances (`numojo.routines.averages`)
81-
- Calculus, Integration & Derivatives etc
82-
- Optimizers
83-
- Function approximators
63+
- etc...
8464

8565
Please find all the available functions and objects [here](docs/features.md).
8666

@@ -97,8 +77,8 @@ from numojo.prelude import *
9777
9878
fn main() raises:
9979
# Generate two 1000x1000 matrices with random float64 values
100-
var A = nm.random.randn(shape=Shape(1000, 1000))
101-
var B = nm.random.randn(shape=Shape(1000, 1000))
80+
var A = nm.random.randn(Shape(1000, 1000))
81+
var B = nm.random.randn(Shape(1000, 1000))
10282
10383
# Generate a 3x2 matrix from string representation
10484
var X = nm.fromstring[f32]("[[1.1, -0.32, 1], [0.1, -3, 2.124]]")
@@ -116,26 +96,27 @@ fn main() raises:
11696
var A_slice = A[1:3, 4:19]
11797
11898
# Get scalar from array
119-
var A_item = A[Idx(291, 141)]
99+
var A_item = A[item(291, 141)]
100+
var A_item_2 = A.item(291, 141)
120101
```
121102

122103
An example of matrix (`Matrix` type) goes as follows.
123104

124105
```mojo
125-
from numojo import mat
106+
from numojo import Matrix
126107
from numojo.prelude import *
127108
128109
129110
fn main() raises:
130111
# Generate two 1000x1000 matrices with random float64 values
131-
var A = mat.rand(shape=(1000, 1000))
132-
var B = mat.rand(shape=(1000, 1000))
112+
var A = Matrix.rand(shape=(1000, 1000))
113+
var B = Matrix.rand(shape=(1000, 1000))
133114
134115
# Generate 1000x1 matrix (column vector) with random float64 values
135-
var C = mat.rand(shape=(1000, 1))
116+
var C = Matrix.rand(shape=(1000, 1))
136117
137118
# Generate a 4x3 matrix from string representation
138-
var F = mat.fromstring[i8](
119+
var F = Matrix.fromstring[i8](
139120
"[[12,11,10],[9,8,7],[6,5,4],[3,2,1]]", shape=(4, 3)
140121
)
141122
@@ -150,12 +131,12 @@ fn main() raises:
150131
print(C[::-1, :])
151132
152133
# Sort and argsort along axis
153-
print(mat.sort(A, axis=1))
154-
print(mat.argsort(A, axis=0))
134+
print(nm.sort(A, axis=1))
135+
print(nm.argsort(A, axis=0))
155136
156137
# Sum the matrix
157-
print(mat.sum(B))
158-
print(mat.sum(B, axis=1))
138+
print(nm.sum(B))
139+
print(nm.sum(B, axis=1))
159140
160141
# Matrix multiplication
161142
print(A @ B)
@@ -164,27 +145,74 @@ fn main() raises:
164145
print(A.inv())
165146
166147
# Solve linear algebra
167-
print(mat.solve(A, B))
148+
print(nm.solve(A, B))
168149
169150
# Least square
170-
print(mat.lstsq(A, C))
151+
print(nm.lstsq(A, C))
152+
```
153+
154+
An example of ComplexNDArray is as follows,
155+
156+
```mojo
157+
import numojo as nm
158+
from numojo.prelude import *
159+
160+
161+
fn main() raises:
162+
# Create a complexscalar 5 + 5j
163+
var complexscalar = ComplexSIMD[cf32](re=5, im=5)
164+
# Create complex array filled with (5 + 5j)
165+
var A = nm.full[cf32](Shape(1000, 1000), fill_value=complexscalar)
166+
# Create complex array filled with (1 + 1j)
167+
var B = nm.ones[cf32](Shape(1000, 1000))
168+
169+
# Print array
170+
print(A)
171+
172+
# Array slicing
173+
var A_slice = A[1:3, 4:19]
174+
175+
# Array multiplication
176+
var C = A * B
177+
178+
# Get scalar from array
179+
var A_item = A[item(291, 141)]
180+
# Set an element of the array
181+
A[item(291, 141)] = complexscalar
171182
```
172183

173184
## How to install
174185

175-
There are two approach to install and use the Numojo package.
186+
There are three approach to install and use the Numojo package.
187+
188+
### Use magic CLI
189+
190+
You can use the following command in the terminal to install `numojo`.
191+
192+
```console
193+
magic add numojo
194+
```
195+
196+
### Add in toml file
197+
198+
You can add `numojo` in the dependencies section of your toml file.
199+
200+
```toml
201+
[dependencies]
202+
numojo = "==0.5"
203+
```
176204

177205
### Build package
178206

179-
This approach invovles building a standalone package file `mojopkg`.
207+
This approach involves building a standalone package file `mojopkg`.
180208

181209
1. Clone the repository.
182-
2. Build the package using `mojo package numojo`
183-
3. Move the numojo.mojopkg into the directory containing the your code.
210+
2. Build the package using `magic run package`.
211+
3. Move the `numojo.mojopkg` into the directory containing the your code.
184212

185213
### Include NuMojo's path for compiler and LSP
186214

187-
This approach does not require buiding a package file. Instead, when you compile your code, you can include the path of NuMojo reporsitory with the following command:
215+
This approach does not require building a package file. Instead, when you compile your code, you can include the path of NuMojo repository with the following command:
188216

189217
```console
190218
mojo run -I "../NuMojo" example.mojo
@@ -213,6 +241,8 @@ This library is still very much a work in progress and may change at any time.
213241

214242
Distributed under the Apache 2.0 License with LLVM Exceptions. See [LICENSE](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/LICENSE) and the LLVM [License](https://llvm.org/LICENSE.txt) for more information.
215243

244+
This project includes code from [Mojo Standard Library](https://github.com/modularml/mojo), licensed under the Apache License v2.0 with LLVM Exceptions (see the LLVM [License](https://llvm.org/LICENSE.txt)). MAX and Mojo usage and distribution are licensed under the [MAX & Mojo Community License](https://www.modular.com/legal/max-mojo-license).
245+
216246
## Acknowledgements
217247

218248
Built in native [Mojo](https://github.com/modularml/mojo) which was created by [Modular](https://github.com/modularml).

0 commit comments

Comments
 (0)