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)

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")[..., 0]

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

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.5.0.tar.gz (4.4 MB 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.5.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hilbert_bytes-0.5.0.tar.gz
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.28

File hashes

Hashes for hilbert_bytes-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d92ee631eb21e07b82ec9a03ed992e6aa60385d60aea6723efce71fc5d54b881
MD5 cbf99d83b4f7a3026e26e2d39edff7a3
BLAKE2b-256 144e1c973908b3f3ac75297e46dfc345070fd1c3f420a76e192e06a95b04a3af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hilbert_bytes-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecd8829a98eb9b17679d6ca28f6221e0d585b61f0f0adadaa2fdbb96958a35e7
MD5 e0c92910e1fdb031179c57cc64327cc1
BLAKE2b-256 ab64008e289254176ff5de578d3a0439dd065b4f9d8268bd0fb760c33ce4ecbf

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