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)  # indices 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.1.tar.gz (56.4 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.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hilbert_bytes-0.7.1.tar.gz
  • Upload date:
  • Size: 56.4 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.1.tar.gz
Algorithm Hash digest
SHA256 a842fc2e1a6c8b05a9baef1eef682fea45701c111c179b458b6e79b22ba987a8
MD5 283feb0363af532cedf25048135b3e1b
BLAKE2b-256 2e7219852a49b48c5ef7cf779511723f96be8bbbea621cc28af8832ac54c6e82

See more details on using hashes here.

Provenance

The following attestation bundles were made for hilbert_bytes-0.7.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: hilbert_bytes-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b74c124ca7d45dba173a7fcd1d855b67538137cd0fcfc397cf5f74a4032c80f7
MD5 11576fe2032091c75542c1fd33dc502f
BLAKE2b-256 38b18d25f294435555d154e9a0e11006b9cfea7b79a1ec8237c2234048e06710

See more details on using hashes here.

Provenance

The following attestation bundles were made for hilbert_bytes-0.7.1-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