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
45 changes: 45 additions & 0 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ jobs:
- name: Run tests
run: bash ./tests/test_decimal128.sh

# ── Test: BigFloat ─────────────────────────────────────────────────────────
test-bigfloat:
name: Test BigFloat
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v4
- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | sh
- name: Add pixi to PATH
run: |
echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV
echo "$HOME/.pixi/bin" >> $GITHUB_PATH
- name: pixi install
run: pixi install
- name: Install MPFR
run: sudo apt-get update && sudo apt-get install -y libmpfr-dev
- name: Build packages
run: |
pixi run mojo package src/decimo && cp decimo.mojopkg tests/
- name: Run tests
run: bash ./tests/test_bigfloat.sh

# ── Test: TOML parser ─────────────────────────────────────────────────────
test-toml:
name: Test TOML parser
Expand Down Expand Up @@ -197,6 +222,26 @@ jobs:
- name: Build & run Python tests
run: pixi run testpy

# ── Doc generation check ──────────────────────────────────────────────────────
doc-check:
name: Doc generation
runs-on: ubuntu-22.04
timeout-minutes: 10
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v4
- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | sh
- name: Add pixi to PATH
run: |
echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV
echo "$HOME/.pixi/bin" >> $GITHUB_PATH
- name: pixi install
run: pixi install
- name: Generate docs
run: pixi run doc

# ── Format check ─────────────────────────────────────────────────────────────
format-check:
name: Format check
Expand Down
383 changes: 364 additions & 19 deletions docs/plans/gmp_integration.md

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ format = """pixi run mojo format ./src \
&&pixi run ruff format ./python"""

# doc
doc = """pixi run mojo doc \
--diagnose-missing-doc-strings --validate-doc-strings src/decimo"""
doc = "pixi run mojo doc --diagnose-missing-doc-strings src/decimo"

# compile the package
p = "clear && pixi run package"
package = """pixi run format \
&& pixi run doc \
&& pixi run package_decimo"""
package_decimo = """pixi run mojo package src/decimo \
&& cp decimo.mojopkg tests/ \
Expand All @@ -43,21 +43,25 @@ c = "clear && pixi run clean"
clean = """rm tests/decimo.mojopkg && \
rm benches/decimo.mojopkg"""

# gmp/mpfr wrapper (compile C wrapper — no MPFR needed at build time)
bgmp = "clear && pixi run buildgmp"
buildgmp = "bash src/decimo/gmp/build_gmp_wrapper.sh"

# tests (use the mojo testing tool)
t = "clear && pixi run test"
tdecimo = "clear && pixi run testdecimo"
test = "pixi run package && bash ./tests/test_all.sh"
testdecimo = "pixi run package && bash ./tests/test_decimo.sh"
testtoml = "pixi run package && bash ./tests/test_toml.sh"
# bigfloat (build test binary linking the C wrapper, then run it)
testfloat = "pixi run buildgmp && bash ./tests/test_bigfloat.sh"
# shortcut for tests
t = "clear && pixi run test"
tdecimo = "clear && pixi run testdecimo"
tf = "clear && pixi run testfloat"
ttoml = "clear && pixi run testtoml"

# bench
bench = "pixi run package && bash benches/run_bench.sh"

# gmp/mpfr wrapper (compile C wrapper — no MPFR needed at build time)
bgmp = "clear && pixi run buildgmp"
buildgmp = "bash src/decimo/gmp/build_gmp_wrapper.sh"

# bench with debug assertions enabled
bdec_debug = """clear && pixi run package && cd benches/bigdecimal \
&& pixi run mojo run -I ../ -D ASSERT=all bench.mojo && cd ../.. \
Expand Down
1 change: 1 addition & 0 deletions src/decimo/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ from .decimal128.decimal128 import Decimal128, Dec128
from .bigint.bigint import BigInt, BInt
from .biguint.biguint import BigUInt, BUInt
from .bigdecimal.bigdecimal import BigDecimal, BDec, Decimal
from .bigfloat.bigfloat import BigFloat, BFlt, Float
from .rounding_mode import (
RoundingMode,
ROUND_DOWN,
Expand Down
2 changes: 2 additions & 0 deletions src/decimo/bigfloat/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ Modules:
- bigfloat: Core BigFloat struct with constructors, arithmetic, transcendentals
- mpfr_wrapper: Low-level FFI bindings to the MPFR C wrapper
"""

from .bigfloat import BigFloat, BFlt, Float, PRECISION as BIGFLOAT_PRECISION
Loading
Loading