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 arrays differing in any of those produce different IDs.

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)                 # "a3f1b2c4"
get_id(arr, prefix="img_")  # "img_a3f1b2c4"
get_id(arr, length=16)      # "a3f1b2c4d5e6f7a8"

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 (max 32)
  • Non-contiguous arrays are handled automatically.
  • Raises ValueError if arr is not a numpy.ndarray.

Development

pip install -e ".[test]"
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.0.tar.gz (1.8 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.0-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for imid-0.2.0.tar.gz
Algorithm Hash digest
SHA256 018f4e5433c4dca90333d44e1a1c159f2d3ddf10c174218de9bc1a4d9e7ab5f5
MD5 202e514c093395a7b1e4548a86f0ceb8
BLAKE2b-256 7c146e655fe77d16ea620da95100ccb53007d2f8c6b6b2afc69ac95b27fed6d9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for imid-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f19d4df3e46c0c45fcefca3e6d870deba85f883a25650fb7d3e803b6c7ad056
MD5 00a009ad8aafec34c701816993e7b54d
BLAKE2b-256 0f0cf02f6017280d000f4724024ac146a6072a2be50d990a767707b2c0ff806b

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