Skip to main content

Deterministic MD5-based IDs for NumPy arrays

Project description

imid

Deterministic MD5-based string IDs for NumPy arrays.

The hash incorporates dtype, shape, and byte content, so differences in any of those affect the ID.

Install

pip install imid

Usage

import numpy as np
from imid import get_id

arr = np.array([1.0, 2.0, 3.0])

get_id(arr)                 # "70543f9b"
get_id(arr, prefix="img_")  # "img_70543f9b"
get_id(arr, length=16)      # "70543f9b270d20db"

API

get_id(arr, *, prefix="", length=8) -> str

Parameter Type Default Description
arr np.ndarray (required) Input array
prefix str "" String prepended to the ID
length int 8 Length of the hex digest (1-32)
  • Non-contiguous arrays are handled automatically.
  • Raises TypeError if arr is not a numpy.ndarray or length is not an int.
  • Raises ValueError if length is outside 1-32 (inclusive).

Development

python -m pip install -e ".[test]"
python -m pytest

License

MIT

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

imid-0.2.4.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

imid-0.2.4-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

Details for the file imid-0.2.4.tar.gz.

File metadata

  • Download URL: imid-0.2.4.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for imid-0.2.4.tar.gz
Algorithm Hash digest
SHA256 9f619841a2c2a2e9e40fff8ea9d7db83615eee89d116836c9c582a0d61c4643f
MD5 f24119175fe21a5a5a6900b44721fca1
BLAKE2b-256 dfce2852e618f07b105b9d7d6db7a6f30a18f8d67d157f76c91d65da0f27f7bb

See more details on using hashes here.

File details

Details for the file imid-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: imid-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 2.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for imid-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b689ed405e463e742c5a5d3b5b28ef133aeb9634020a98f8ec16362e3e69013c
MD5 991671eaf6359c481446e0286696b43a
BLAKE2b-256 c6d88c506ade5341988aae35294dfb8043f06a0223c9400a4d0a7673ab980dff

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