diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 2e6f88f8..f1885bc3 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85e3e687..a31afa6a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 \ No newline at end of file diff --git a/numojo/core/complex/complex_ndarray.mojo b/numojo/core/complex/complex_ndarray.mojo index 4c113b2c..54a4c923 100644 --- a/numojo/core/complex/complex_ndarray.mojo +++ b/numojo/core/complex/complex_ndarray.mojo @@ -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): diff --git a/numojo/core/ndarray.mojo b/numojo/core/ndarray.mojo index ed3c50b3..4f0af156 100644 --- a/numojo/core/ndarray.mojo +++ b/numojo/core/ndarray.mojo @@ -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 diff --git a/numojo/routines/creation.mojo b/numojo/routines/creation.mojo index 5f6de347..9c3fb906 100644 --- a/numojo/routines/creation.mojo +++ b/numojo/routines/creation.mojo @@ -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): @@ -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): @@ -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): @@ -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): diff --git a/numojo/routines/manipulation.mojo b/numojo/routines/manipulation.mojo index 0f43ab7b..3c97a2fd 100644 --- a/numojo/routines/manipulation.mojo +++ b/numojo/routines/manipulation.mojo @@ -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 diff --git a/numojo/routines/math/differences.mojo b/numojo/routines/math/differences.mojo index dab3615b..5302d435 100644 --- a/numojo/routines/math/differences.mojo +++ b/numojo/routines/math/differences.mojo @@ -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