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

PyPI:

pip install bastools

Or with uv:

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.1.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.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bastools-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ee7a10013e608a56ca77e6f3b6aec20d2bda7ab79b8cf6705c0a6b85b39bb980
MD5 561d73090c346eace9c514e95fea0127
BLAKE2b-256 4defef73899ddd5ba2d04724f7ceee28416cf153e3c24e35ca4b625e775a2720

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bastools-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b5d4430ddac8125db06643c73c8f121c4c2b5e5dabc97dcec476bd494c713e2
MD5 4f67b13bbf11b66258069be1dbe565c0
BLAKE2b-256 945423c436c87f856848c0fc98f83e84e178ee591e0e4426c209095458396f46

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