Skip to main content

mech-lab-tools

Toolbox Python per l'analisi dei dati di laboratorio di meccanica.

L'obiettivo del progetto e' raccogliere in un unico package le utility che tornano spesso nei notebook di laboratorio: caricamento CSV, statistiche descrittive e pesate, istogrammi e fit lineare con incertezze.

Lo stato attuale e' ancora Alpha: il package e' gia' utilizzabile per casi semplici, ma l'API non va considerata stabile.

Cosa c'e' oggi

Il package espone direttamente:

  • load_csv
  • median
  • weighted_mean
  • variance
  • covariance
  • standard_deviation
  • histogram
  • lin_fit

I moduli attualmente presenti in src/mech_lab_tools sono:

  • io_utils.py: lettura CSV con gestione di separatori, decimali, colonne richieste e missing values
  • stats_utils.py: funzioni statistiche di base, anche con pesi
  • plot_utils.py: istogrammi con media e banda ±1σ
  • fit_utils.py: fit lineare pesato con residui, incertezze sui parametri e grafico opzionale

Struttura del progetto

mech-lab-tools/
├── src/mech_lab_tools/   # package Python
├── tests/                # test pytest
├── notebooks/            # notebook di prova e dimostrazione
├── docs/                 # documentazione LaTeX e PDF
├── data/reference/       # dataset di riferimento per test/esempi
├── figures/              # figure esportate
├── tools/                # script di supporto
├── pyproject.toml        # metadata del package
└── Makefile              # comandi di setup e documentazione

Requisiti

  • Python >= 3.12
  • git
  • lualatex, latexmk e pygmentize solo se vuoi ricompilare la documentazione
  • font richiesti dalla build docs: Libertinus Serif, Libertinus Math, Libertinus Sans, JetBrains Mono, Inter Display

Installazione rapida

Clona il repository ed entra nella directory:

git clone https://github.com/giancarmine-sparso/mech-lab-tools
cd mech-lab-tools

Crea il virtualenv e installa il package con le dipendenze di sviluppo:

make setup

Questo installa anche gli strumenti usati per il check pre-release (build e twine).

Se vuoi attivare l'ambiente manualmente:

source .venv/bin/activate

Esempio minimo

from mech_lab_tools import lin_fit, load_csv, weighted_mean

df = load_csv("data/reference/test_misure.csv", sep=",", decimal=".")

x = df["misura_n"].to_numpy(dtype=float)
y = df["lunghezza_mm"].to_numpy(dtype=float)
sigma_y = df["sigma_mm"].to_numpy(dtype=float)

y_bar = weighted_mean(y, 1 / sigma_y**2)

fit = lin_fit(
    x=x,
    y=y,
    sigma_y=sigma_y,
    xlabel="numero misura",
    ylabel="lunghezza [mm]",
    plot=False,
)

print("media pesata:", y_bar)
print("pendenza:", fit["m"])

Documentazione

La documentazione del package e' in docs/main.pdf.

Per ricompilarla:

make docs

Il target usa minted, quindi richiede anche pygmentize disponibile nel PATH. Inoltre il sorgente LaTeX usa i font Libertinus Serif, Libertinus Math, Libertinus Sans, JetBrains Mono e Inter Display. make check-tex verifica i comandi necessari e, se fc-match e' disponibile nel sistema, controlla anche la presenza di questi font.

Le sezioni attualmente documentate sono:

  • io_utils
  • stats_utils
  • plot_utils
  • fit_utils

Check pre-release

Per eseguire il gate completo di release PyPI in locale:

make release-check

Il comando esegue test, compileall, pip check, build di sdist e wheel, validazione con twine check e smoke test degli import a partire dalla wheel generata.

Comandi utili

Target Descrizione
make setup Crea il virtualenv e installa il package in editable mode con dipendenze dev
make venv Crea solo il virtualenv
make install Installa il package locale e le dipendenze
make test Esegue l'intera suite pytest
make dist Genera sdist e wheel in dist/
make twine-check Valida gli artifact generati con twine check
make release-check Esegue il gate completo pre-release per PyPI
make check-tex Verifica i prerequisiti LaTeX e, se possibile, i font richiesti
make docs Compila la documentazione PDF
make docs-clean Rimuove i file temporanei LaTeX
make dist-clean Rimuove gli artifact Python di build
make clean Esegue la pulizia generale

Note

  • I notebook in notebooks/ sono esempi di utilizzo e test esplorativi, non documentazione API stabile.

Metadata

Release files for mech-lab-tools 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mech-lab-tools 0.1.2
File Size Uploaded Provenance Actions
mech_lab_tools-0.1.2.tar.gz 15.0 kB Without provenance Details for mech_lab_tools-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mech-lab-tools 0.1.2
File Interpreter ABI Platform Actions
mech_lab_tools-0.1.2-py3-none-any.whl Python 3 none any Details for mech_lab_tools-0.1.2-py3-none-any.whl

Total release size: 27.0 kB

Release files / mech_lab_tools-0.1.2.tar.gz

Download URL mech_lab_tools-0.1.2.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
460f07bfa569f41bf0daff29065b51360817c83137d58adaf928a2f90757c47c
BLAKE2b-256 checksum
How to use checksums
53220ee06681a47405c8e478bcb4526490c89c4b80dd36a1d46612bc52361e09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / mech_lab_tools-0.1.2-py3-none-any.whl

Download URL mech_lab_tools-0.1.2-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
407eb83d42867d9b9a3faf9bf46792f2852a3e67f3c9d03d19d2523231c004b6
BLAKE2b-256 checksum
How to use checksums
a5b3317a19467cef1b23baf7e59ec2bff872015b2cf03435fe2edfb319f60da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for mech-lab-tools 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page