Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,18 @@ jobs:
run: |
curl -fsSL https://pixi.sh/install.sh | bash
echo "$HOME/.pixi/bin" >> $GITHUB_PATH

- name: Add Modular to Pixi
run: |
export PATH="$HOME/.pixi/bin:$PATH"
pixi add modular

- name: Set up Modular environment
run: |
echo "MODULAR_HOME=$HOME/.modular" >> $GITHUB_ENV
echo "$HOME/.modular/bin" >> $GITHUB_PATH
echo "$HOME/.modular/pkg/packages.modular.com_mojo/bin" >> $GITHUB_PATH

- name: Setup Python virtualenv
- name: Pixi install
run: |
python3 -m venv $HOME/venv/
. $HOME/venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
pixi install

- name: Install packages
- name: Build package
run: |
pip install "numpy"
pixi run mojo package numojo
cp numojo.mojopkg tests/

- name: Run tests
run: |
export PATH="$HOME/.pixi/bin:$PATH"
pixi install
pixi run mojo test tests -I .
pixi run mojo test tests/core/test_matrix.mojo -I . -D F_CONTIGUOUS
12 changes: 3 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ repos:
hooks:
- id: mojo-format
name: mojo-format
entry: pixi run mojo format ./
entry: pixi run mojo format
language: system
files: '\.(mojo|🔥|py)$'
stages: [pre-commit]
pass_filenames: false # Don't pass filenames to the formatter
always_run: true # Always run the formatter
# - id: autodoc
# name: mautodoc
# entry: magic run doc_pages
# language: system
# files: '\.(mojo|🔥|py)$'
# stages: [pre-commit]
# pass_filenames: false # Don't pass filenames to the formatter
# always_run: true # Always run the formatter
12 changes: 6 additions & 6 deletions numojo/core/complex/complex_ndarray.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -2041,12 +2041,12 @@ struct ComplexNDArray[dtype: DType = DType.float64](
```.
"""
try:
var result: String = String("ComplexNDArray[CDType.") + String(
self.dtype
) + String("](List[ComplexSIMD[CDType.c") + String(
self._re.dtype
) + String(
"]]("
var result: String = (
String("ComplexNDArray[CDType.")
+ String(self.dtype)
+ String("](List[ComplexSIMD[CDType.c")
+ String(self._re.dtype)
+ String("]](")
)
if self._re.size > 6:
for i in range(6):
Expand Down
4 changes: 3 additions & 1 deletion numojo/core/ndarray.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -3518,7 +3518,9 @@ struct NDArray[dtype: DType = DType.float64](
# the pritable region to determine the digits before decimals and
# the negative sign and then determine the formatted width.
if dimension == 0:
var negative_sign: Bool = False # whether there should be a negative sign
var negative_sign: Bool = (
False # whether there should be a negative sign
)
var number_of_digits: Int # number of digits before or after decimal point
var number_of_digits_small_values: Int # number of digits after decimal point for small values
var formatted_width: Int # formatted width based on precision and digits before decimal points
Expand Down
8 changes: 4 additions & 4 deletions numojo/routines/creation.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ fn geomspace[

if endpoint:
var result: NDArray[dtype] = NDArray[dtype](NDArrayShape(num))
var base: Scalar[dtype] = (stop / start)
var base: Scalar[dtype] = stop / start
var power: Scalar[dtype] = 1 / Scalar[dtype](num - 1)
var r: Scalar[dtype] = base**power
for i in range(num):
Expand All @@ -798,7 +798,7 @@ fn geomspace[

else:
var result: NDArray[dtype] = NDArray[dtype](NDArrayShape(num))
var base: Scalar[dtype] = (stop / start)
var base: Scalar[dtype] = stop / start
var power: Scalar[dtype] = 1 / Scalar[dtype](num)
var r: Scalar[dtype] = base**power
for i in range(num):
Expand Down Expand Up @@ -841,7 +841,7 @@ fn geomspaceC[
var result: ComplexNDArray[dtype] = ComplexNDArray[dtype](
NDArrayShape(num)
)
var base: ComplexSIMD[dtype] = (stop / start)
var base: ComplexSIMD[dtype] = stop / start
var power: Scalar[dtype] = 1 / Scalar[dtype](num - 1)
var r: ComplexSIMD[dtype] = base**power
for i in range(num):
Expand All @@ -855,7 +855,7 @@ fn geomspaceC[
var result: ComplexNDArray[dtype] = ComplexNDArray[dtype](
NDArrayShape(num)
)
var base: ComplexSIMD[dtype] = (stop / start)
var base: ComplexSIMD[dtype] = stop / start
var power: Scalar[dtype] = 1 / Scalar[dtype](num)
var r: ComplexSIMD[dtype] = base**power
for i in range(num):
Expand Down
6 changes: 3 additions & 3 deletions numojo/routines/manipulation.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ fn _set_values_according_to_shape_and_strides(
and strides for variadic number of dimensions.
"""
for index_of_axis in range(new_shape[current_dim]):
var current_sum = previous_sum + index_of_axis * new_strides[
current_dim
]
var current_sum = (
previous_sum + index_of_axis * new_strides[current_dim]
)
if current_dim >= new_shape.ndim - 1:
I._buf.ptr[index] = current_sum
index = index + 1
Expand Down
6 changes: 3 additions & 3 deletions numojo/routines/math/differences.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ fn trapz[

var integral: Scalar[dtype] = 0.0
for i in range(x.size - 1):
var temp = (x.load(i + 1) - x.load(i)) * (
y.load(i) + y.load(i + 1)
) / 2.0
var temp = (
(x.load(i + 1) - x.load(i)) * (y.load(i) + y.load(i + 1)) / 2.0
)
integral += temp
return integral