Simple python utilities for various projects.
Project description
Kōyō
A utility library of reusable Python functions used throughout various projects in the Van de Plas lab.
Features
| Module | Description |
|---|---|
koyo.click |
CLI helpers: path parsing, plugin loading, parameter tables, timed iterators |
koyo.system |
Platform detection, environment variable helpers, version checks, disk-space checks |
koyo.utilities |
Generic utils: nearest-index search (Numba-accelerated), array rescaling, chunking, size formatting |
koyo.timer |
Human-readable timing and measure_time context manager |
koyo.multicore |
joblib-backed multi-core helpers with RAM-aware CPU count |
koyo.logging |
loguru-based logging configuration |
koyo.color |
RGB/hex conversions and matplotlib colour utilities |
koyo.path |
File-system helpers: zero-copy sendfile, glob utilities, URI handling |
koyo.zarr |
Zarr-backed compressed array storage (Blosc/zip) |
koyo.sparse |
scipy.sparse convenience wrappers |
koyo.compression |
Generic data-compression utilities |
koyo.fig_mixin |
FigureMixin for composable figure export |
koyo.pdf_mixin |
PDF export backend |
koyo.pptx_mixin |
PowerPoint export backend (requires pptx extra) |
koyo.spectrum |
Spectroscopy (mass-spectrometry) utilities |
koyo.mosaic |
Rectangle-packing algorithm for image/figure mosaics |
koyo.decorators |
retry decorator with exponential back-off |
koyo.json |
JSON serialisation helpers |
koyo.toml |
TOML file handling |
Installation
pip install koyo
Optional dependencies
# PowerPoint export
pip install koyo[pptx]
# Image-processing utilities (scikit-learn)
pip install koyo[image]
# Clipboard support
pip install koyo[clipboard]
# Windows shortcut support
pip install koyo[win]
# All extras
pip install koyo[pptx,image,clipboard,win]
Quick start
from koyo.utilities import find_nearest_index, rescale, format_size
from koyo.system import is_installed, get_version
from koyo.timer import measure_time
# Find the closest index in a sorted array
import numpy as np
arr = np.linspace(0, 100, 1000)
idx = find_nearest_index(arr, 42.7)
# Rescale an array to [0, 1]
scaled = rescale(arr, 0, 1)
# Human-readable byte size
print(format_size(1_500_000)) # "1.4M"
# Check whether a package is installed
if is_installed("zarr"):
print(f"zarr {get_version('zarr')} is available")
# Time a block of code
with measure_time() as t:
result = some_expensive_function()
print(f"Finished in {t():.3f}s")
Contributing
Contributions are always welcome. Please feel free to submit PRs with new features, bug fixes, or documentation improvements.
git clone https://github.com/vandeplaslab/koyo.git
cd koyo
pip install -e ".[dev]"
Run the test suite:
pytest
Run linting:
ruff check src/
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
koyo-0.3.5.tar.gz
(121.3 kB
view details)
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
koyo-0.3.5-py3-none-any.whl
(104.8 kB
view details)
File details
Details for the file koyo-0.3.5.tar.gz.
File metadata
- Download URL: koyo-0.3.5.tar.gz
- Upload date:
- Size: 121.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ad0d0af7591c7247914612c2ed810b6cafdbd931cec81d6963260bb3ad5f477
|
|
| MD5 |
b629bd80ca9a3811baf1f37baf1ba419
|
|
| BLAKE2b-256 |
4dc8b7f5360a478544ba429dc56c0c7d48a8a766f19a60ed01db076dc689c4e7
|
File details
Details for the file koyo-0.3.5-py3-none-any.whl.
File metadata
- Download URL: koyo-0.3.5-py3-none-any.whl
- Upload date:
- Size: 104.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c24ffef9ec8271ec11f772899cf5bfb0140fdc246419432b242b0aa53b98f99
|
|
| MD5 |
ee3fd8272354e824c8dda6032c116ded
|
|
| BLAKE2b-256 |
8d7257b00e9a82dce347fef428052552b5f244ee993d4bf84b61177797b549da
|