Skip to main content

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):

  1. Push this repository to https://github.com/d-laub/xolars.
  2. Add a GH_ACTIONS repository secret (a PAT able to push to main) so the bump commit + tag can be pushed past branch protection.
  3. Configure a pypi environment and enable PyPI trusted publishing for the xolars project pointing at the publish job.

Metadata

Release files for xolars 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xolars 0.3.0
File Size Uploaded
xolars-0.3.0.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xolars 0.3.0
File Interpreter ABI Platform
xolars-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / xolars-0.3.0.tar.gz

Download URL xolars-0.3.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
228153477909949fed7aae0cd4bae088181b0c7a110c8941f9ee2d79a664db9c
BLAKE2b-256 checksum
How to use checksums
465c0f869d11e2111c024815e4d3277a0f86d832b71a3574b65d8e7be4e98295
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / xolars-0.3.0-py3-none-any.whl

Download URL xolars-0.3.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0659ec9d5bf3d9d4d858bcf6bd317a923fff4ad34563d33c9a4cb7e50eff19db
BLAKE2b-256 checksum
How to use checksums
d5ff63500b091ed0a53218907a2e900cc3d48d076861deabcc4d1f58f443ad88
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page