Metadata-Version: 2.4
Name: tet-py
Version: 0.3.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering
Requires-Dist: numpy>=2.0
Requires-Dist: h5py>=3.10 ; extra == 'convert'
Requires-Dist: netcdf4>=1.6 ; extra == 'convert'
Requires-Dist: zarr>=3 ; extra == 'convert'
Requires-Dist: pyarrow>=14.0 ; extra == 'convert'
Requires-Dist: pytest>=8.0 ; extra == 'dev'
Requires-Dist: maturin>=1.7 ; extra == 'dev'
Requires-Dist: mypy>=1.13 ; extra == 'dev'
Requires-Dist: numpy>=2.0 ; extra == 'dev'
Requires-Dist: h5py>=3.10 ; extra == 'export'
Requires-Dist: netcdf4>=1.6 ; extra == 'export'
Requires-Dist: zarr>=3 ; extra == 'export'
Requires-Dist: h5py>=3.10 ; extra == 'h5'
Requires-Dist: netcdf4>=1.6 ; extra == 'netcdf'
Requires-Dist: pyarrow>=14.0 ; extra == 'parquet'
Requires-Dist: zarr>=3 ; extra == 'zarr'
Provides-Extra: convert
Provides-Extra: dev
Provides-Extra: export
Provides-Extra: h5
Provides-Extra: netcdf
Provides-Extra: parquet
Provides-Extra: zarr
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Summary: Python bindings for Tetration .tet files and the query engine
Keywords: tetration,tensor,mmap,zarr,hdf5,netcdf
Author-email: AHurowitz <latkaindustries@gmail.com>
License: MIT OR Apache-2.0
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://docs.tetration.sh/python/
Project-URL: Homepage, https://docs.tetration.sh/python/
Project-URL: Repository, https://github.com/Latka-Industries/tet-py

# tet-py

[![PyPI](https://img.shields.io/pypi/v/tet-py.svg)](https://pypi.org/project/tet-py/)
[![Docs](https://img.shields.io/badge/docs-docs.tetration.sh-blue)](https://docs.tetration.sh/python/)
[![CI](https://github.com/Latka-Industries/tet-py/actions/workflows/ci.yml/badge.svg)](https://github.com/Latka-Industries/tet-py/actions/workflows/ci.yml)
[![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue)](LICENSE-MIT)

Python bindings for [**Tetration**](https://github.com/Latka-Industries/tetration) — mmap-friendly `.tet` tensors and the JSON/TOML query engine.

| | |
| --- | --- |
| **Install** | [`pip install tet-py`](https://pypi.org/project/tet-py/) → `import tet` |
| **Docs** | [docs.tetration.sh/python](https://docs.tetration.sh/python/) |
| **Rust core** | [`tetration`](https://crates.io/crates/tetration) (linked at build time) |
| **CLI** | [`tet`](https://github.com/Latka-Industries/tetration) binary from the main repo |

Do **not** `pip install tetration` — that PyPI name is unrelated math code.

## Quick start

```bash
pip install tet-py
python -c "import tet; print(tet.__version__, tet.core_version())"
```

```python
import tet

with tet.open("data.tet") as f:
    print(f.mean("temperature"), f.quantile("temperature", 0.5))
    arr = f.read_numpy("temperature")                 # ram (memmap for full-width raw slabs)
    z = f.transform.to_numpy.zscore("temperature")  # transform → ndarray
```

More examples: [Python quick start](https://docs.tetration.sh/python/quick-start) · [operations](https://docs.tetration.sh/python/operations) · [NumPy](https://docs.tetration.sh/python/numpy)

## Convert

`tet.convert` writes one `.tet` from a foreign file. `.npy`, multi-member `.npz`, and `.csv` / `.tsv` are in the core wheel. Other formats are optional extras: `tet-py[h5]`, `[netcdf]`, `[zarr]`, `[parquet]`, or `[convert]` for all of them.

| Extra | What it imports |
| --- | --- |
| *(core)* | `.npy` (one dataset), `.npz` (every member), `.csv` / `.tsv` (numeric + category text columns) |
| `h5` | HDF5 datasets, groups as `parent/child` names |
| `netcdf` | NetCDF variables, including groups |
| `zarr` | Zarr v2 and v3 directory stores |
| `parquet` | Parquet numeric columns and UTF-8 category columns |

Compared with Rust `tet convert`: Python does not apply CF scale/offset, chunks the whole array unless you pass `chunk_shape`, and can read codecs the Rust importer skips when the extra library can decode them. Columns that are not layout-v1 numeric (or category text) are omitted.

## Export

`tet.export` (and `TetFile.export`) writes a `.tet` to HDF5, NetCDF, or Zarr. Same optional extras as convert (`[h5]`, `[netcdf]`, `[zarr]`, or `[export]` for those three). Dense numeric datasets only; carries `dim_names` and basic string attrs when present. Values are densified via `read_numpy` — prefer Rust `tet export` when you need native HDF5/NetCDF or chunk-preserving Zarr.

## Packages

`tet.open("pkg.tet.d")` reads the generation named by `CURRENT` (`packed.tet`). `tet.ingest` copies a sealed `.tet` into staging, and `tet.publish` seals those parts and updates `CURRENT`.

For an S3-compatible backend:

```python
from tet import S3Store

store = S3Store.connect(endpoint="http://127.0.0.1:9000", bucket="…",
                        access_key_id="…", secret_access_key="…", prefix="demo")
store.ingest("part.tet", session_id="s0")
store.publish(["part"])
f = store.open("current")  # pin; later publish does not retarget f
```

Endpoint and credentials are arguments (not in the URI). See [`docs/operations.md`](docs/operations.md#packages).

## Documentation

| Topic | Where |
| ----- | ----- |
| Install, API, NumPy sinks | [docs.tetration.sh/python](https://docs.tetration.sh/python/) |
| Query ops (local mirror) | [`docs/operations.md`](docs/operations.md) |
| Release notes | [`CHANGELOG.md`](CHANGELOG.md) |
| Format + query wire | [docs.tetration.sh](https://docs.tetration.sh) · [tetration repo](https://github.com/Latka-Industries/tetration) |
| Roadmap | [docs.tetration.sh/roadmap](https://docs.tetration.sh/roadmap) |

## Develop

```bash
uv sync --extra dev
mise run develop          # or: uv run maturin develop
uv run pytest -q
uv run mypy python/tet
```

Requires Python **3.11+** and Rust **1.95+** ([`.mise.toml`](.mise.toml)). Fixtures: `tests/fixtures/`.

## License

**MIT OR Apache-2.0**, same as [tetration](https://github.com/Latka-Industries/tetration).

