Xarray + Polars: an xarray Dataset paired with per-dimension Polars frames that stay aligned under selection.
Project description
xolars
Xarray + polars: an xarray Dataset paired with one
Polars frame per dimension, kept aligned to the Dataset's
coordinate order — including under isel/sel selection and zarr + parquet
round-trips.
Install
uv add xolars # or: pip install xolars
Usage
import numpy as np
import polars as pl
import xarray as xr
from xolars import Xolars
ds = xr.Dataset(
{"expr": (["gene_id", "sample_id"], np.arange(12.0).reshape(3, 4))},
coords={"gene_id": ["G1", "G2", "G3"], "sample_id": ["S1", "S2", "S3", "S4"]},
)
genes = pl.DataFrame({"gene_id": ["G1", "G2", "G3"], "chrom": ["c1", "c2", "c3"]})
xol = Xolars(ds=ds, df={"gene_id": genes})
# Selection filters the Dataset AND every per-dimension frame, together:
sub = xol.sel(gene_id=["G3", "G1"])
assert list(sub.df["gene_id"]["gene_id"]) == list(sub.ds["gene_id"].values)
# Persist to zarr (Dataset) + parquet (per-dim frames), then reopen lazily:
xol.write("mydata.xolars", mode="w")
reloaded = Xolars.open("mydata.xolars") # frames are pl.LazyFrame
eager = reloaded.collect() # -> pl.DataFrame
Xolars is a frozen, generic container: Xolars[pl.LazyFrame] after open,
Xolars[pl.DataFrame] after collect. Construction validates that each frame's
dim column exactly matches the Dataset coordinate (same set, same multiplicity)
and reorders rows to the Dataset's order.
Development
uv sync # create .venv with runtime + dev deps
uv run pytest -q # tests
uv run prek run --all-files # ruff + pyrefly + hygiene hooks
uv run prek install # enable git hooks locally
Releasing
Releases run via the manual Release GitHub Actions workflow
(workflow_dispatch), which uses commitizen
to bump the version from conventional commits, tag, create a GitHub release, and
publish to PyPI via OIDC trusted publishing. Before the workflow can succeed,
the following one-time setup is required on GitHub (out of scope for the initial
extraction):
- Push this repository to
https://github.com/d-laub/xolars. - Add a
GH_ACTIONSrepository secret (a PAT able to push tomain) so the bump commit + tag can be pushed past branch protection. - Configure a
pypienvironment and enable PyPI trusted publishing for thexolarsproject pointing at thepublishjob.
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 xolars-0.3.0.tar.gz.
File metadata
- Download URL: xolars-0.3.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
228153477909949fed7aae0cd4bae088181b0c7a110c8941f9ee2d79a664db9c
|
|
| MD5 |
18bd1013a07e1b8fa8eb4f35e08000ee
|
|
| BLAKE2b-256 |
465c0f869d11e2111c024815e4d3277a0f86d832b71a3574b65d8e7be4e98295
|
File details
Details for the file xolars-0.3.0-py3-none-any.whl.
File metadata
- Download URL: xolars-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0659ec9d5bf3d9d4d858bcf6bd317a923fff4ad34563d33c9a4cb7e50eff19db
|
|
| MD5 |
21525b2af54d4284cd83785f7816ba50
|
|
| BLAKE2b-256 |
d5ff63500b091ed0a53218907a2e900cc3d48d076861deabcc4d1f58f443ad88
|