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.
pip install imidimport 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"| 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
TypeErrorifarris not anumpy.ndarray. - Raises
ValueErroriflengthis outside 1-32 (inclusive).
pip install -e ".[test]"
pytestMIT