Skip to main content

Calculate Pi via the Monte Carlo method

Project description

Calculating Pi with Modern Tooling

image image image

We need a few things:

  1. a CLI tool to specify the number of iterations and the number of cores it runs on: picarlo --cores 4 --iterations 10000
  2. a library that can be imported in a notebook

[!CAUTION] The CLI requires a few more dependencies like typer

Tooling setup (runs on each commit)

  • uv self update & uv sync --group dev
  • linting/format checking: uv run ruff check
  • auto-formatting: uv run ruff format
  • type checking: uv run pyrefly check
  • testing: uv run pytest
  • integrate into pre-commit pre-commit run --all-files
  • use maturin framework to run MC via Rust
  • build a GitHub actions pipeline to run prior to merge into main (and post to publish to PyPi)
  • run tests in parallel
  • split between dev and prod dependencies: uv add --group dev
  • add a build system, hatchling in pyproject.toml
  • run a build uv build

Checks

  1. Check that the package can be installed: uv run --with picarlo --no-project -- python -c "import picarlo"

Goal

  1. run from command-line (uvx)
  2. import lib into notebook (either via PyPi or from local dist)
  3. published module

Useful stuff

  1. Create docstrings via LLM
  2. Create docs from docstrings
  3. Calculate test coverage
  4. Tracing
  5. server-sent event via starlette

More interesting stuff

  • parallelism, e.g. concurrent.futures (see prime number example)
  • bulk python version testing through tox

Release preparation

  1. Generate Changelog: make changelog (requires Conventional Commits)
  2. Bump Version: Update pyproject.toml and Cargo.toml
  3. Build: make build
  4. Publish: make publish

Commit Convention

This project uses Conventional Commits to automate changelog generation.

  • feat: ... for new features
  • fix: ... for bug fixes
  • docs: ... for documentation
  • perf: ... for performance improvements

Example: git commit -m "feat: add parallel processing support"

vscode extensions

  1. Ruff
  2. TOML syntax highlighting

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picarlo-0.4.5.tar.gz (124.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

picarlo-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl (246.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

Details for the file picarlo-0.4.5.tar.gz.

File metadata

  • Download URL: picarlo-0.4.5.tar.gz
  • Upload date:
  • Size: 124.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for picarlo-0.4.5.tar.gz
Algorithm Hash digest
SHA256 4d10c3c700fb0772160581b1ab450c184851fedcca00de86b91e198d991b1aea
MD5 5a0d9ef93170f41320eaaa1848809c02
BLAKE2b-256 4e55d63220e59174b8199d0c8e1be9ac21601ea6d2110417334d1437e91d5ed6

See more details on using hashes here.

Provenance

The following attestation bundles were made for picarlo-0.4.5.tar.gz:

Publisher: ci.yml on hendrikfrentrup/picarlo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file picarlo-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for picarlo-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 daa0dc763199cf6e71c1de8854c1fae160fab0b58e87f4dc456f6e4018557c5b
MD5 d1d71ade9eaff370a8c7f6c06767a4fd
BLAKE2b-256 807830aa9ab3e193924cbbccae916aef09d8cc68c958b446c4100e51f2be11ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for picarlo-0.4.5-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: ci.yml on hendrikfrentrup/picarlo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page