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.3.tar.gz (115.0 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.3-cp312-cp312-manylinux_2_34_x86_64.whl (247.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

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

File metadata

  • Download URL: picarlo-0.4.3.tar.gz
  • Upload date:
  • Size: 115.0 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.3.tar.gz
Algorithm Hash digest
SHA256 78ebd0537e89f507d311eccfab4007c48869cd7802d934c560412b425d85c08b
MD5 05b313cb94096536e8787e81a76e4d16
BLAKE2b-256 65c70cd5d477b5973f6250539aa741201ab4b5508629b7d704ac4e6e7e12f925

See more details on using hashes here.

Provenance

The following attestation bundles were made for picarlo-0.4.3.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.3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for picarlo-0.4.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6e482de99ada2acc1e122bd22802a6cd1e1bfc6c423367398041bd8d635cf8ce
MD5 555637d25e901a0c5649dc1332134083
BLAKE2b-256 dcd6f1963af8596e9b2155c797c8806d3c48f3db218766155a64ac74f7a6a7aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for picarlo-0.4.3-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