Skip to main content

A python library for converting between d-dimensional points and indices on a hilbert curve

Project description

Hilbert Bytes

build pypi docs

Hilbert Bytes is a python library for converting to and from points in d-dimensions and their corresponding index on a hilbert curve. It's similar to hilbertcurve and numpy-hilbert-curve but is faster and more space efficient than either by keeping manipulations at the byte level, and using numba to compile the results. It also uses arbitrary precision integers, allowing you to make the grid arbitrarily fine

Installation

pip install hilbert-bytes

Usage

import hilbert_bytes
import numpy as np

points = ... # arbitrary d-dimensional points
num, dim = points.shape
# convert to big-endian bytes
points_bytes = points[..., None].astype(">u8").view("u1")
index_bytes = hilbert_bytes.encode(points_bytes)  # indies as big-endian ints
new_points_bytes = hilbert_bytes.decode(index_bytes, dim)

If you want the indices as multi-byte ints, you can can do a similar trick in reverse:

index_bytes = ... # an array of big-endian ints
indices = index_bytes.view(">u8").astype("u8")[..., -1]

But note that this will only work if your index fits in 8 bytes

Publishing

Releases are cut with the release workflow, run manually from the Actions tab with a patch, minor, or major version bump. It bumps the version, uploads to PyPI via trusted publishing, tags and creates a GitHub release, then builds and deploys the docs.

Project details


Download files

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

Source Distribution

hilbert_bytes-0.7.0.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

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

hilbert_bytes-0.7.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file hilbert_bytes-0.7.0.tar.gz.

File metadata

  • Download URL: hilbert_bytes-0.7.0.tar.gz
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hilbert_bytes-0.7.0.tar.gz
Algorithm Hash digest
SHA256 807232a06f53780f8878187b62c30786bea17978b5305b4eff16eb50910dc9c3
MD5 246f3d6e88172fd91577ab4229a4cebd
BLAKE2b-256 7a14c8e849a222a8ba27db23b7e8461d2160dc4507f150744d70dea07cf3ec35

See more details on using hashes here.

Provenance

The following attestation bundles were made for hilbert_bytes-0.7.0.tar.gz:

Publisher: release.yml on hafaio/hilbert-bytes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hilbert_bytes-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: hilbert_bytes-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hilbert_bytes-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e955c343b75d07bc1696840929018752e30b5a3db7ac057cfe7487ff74df088f
MD5 f32958b873d732775092894227427686
BLAKE2b-256 3c66b6cb198a5d08bc42603b9a6f2a06fd69a5b712ee238be05c60148745372d

See more details on using hashes here.

Provenance

The following attestation bundles were made for hilbert_bytes-0.7.0-py3-none-any.whl:

Publisher: release.yml on hafaio/hilbert-bytes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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