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 (*_array/*_single variants are Numba-jitted), array rescaling, chunking, size formatting |
koyo.timer |
Human-readable timing and measure_time context manager |
koyo.multicore |
mpire-based multi-core helpers by default (joblib optional); only estimate_cpu_count_from_size is RAM-aware |
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 (deprecated, use ims_utils) |
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/
Metadata
Release files for koyo 0.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| koyo-0.3.7.tar.gz | 137.4 kB | Without provenance | Details for koyo-0.3.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| koyo-0.3.7-py3-none-any.whl | Python 3 | none | any | Details for koyo-0.3.7-py3-none-any.whl |
Total release size: 253.4 kB
Release files / koyo-0.3.7.tar.gz
| Download URL | koyo-0.3.7.tar.gz |
|---|---|
| Size | 137.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26aeb86ae2c63c173977e464e552a8b1ce4d8696ecd1bb08d66cd582d041a694
|
|
BLAKE2b-256 checksum How to use checksums |
d85bb833a15ac7f3d5eb04a7fb2666555f1fea0b7026acb4786b523e8ebed48f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / koyo-0.3.7-py3-none-any.whl
| Download URL | koyo-0.3.7-py3-none-any.whl |
|---|---|
| Size | 116.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcef6ab6643371ebf340daf91830d31d81f596fb5df54427e24a6ac622c25207
|
|
BLAKE2b-256 checksum How to use checksums |
1e80bd75dbd9037d2fad6526d7a528dadd8d77ae09398ca136a48a84c97a1d97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for koyo 0.3.7
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.