Skip to main content

High-performance Python bindings for the AirMettle AirTree C++ library

Project description

pyairtree

Python bindings for AirTree — a high-performance library for building, compressing, and querying multi-dimensional histograms over floating-point data.

Turn large numeric datasets into compact .airtree histograms and run fast statistical queries without keeping the full raw data in memory.

Required Notice: Copyright AirMettle, Inc. (https://airmettle.com)


Installation

pip install pyairtree

Supported platforms

Platform Architecture Python
Linux x86_64, ARM 3.8 – 3.12
Windows amd64 3.8 – 3.12

NumPy is installed automatically as a dependency.

Verify the install

import pyairtree
print(pyairtree.__version__)

Quick start

Build a 1D histogram from a NumPy array, save it, and query percentiles:

import numpy as np
import pyairtree

# Sample data
data = np.random.randn(100_000)

# Build a compressed histogram (1D, high precision)
buffer = pyairtree.generate(data)

# Save to disk
pyairtree.write(buffer, "histogram.airtree")

# Query percentiles
p = pyairtree.Percentile(buffer)
print(f"Median: {p.get_percentile(50):.4f}")
print(f"95th percentile: {p.get_percentile(95):.4f}")

Load data directly from .npy or single-array .npz files

buffer = pyairtree.generate("samples/data.npy")

Core workflow

A typical workflow has three steps:

  1. Generate — compress numeric arrays into an in-memory histogram buffer
  2. Store — write the buffer to a .airtree file
  3. Query — run statistics or spatial queries on the buffer or file
import pyairtree

# 1. Generate
buffer = pyairtree.generate(x, y, options)

# 2. Store
pyairtree.write(buffer, "output.airtree")

# 3. Query
reader = pyairtree.read("output.airtree")
p = pyairtree.Percentile(buffer)

Generating histograms

Unified generate() API (recommended)

Pass one NumPy array per dimension. Use AirTreeOptions to control dimensionality and precision:

import numpy as np
import pyairtree

x = np.random.randn(50_000)
y = np.random.randn(50_000)

options = pyairtree.AirTreeOptions()
options.dimensions = 2
options.type = pyairtree.ConfigType.XP   # highest precision (default for most use cases)

buffer = pyairtree.generate(x, y, options)

Configuration types

Type Precision Best for
ConfigType.XT 13-bit Large datasets, fastest builds
ConfigType.XF 16-bit General-purpose balance
ConfigType.XP 20-bit (1D) / 10-bit (2D+) Highest accuracy

Dimensionality

# 1D
buf_1d = pyairtree.generate(a, options)

# 2D
buf_2d = pyairtree.generate(a, b, options)

# 3D
buf_3d = pyairtree.generate(a, b, c, options)

# 4D
buf_4d = pyairtree.generate(a, b, c, d, options)

Set options.dimensions to match the number of arrays you pass.

Named generation functions

Convenience functions are also available for explicit configs:

arr = pyairtree.buildFPHArray(data)

# 1D
pyairtree.generate_1DxT(arr)   # 13-bit
pyairtree.generate_1DxF(arr)   # 16-bit
pyairtree.generate_1DxP(arr)   # 20-bit

# 2D / 3D / 4D
pyairtree.generate_2DxP(arr_x, arr_y)
pyairtree.generate_3DxP(arr_x, arr_y, arr_z)
pyairtree.generate_4DxP(arr_x, arr_y, arr_z, arr_w)

Supported array types

NumPy arrays with dtype float64, float32, int64, or int32.


File I/O

Write a histogram

pyairtree.write(buffer, "histogram.airtree")

Read a histogram

reader = pyairtree.read("histogram.airtree")

print(reader.dims)        # number of dimensions
print(reader.bit_length)  # encoding precision
print(reader.type)        # configuration type

header = reader.header
print(header.version)
print(header.nan_count)

Query operations

Percentile (1D)

p = pyairtree.Percentile(buffer)

median = p.get_percentile(50.0)
p95    = p.get_percentile(95.0)

Min / Max (1D)

mm = pyairtree.MinMax(buffer)
print(mm.get_min(), mm.get_max())

Top-K (1D)

Return the bins with the highest counts:

topk = pyairtree.TopK(buffer)
results = topk.top_k(10.0)   # top 10% of bins by count

for r in results:
    print(r.lower_bound, r.upper_bound, r.count)

CDF (1D)

cdf = pyairtree.CDF(buffer)
values = cdf.get_cdf()

Bounding box (2D)

Count values inside a rectangular region:

bbox_query = pyairtree.BoundingBox(buffer_2d)

region = pyairtree.BoundingBoxCoordinate2D(
    min_x=0.0, max_x=1.0,
    min_y=0.0, max_y=1.0,
)

safe, edge = bbox_query.get_counts(region)
(safe_coords, safe_count) = safe
(edge_coords, edge_count) = edge

Grid query (1D)

Evaluate the histogram over a regular grid:

gq = pyairtree.GridQuery(buffer)
result = gq.get_grid(spec)   # pass a GridSpec with min, max, steps
rows = result.materialize_rows()

Export

Export histogram data to common interchange formats:

pyairtree.export_tree(buffer, "output.arrow", pyairtree.ExportFormat.ARROW)
pyairtree.export_tree(buffer, "output.parquet", pyairtree.ExportFormat.PARQUET)
pyairtree.export_tree(buffer, "output.csv", pyairtree.ExportFormat.CSV)

Choosing a configuration

Use case Suggested config
Exploratory analysis on large 1D datasets ConfigType.XT or generate_1DxT
Production 1D analytics ConfigType.XF or generate_1DxF
High-precision 1D requirements ConfigType.XP or generate_1DxP
2D spatial / correlation data generate_2DxP
3D / 4D multi-variate data generate_3DxP / generate_4DxP

Error handling

import pyairtree
import numpy as np

try:
    pyairtree.generate(np.array(["not", "numeric"]))
except (TypeError, RuntimeError) as e:
    print(f"Generation failed: {e}")

try:
    pyairtree.Percentile(two_d_buffer)   # Percentile is 1D only
except RuntimeError as e:
    print(f"Query failed: {e}")

License

AirMettle Noncommercial License

This software is provided for noncommercial use only. Government use requires a separate commercial license.

• Personal, research, educational, and qualifying nonprofit use is permitted • Commercial or government use requires a license from AirMettle

For commercial licensing, support, or enterprise usage:

support@airmettle.com

Patent Pending — U.S. Patent Application Publication No. 2025/0217930 A1 (https://patents.google.com/patent/US20250217930A1)

See the bundled LICENSE file for full terms.


Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyairtree-1.3.0-cp312-cp312-win_amd64.whl (25.5 MB view details)

Uploaded CPython 3.12Windows x86-64

pyairtree-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyairtree-1.3.0-cp311-cp311-win_amd64.whl (20.4 MB view details)

Uploaded CPython 3.11Windows x86-64

pyairtree-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyairtree-1.3.0-cp310-cp310-win_amd64.whl (15.3 MB view details)

Uploaded CPython 3.10Windows x86-64

pyairtree-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyairtree-1.3.0-cp39-cp39-win_amd64.whl (10.2 MB view details)

Uploaded CPython 3.9Windows x86-64

pyairtree-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyairtree-1.3.0-cp38-cp38-win_amd64.whl (5.1 MB view details)

Uploaded CPython 3.8Windows x86-64

pyairtree-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file pyairtree-1.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyairtree-1.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 25.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pyairtree-1.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 253185ad135a8ba99b15415d36e245b267353920e130c7eda5123cd20c4e90f2
MD5 de22a854b92b6b1f7d6c042ab90b8470
BLAKE2b-256 3a1028100a5c7794f225ec6748adf02358a3ad82550610eed71433ba8ca99e5b

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyairtree-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70d039847ad3ed114f505cbb78591dc460cbbd9ac53da83e593b8e0e10833371
MD5 a4f8c2e84393ece07a48ae38bcec31e8
BLAKE2b-256 31559c7b0cdbf933b5c42bb812067cd293ca9ccfc888122581be413bb03ca4db

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyairtree-1.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 20.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pyairtree-1.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c4aea043ebe578e2bc48a3c360555d5a5dcc41ea9861f014d29f58c383230c2e
MD5 4034fe7c916dcd9ec54cf8e1a99d08f6
BLAKE2b-256 560a2e3c52f43af5dc5fc4db6b73561c48816ede71420ec0c8e7f29d6ed3153e

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyairtree-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 935666a9e01a039e1b882eef4c756de76513adb9f64b9ca3eacff8821b0c2ef0
MD5 23accccac5b9d98581823ddff418a553
BLAKE2b-256 7d3f5b86266db30fd71f2ae140135bd4f2ee5e4478e949b30fc2d99167da1b5c

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyairtree-1.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 15.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pyairtree-1.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 36823d618e01035bd94368f1f558bde7a2abd259bc74bdbf151bb1611c5ec1ab
MD5 9fa355641f195836ddfef0da152a5b8d
BLAKE2b-256 fa6e30a5cf4792337296257286b9e7c848f8b428bcfe1e1cbc85eecf24e15b83

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyairtree-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f370ea9331c534e7e95b3f6b93918528bf6851e7e95ce0b4d1803ba5cbe61d90
MD5 d90586178dae3403fe1bac64ca72f92b
BLAKE2b-256 f23fa72c9174c6a01579a7fcc18b62098dd392ae8c79eddf75849907cebd032b

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyairtree-1.3.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 10.2 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pyairtree-1.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d2db2b3a3ee4d0df69087006717651c747201bedc31fd8f18041ac3778ab49ed
MD5 65bbd63ec421eb1d3fede28953c81bd4
BLAKE2b-256 f2becadae9810a3a6c7526dd990b39592aae6e5e816622e3937dc9570c852275

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyairtree-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 328f666d85314ff2af730361de7117581fbf89497acdb2b7b36a283ed31cf838
MD5 460ecad90b70514683f5301e3fb99922
BLAKE2b-256 6ab41ef36231388d895d6421adb3fa80cc1be1ee9b489a8f722335ba4b1dee16

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyairtree-1.3.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 5.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pyairtree-1.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9a3fe213dcc6aa20a696dc3e640c43f717a1137871e2f6a309248643abfe30b5
MD5 7fd06cebfc42f3181b3ec944038068b0
BLAKE2b-256 930a89a4a254b628fb61b749db17e8cafa2df9e4be8bf8fa190d11bcf96b4756

See more details on using hashes here.

File details

Details for the file pyairtree-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyairtree-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34642e39e2feada1b8aca0876f5b317434d43cb3e3a7c818c9fd8245958a8f4c
MD5 9e5ca678c3b8ad0cf3afb36732245c2d
BLAKE2b-256 d77f9058e14b66af8d2b28fa1e1d0ce90d95f5d508ffbfe2bcb7cf88f81f1b05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page