Helper functions to increase efficiency.
Project description
Baloot
Small, focused Python helpers for experiments and day-to-day developer workflows. The package is pure Python, has no required runtime dependencies, and keeps the API flat so you can import most helpers directly from baloot.
Overview
- Lightweight utilities for seeding, file helpers, settings, Torch ergonomics, plotting, and small modules.
- Optional integrations: install the libraries you actually use (e.g.,
torch,numpy,matplotlib). - A simple, readable API surface intended for quick reuse in scripts and research code.
Installation
- From PyPI:
pip install baloot
- Local editable install:
pip install -e .
Requires Python 3.9+.
Optional dependencies (install as needed):
torchforbaloot.torch,baloot.modules, andseed_torch/seed_everything.numpyforseed_numpyand charting utilities.matplotlibforbaloot.chartutilities.
Usage
Quick start:
from baloot import acceleration_device, funnel, seed_everything, settings
device = acceleration_device() # torch: cuda -> mps -> cpu
seed_everything(42) # python, numpy, torch aligned
funnel("model.pkl", model) # save a pickled object
print(settings("training.batch_size", default=32))
API reference (all implemented methods)
Top-level re-exports (from baloot import ...):
acceleration_device()->torch.deviceparameter_count(model)->intksg_mi(x, y, k=3)->torch.Tensorrandomly_replace_layers(model, target_type, replacement_pool)->torch.nn.Modulerender_template(template_location, target_location, **replacements)->boolfunnel(file_location, thing=None)->bool | Any | Noneseed_python(seed)->Noneseed_torch(seed)->Noneseed_numpy(seed)->Noneseed_everything(seed)->Noneseed_gym(seed, environment, seed_observation=False)->Noneseed_gymnasium(seed, environment)->Nonesettings(key, default=None)->Anyget_settings(*args, **kwargs)->Anyreload_settings()->None
Files & utilities (organized by module):
baloot.files
_save_thing(thing, file_location)->bool: Pickle and save an object._load_thing(file_location)->Any | None: Load a pickled object.funnel(file_location, thing=None)->bool | Any | None: Save whenthingis provided; load whenthing=None.render_template(template_location, target_location, **replacements)->bool: Replace%key%placeholders in a template.
baloot.seed
seed_torch(seed)->None: Seed CPU/CUDA and set deterministic cuDNN flags.seed_numpy(seed)->None: Seed NumPy RNG.seed_python(seed)->None: Seed Pythonrandom._try_seed_space(space, seed)->None: Internal helper for Gym-style spaces.seed_gymnasium(seed, environment)->None: Seed Gymnasium env, action space, and observation space.seed_gym(seed, environment, seed_observation=False)->None: Seed classic Gym action space (+ optional observation space).seed_everything(seed)->None: Call Python, NumPy, and Torch seeders.
baloot.settings
settings(key, default=None)->Any: Dotted-path lookup insettings.jsonfrom the working directory.reload_settings()->None: Clear the settings cache.get_settings(*args, **kwargs)->Any: Alias forsettings.
baloot.torch
parameter_count(model)->int: Count trainable parameters (requires_grad=True).acceleration_device()->torch.device: Pickcuda,mps, thencpu.randomly_replace_layers(model, target_type, replacement_pool)->torch.nn.Module: Recursively swap layers by type.ksg_mi(x, y, k=3)->torch.Tensor: Kraskov-Stoegbauer-Grassberger MI estimate.
baloot.modules
Reshape.forward(x)->torch.Tensor: Reshape to[B, -1, DIM].PatchEmbedding.__init__(channels, features, patch_width, patch_height, activate=False, activation=torch.nn.functional.gelu)PatchEmbedding.forward(x)->torch.Tensor
baloot.drl
linear_epsilon(step, k, start_eps, end_eps)->float: Linear epsilon schedule.cosine_epsilon(step, k, start_eps, end_eps)->float: Cosine epsilon schedule.
baloot.chart
size(width, height=None)->None: Set figure size (square whenheight=None).dpi(resolution)->None: Set figure DPI.spring(x, y=None, title=None, xtitle=None, ytitle=None, output_path=None, color="#2E86C1", alpha=0.1)->(figure, axis)
Notes:
settings.jsonis read from the current working directory. Callreload_settings()after edits.- Torch-dependent utilities require
torchinstalled; chart utilities requirematplotlibandnumpy.
Copyright
MIT License. Copyright (c) 2025 Taha Shieenavaz. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file baloot-0.0.25.tar.gz.
File metadata
- Download URL: baloot-0.0.25.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41a1e5e42fdde9acd21010ca4998e6c0c9820e090356cf4fbb081dd0079314a6
|
|
| MD5 |
340d85056a049d3f5dc5f388f2fb0786
|
|
| BLAKE2b-256 |
5d8e6e852f3d4886ea3f7e255be826e1d707626b7317c61a52eae38d68c889cb
|
File details
Details for the file baloot-0.0.25-py3-none-any.whl.
File metadata
- Download URL: baloot-0.0.25-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
989e3a2531bff860638eb763ef9c5584be04089815211a8b5830c6b229b72e6c
|
|
| MD5 |
0e94f702caf36b20e7fe98a2f9faf9e2
|
|
| BLAKE2b-256 |
3ca6f5126c01124138dcf7969979926cd180cd63b96df4567fc0de95ee7145ca
|