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
21 changes: 10 additions & 11 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,36 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install magic
- name: Install pixi
run: |
curl -ssL https://magic.modular.com/ | MAGIC_VERSION=0.7.0 bash
curl -fsSL https://pixi.sh/install.sh | sh

- name: Add path
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
echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV
echo "$HOME/.pixi/bin" >> $GITHUB_PATH

- name: Activate virtualenv
run: |
python3 -m venv $HOME/venv/
. $HOME/venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV

- name: Magic install
- name: Pixi install
run: |
magic install
pixi install

- name: Build package
run: |
magic run mojo package src/decimojo
magic run mojo package src/tomlmojo
pixi run mojo package src/decimojo
pixi run mojo package src/tomlmojo
cp decimojo.mojopkg tests/
cp decimojo.mojopkg benches/
mv tomlmojo.mojopkg tests/

- name: Run tests
run: |
magic run mojo test tests
pixi run mojo test tests

- name: Install pre-commit
run: |
Expand All @@ -68,5 +67,5 @@ jobs:

- name: Run pre-commit
run: |
magic install
pixi install
pre-commit run --all-files
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# pixi environments
.pixi
pixi.lock
*.egg-info
# magic environments
.magic
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
hooks:
- id: mojo-format
name: mojo-format
entry: magic run mojo format
entry: pixi run mojo format
language: system
files: '\.(mojo|🔥|py)$'
stages: [pre-commit]
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ This repository includes [TOMLMojo](https://github.com/forfudan/decimojo/tree/ma

DeciMojo is available in the [modular-community](https://repo.prefix.dev/modular-community) package repository. You can install it using any of these methods:

From the `magic` CLI, simply run ```magic add decimojo```. This fetches the latest version and makes it immediately available for import.
From the `pixi` CLI, simply run ```pixi add decimojo```. This fetches the latest version and makes it immediately available for import.

For projects with a `mojoproject.toml`file, add the dependency ```decimojo = ">=0.3.0"```. Then run `magic install` to download and install the package.
For projects with a `mojoproject.toml`file, add the dependency ```decimojo = ">=0.3.1"```. Then run `pixi install` to download and install the package.

For the latest development version, clone the [GitHub repository](https://github.com/forfudan/decimojo) and build the package locally.

| `decimojo` | `mojo` |
| ---------- | ------ |
| v0.1.0 | >=25.1 |
| v0.2.0 | >=25.2 |
| v0.3.0 | >=25.2 |
| `decimojo` | `mojo` | package manager |
| ---------- | ------------- | --------------- |
| v0.1.0 | ==25.1 | magic |
| v0.2.0 | ==25.2 | magic |
| v0.3.0 | ==25.2 | magic |
| v0.3.1 | >=25.2, <25.4 | pixi |

## Quick start

Expand Down Expand Up @@ -203,8 +204,8 @@ Regular benchmarks against Python's `decimal` module are available in the `bench

After cloning the repo onto your local disk, you can:

- Use `magic run test` to run tests.
- Use `magic run bench_decimal` to generate logs for benchmarking tests against `python.decimal` module. The log files are saved in `benches/decimal/logs/`.
- Use `pixi run test` to run tests.
- Use `pixi run bench_decimal` to generate logs for benchmarking tests against `python.decimal` module. The log files are saved in `benches/decimal/logs/`.

## Citation

Expand All @@ -216,7 +217,7 @@ If you find DeciMojo useful for your research, consider listing it in your citat
year = {2025},
title = {An arbitrary-precision decimal and integer mathematics library for Mojo},
url = {https://github.com/forfudan/decimojo},
version = {0.3.0},
version = {0.3.1},
note = {Computer Software}
}
```
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This is a list of RELEASED changes for the DeciMojo Package. For the unreleased changes, please refer to **[changelog_unreleased](https://zhuyuhao.com/decimojo/docs/changelog_unreleased.html)**.

## 06/06/2025 (v0.3.1)

DeciMojo v0.3.1 updates the codebase to Mojo 25.3 and replaces the `magic` package manager with `pixi`. This release enables you to use DeciMojo with the latest Mojo features and the new package manager.

## 15/04/2025 (v0.3.0)

DeciMojo v0.3.0 introduces the arbitrary-precision `BigDecimal` type with comprehensive arithmetic operations, comparisons, and mathematical functions (`sqrt`, `root`, `log`, `exp`, `power`). A new `tomlmojo` package supports test refactoring. Improvements include refined `BigUInt` constructors, enhanced `scale_up_by_power_of_10()` functionality, and a critical multiplication bug fix.
Expand Down
21 changes: 11 additions & 10 deletions docs/readme_zht.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ DeciMojo 爲 Mojo 提供了全面的定點數和整數運算庫,專爲處理

DeciMojo 可在 [modular-community](https://repo.prefix.dev/modular-community) 包倉庫中獲取。您可以使用以下任一方法進行安裝:

從 `magic` CLI,只需運行 ```magic add decimojo```。這會獲取最新版本並使其立即可用於導入。
從 `pixi` CLI,只需運行 ```pixi add decimojo```。這會獲取最新版本並使其立即可用於導入。

對於帶有 `mojoproject.toml` 文件的項目,添加依賴 ```decimojo = ">=0.3.0"```。然後運行 `magic install` 來下載並安裝包。
對於帶有 `mojoproject.toml` 文件的項目,添加依賴 ```decimojo = ">=0.3.1"```。然後運行 `pixi install` 來下載並安裝包。

如需最新的開發版本,請克隆 [GitHub 倉庫](https://github.com/forfudan/decimojo) 並在本地構建包。

| `decimojo` | `mojo` |
| ---------- | ------ |
| v0.1.0 | >=25.1 |
| v0.2.0 | >=25.2 |
| v0.3.0 | >=25.2 |
| `decimojo` | `mojo` | 包管理 |
| ---------- | ------------- | ------ |
| v0.1.0 | >=25.1 | magic |
| v0.2.0 | >=25.2 | magic |
| v0.3.0 | >=25.2 | magic |
| v0.3.1 | >=25.2, <25.4 | pixi |

## 快速入門

Expand Down Expand Up @@ -203,8 +204,8 @@ DeciMojo 相較於 Python 的 `decimal` 模塊提供了卓越的性能,同時

在將倉庫克隆到本地磁盤後,您可以:

- 使用 `magic run test`(或 `maigic run t`)運行測試。
- 使用 `magic run bench`(或 `magic run b`)生成對比 `python.decimal` 模塊的基準測試日誌。日誌文件保存在 `benches/logs/` 中。
- 使用 `pixi run test`(或 `pixi run t`)運行測試。
- 使用 `pixi run bench`(或 `pixi run b`)生成對比 `python.decimal` 模塊的基準測試日誌。日誌文件保存在 `benches/logs/` 中。

## 引用

Expand All @@ -216,7 +217,7 @@ DeciMojo 相較於 Python 的 `decimal` 模塊提供了卓越的性能,同時
year = {2025},
title = {DeciMojo: A fixed-point decimal arithmetic library in Mojo},
url = {https://github.com/forfudan/decimojo},
version = {0.3.0},
version = {0.3.1},
note = {Computer Software}
}
```
Expand Down
41 changes: 0 additions & 41 deletions mojoproject.toml

This file was deleted.

41 changes: 41 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[project]
authors = ["ZHU Yuhao 朱宇浩 <[email protected]>"]
channels = ["https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
# channels = ["https://conda.modular.com/max-nightly", "https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"]
description = "An arbitrary-precision decimal and integer mathematics library for Mojo"
license = "Apache-2.0"
name = "decimojo"
platforms = ["osx-arm64", "linux-64"]
readme = "README.md"
version = "0.3.1"

[dependencies]
max = ">=25.2, <25.4"

[tasks]
# format the code
format = "pixi run mojo format ./"

# compile the package
package_decimojo = "pixi run mojo package src/decimojo && cp decimojo.mojopkg tests/ && cp decimojo.mojopkg benches/ && rm decimojo.mojopkg"
package_tomlmojo = "pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/"
package = "pixi run format && pixi run package_decimojo && pixi run package_tomlmojo"
p = "clear && pixi run package"

# clean the package files in tests folder
clean = "rm tests/decimojo.mojopkg && rm benches/decimojo.mojopkg && rm tests/tomlmojo.mojopkg"
c = "clear && pixi run clean"

# tests (use the mojo testing tool)
test = "pixi run package && pixi run mojo test tests --filter"
t = "clear && pixi run package && pixi run mojo test tests --filter"

# benches
bench_decimal = "clear && pixi run package && cd benches/decimal && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
bench_bigint = "clear && pixi run package && cd benches/bigint && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
bench_biguint = "clear && pixi run package && cd benches/biguint && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
bench_bigdecimal = "clear && pixi run package && cd benches/bigdecimal && pixi run mojo -I ../ bench.mojo && cd ../.. && pixi run clean"
bench_dec = "pixi run bench_decimal"
bench_bint = "pixi run bench_bigint"
bench_buint = "pixi run bench_biguint"
bench_bdec = "pixi run bench_bigdecimal"