Type Aliases
PyHDC uses typed aliases throughout its API. They are defined in
pyhdc.types and re-exported from pyhdc for convenience.
Core types
- pyhdc.types.Backend
Backend = Literal["numpy", "torch"]
Specifies which array backend a hypervector or encoding uses.
- pyhdc.types.ArrayLike
ArrayLike = Union[numpy.ndarray, torch.Tensor]
The raw array types that PyHDC can operate on. NumPy arrays are always supported; PyTorch tensors require
TORCH_AVAILABLE = True.
- pyhdc.types.Device
Device = Union[str, torch.device]
A device specification for PyTorch. Common values:
"cpu","cuda","cuda:0","cuda:1". Ignored whenbackend="numpy".
- pyhdc.types.GeneratorOutputType
GeneratorOutputType = Literal["bits", "words", "floats"]
The type of values a generator produces. Each encoding family requires a specific output type from its generator. See the compatibility table in Random Number Generators.
Composite types
- pyhdc.types.HypervectorLike
HypervectorLike = Union[Hypervector, List[Hypervector]]
Accepted anywhere a single hypervector or a list of hypervectors is valid.
- pyhdc.types.HypervectorInput
HypervectorInput = Union[ ArrayLike, Hypervector, List[Hypervector], List[List[Hypervector]], ]
The broadest input type for encoding methods like
bundleandbind. Supports raw arrays, single hypervectors, flat lists, and nested lists for batched operations.
- pyhdc.types.SimilarityResult
SimilarityResult = Union[float, ArrayLike, List[Union[float, ArrayLike]]]
The return type of similarity functions. A scalar float for single-pair comparisons; an array for batched comparisons; a list for list inputs.
- pyhdc.types.SequenceType
SequenceType = Union[List[int], List[float], ArrayLike]
Used internally by the recovery module (not yet public).
Metadata types
- pyhdc.types.OperationMetadata
OperationMetadata = Dict[str, Any]
The metadata dict attached to a
Hypervector. Currently used by MBAT to store binding matrices under the key"matrices".
- pyhdc.types.OperationResult
OperationResult = Union[ArrayLike, Tuple[ArrayLike, OperationMetadata]]
The return type of raw component functions. Most return a plain array; MBAT binding returns
(array, metadata_dict).