HsdPy
HsdPy library allows users to use Hsdlib in Python.
Installation
pip install hsdpy
Examples
Below is a simple usage example of HsdPy:
import hsdpy
# HsdPy uses NumPy for array handling
import numpy as np
# Create two NumPy arrays of float32 type
a = np.array([1.0, 2.0, 3.0], dtype=np.float32)
b = np.array([4.0, 5.0, 6.0], dtype=np.float32)
# Calculate the euclidean distance between the two arrays
dist_euc = hsdpy.dist_sqeuclidean_f32(a, b) ** 0.5
# Calculate Manhattan distance
dist_man = hsdpy.dist_manhattan_f32(a, b)
# Let's see the results
print(f"Euclidean distance: {dist_euc}") # 5.196
print(f"Manhattan distance: {dist_man}") # 9.0
# See the SIMD backend in use
print(f"Backend: {hsdpy.get_backend()}")
Check out hsdpy_example.py for more detailed examples.
API Summary
| Function | Description | Input Types (np.ndarray) |
Return Type |
|---|---|---|---|
dist_sqeuclidean_f32(a, b) |
Computes squared Euclidean distance between vectors. | np.float32 |
float |
dist_manhattan_f32(a, b) |
Computes Manhattan distance between vectors. | np.float32 |
float |
dist_hamming_u8(a, b) |
Computes Hamming distance between binary vectors. | np.uint8 |
int |
sim_dot_f32(a, b) |
Computes dot product between vectors. | np.float32 |
float |
sim_cosine_f32(a, b) |
Computes cosine similarity between vectors. | np.float32 |
float |
sim_jaccard_u16(a, b) |
Computes Jaccard similarity between integer vectors. | np.uint16 |
float |
get_backend() |
Returns information about the backend in use. | None |
str |
get_library_info() |
Returns information about the loaded library. | None |
dict |
Notes
- HsdPy provides the
HsdErrorexception class for error handling. It is a custom exception class wraps the Hsdlib error codes to make them more Pythonic. - All distance and similarity functions expect one-dimensional NumPy arrays as input.
- Functions will raise
NotImplementedErrorif the corresponding Hsdlib function is not implemented for the given data type.
License
HsdPy is licensed under the MIT License.
Metadata
Release files for hsdpy 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hsdpy-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for hsdpy-0.5.1-py3-none-any.whl |
Release files / hsdpy-0.5.1-py3-none-any.whl
| Download URL | hsdpy-0.5.1-py3-none-any.whl |
|---|---|
| Size | 62.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bbb734d4a4029e21535c49c2606de8c50b8af2545769b85aec68a03cde254d0
|
|
BLAKE2b-256 checksum How to use checksums |
7ec2df30676825ad981d01e2a92df8c26e9d34b2fdf80c2827cb204045406436
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for hsdpy 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.