Skip to main content

Personal Python utilities for scientific plotting, formatting and data handling

Project description

bastools

Personal Python utilities for scientific plotting, formatting and data handling. Mainly LLM-generated with post-correction.

Installation

uv add bastools

Or from source:

git clone https://github.com/BastienGrvt/bastools
cd bastools
uv sync

Minimal example

import bastools as bst

# Grid of subplots, last row auto-centered
fig, axs = bst.subplots_grid(2, 3, n_plots=5, plot_size=(5, 4))

# Format a measurement with its uncertainty
label = bst.sci_notation(1.234e-3, 5.6e-5, n=2)

axs[0].set_title(label)
fig.savefig("figure.png", dpi=300, bbox_inches="tight")

Available tools

Plots (bastools.plots)

  • subplots_grid(rows, cols, n_plots, plot_size, grid) - matplotlib subplot grid with automatic centering of incomplete rows
  • plot_colormap(...) - plot a family of curves colored by a parameter, with linear or log colorbar

Helpers (bastools.helpers)

  • set_not_none(class_parent, **kwargs) - assign keyword arguments to an object, skipping None values
  • get_not_none(arg, arg_type) - return the argument if set, else a default of the given type
  • sci_notation(mu, sigma, n) - format a value and its uncertainty in scientific notation
  • smart_tqdm(iterable, *args, **kwargs) - tqdm wrapper that auto-detects nesting and sets leave accordingly
  • wsl_show(fig, file_path) - save a matplotlib figure and open it from WSL
  • wsl_open(file_path) - open a file with the Windows default application from WSL

Draw (bastools.draw)

  • svg_draw(x_min, x_max, N, unit_size, foo, file_path) - render a 1D function as an SVG path

Requirements

Python >= 3.13 - numpy, scipy, matplotlib, tqdm, rich, svgwrite

License

Apache-2.0 - see LICENSE.

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

bastools-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

bastools-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file bastools-0.1.0.tar.gz.

File metadata

  • Download URL: bastools-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bastools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 95356168ebce1f91001b4a2f3eb20c2f793ba38b78aa1e7ddb83e0ec82116cd4
MD5 619155d3be56fb95e63e67ed4054da33
BLAKE2b-256 6d3bc558a661cdbca308d9de2d948a7d6513e80be23df8735650deb9a63be251

See more details on using hashes here.

File details

Details for the file bastools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bastools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bastools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05b8a3b9260d673ad5a37b1fc75fda90ab2887de87daf043fccbf24083652986
MD5 8e17d5094f319c214749036f394c2977
BLAKE2b-256 421b14fb60bac18cee94ede9295fd18bb7dac2290a039d4b09bca98f71a6bb60

See more details on using hashes here.

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