hdlib 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hdlib
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: Hyperdimensional Computing Library for building Vector Symbolic Architectures in Python
5
- Home-page: http://github.com/cumbof/hdlib
6
- Author: Fabio Cumbo
7
- Author-email: fabio.cumbo@gmail.com
5
+ Author-email: Fabio Cumbo <fabio.cumbo@gmail.com>
8
6
  License: MIT
7
+ Project-URL: Homepage, https://github.com/cumbof/hdlib
9
8
  Project-URL: Issues, https://github.com/cumbof/hdlib/issues
10
9
  Project-URL: Source, https://github.com/cumbof/hdlib
11
10
  Project-URL: Wiki, https://github.com/cumbof/hdlib/wiki
@@ -14,31 +13,36 @@ Classifier: Intended Audience :: Information Technology
14
13
  Classifier: Intended Audience :: Science/Research
15
14
  Classifier: License :: OSI Approved :: MIT License
16
15
  Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
17
19
  Classifier: Topic :: Scientific/Engineering
18
- Requires-Python: >=3
20
+ Requires-Python: >=3.11
19
21
  Description-Content-Type: text/markdown
20
22
  License-File: LICENSE
21
- Requires-Dist: numpy>=2.2.5
22
- Requires-Dist: scikit-learn>=1.6.1
23
+ Requires-Dist: mthree>=3.0.0
24
+ Requires-Dist: numpy>=2.3.4
25
+ Requires-Dist: qiskit>=2.2.1
26
+ Requires-Dist: qiskit-aer>=0.17.2
27
+ Requires-Dist: qiskit-ibm-runtime>=0.42.0
28
+ Requires-Dist: scikit-learn>=1.7.2
29
+ Requires-Dist: scipy>=1.16.2
23
30
  Requires-Dist: tabulate>=0.9.0
24
- Dynamic: author
25
- Dynamic: author-email
26
- Dynamic: classifier
27
- Dynamic: description
28
- Dynamic: description-content-type
29
- Dynamic: home-page
30
- Dynamic: license
31
+ Provides-Extra: examples
32
+ Requires-Dist: qiskit_machine_learning>=0.8.4; extra == "examples"
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest>=8; extra == "test"
35
+ Provides-Extra: dev
36
+ Requires-Dist: build>=1; extra == "dev"
37
+ Requires-Dist: twine>=5; extra == "dev"
38
+ Requires-Dist: pytest>=8; extra == "dev"
31
39
  Dynamic: license-file
32
- Dynamic: project-url
33
- Dynamic: requires-dist
34
- Dynamic: requires-python
35
- Dynamic: summary
36
40
 
37
41
  # hdlib
38
42
 
39
43
  Hyperdimensional Computing Library for building Vector-Symbolic Architectures in Python 3.
40
44
 
41
- ![Conda](https://img.shields.io/conda/dn/conda-forge/hdlib?label=hdlib%20on%20Conda)
45
+ ![Conda](https://img.shields.io/conda/dn/conda-forge/hdlib?label=hdlib%20in%20Conda)
42
46
  [![DOI](https://joss.theoj.org/papers/10.21105/joss.05704/status.svg)](https://doi.org/10.21105/joss.05704)
43
47
  [![DOI](https://zenodo.org/badge/485488487.svg)](https://doi.org/10.5281/zenodo.7996502)
44
48
 
@@ -67,6 +71,14 @@ Here is the table of content:
67
71
  - [Clustering](https://github.com/cumbof/hdlib/wiki/Examples#clustering)
68
72
  - [Support and contributions](https://github.com/cumbof/hdlib/wiki/Support-and-contributions)
69
73
 
74
+ ## Agent Skills
75
+
76
+ Want to use `hdlib` with an LLM coding assistant? The [**hdlib-skills**](https://github.com/cumbof/hdlib-skills) repository provides a collection of [Agent Skills](https://github.com/cumbof/hdlib-skills) that teach LLM agents how to use the library effectively.
77
+
78
+ The skills cover foundational concepts (vectors, space, arithmetic, and distance operations), machine learning models (classification, clustering, regression, graph encoding, and feature selection), quantum hyperdimensional computing, and common usage patterns (analogical reasoning, data encoding, and troubleshooting).
79
+
80
+ They are compatible with any tool that supports the Agent Skills standard. See the [hdlib-skills](https://github.com/cumbof/hdlib-skills) repository for installation and usage instructions.
81
+
70
82
  ## Credits
71
83
 
72
84
  Please credit our work in your manuscript by citing:
@@ -82,6 +94,16 @@ Please credit our work in your manuscript by citing:
82
94
  year = {2023},
83
95
  doi = {10.21105/joss.05704}
84
96
  }
97
+
98
+ @misc{cumbo2026hdlib,
99
+ title = {hdlib 2.0: Extending Machine Learning Capabilities of Vector-Symbolic Architectures},
100
+ author = {Fabio Cumbo and Kabir Dhillon and Daniel Blankenberg},
101
+ year = {2026},
102
+ eprint = {2601.02509},
103
+ archivePrefix = {arXiv},
104
+ primaryClass = {cs.LG},
105
+ url = {https://arxiv.org/abs/2601.02509}
106
+ }
85
107
  ```
86
108
 
87
109
  ## Other publications
@@ -96,7 +118,13 @@ Please credit our work in your manuscript by citing:
96
118
  >
97
119
  > Cumbo et al., (2025). Hyperdimensional computing in biomedical sciences: a brief review. _PeerJ Computer Science_, 11, e2885. https://doi.org/10.7717/peerj-cs.2885
98
120
  >
99
- > Cumbo et al., (2025). A novel Vector-Symbolic Architecture for graph encoding and its application to viral pangenome-based species classification. _bioRxiv_, 2025-09. https://doi.org/10.1101/2025.09.08.674958
121
+ > Cumbo et al., (2026). A novel Vector-Symbolic Architecture for graph encoding and its application to viral pangenome-based species classification. _BioData Mining_, 2026-05. https://doi.org/10.1186/s13040-026-00561-1
122
+ >
123
+ > Cumbo et al., (2026). Quantum Hyperdimensional Computing: a foundational paradigm for quantum neuromorphic architectures. _npj Unconventional Computing_, 3(1), 21. https://doi.org/10.1038/s44335-026-00064-6
124
+ >
125
+ > Cumbo et al., (2026). Designing vector-symbolic architectures for biomedical applications: ten tips and common pitfalls. _PeerJ Computer Science_, 12, e3682. https://doi.org/10.7717/peerj-cs.3682
126
+ >
127
+ > Cumbo et al., (2026). Predicting the toxicity of chemical compounds via Hyperdimensional Computing. _Molecular Informatics_, 45(9), e70052. https://doi.org/10.1002/minf.70052
100
128
 
101
129
  ## Support and contributions
102
130
 
@@ -1,44 +1,8 @@
1
- Metadata-Version: 2.4
2
- Name: hdlib
3
- Version: 2.0.0
4
- Summary: Hyperdimensional Computing Library for building Vector Symbolic Architectures in Python
5
- Home-page: http://github.com/cumbof/hdlib
6
- Author: Fabio Cumbo
7
- Author-email: fabio.cumbo@gmail.com
8
- License: MIT
9
- Project-URL: Issues, https://github.com/cumbof/hdlib/issues
10
- Project-URL: Source, https://github.com/cumbof/hdlib
11
- Project-URL: Wiki, https://github.com/cumbof/hdlib/wiki
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Intended Audience :: Information Technology
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: License :: OSI Approved :: MIT License
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Topic :: Scientific/Engineering
18
- Requires-Python: >=3
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: numpy>=2.2.5
22
- Requires-Dist: scikit-learn>=1.6.1
23
- Requires-Dist: tabulate>=0.9.0
24
- Dynamic: author
25
- Dynamic: author-email
26
- Dynamic: classifier
27
- Dynamic: description
28
- Dynamic: description-content-type
29
- Dynamic: home-page
30
- Dynamic: license
31
- Dynamic: license-file
32
- Dynamic: project-url
33
- Dynamic: requires-dist
34
- Dynamic: requires-python
35
- Dynamic: summary
36
-
37
1
  # hdlib
38
2
 
39
3
  Hyperdimensional Computing Library for building Vector-Symbolic Architectures in Python 3.
40
4
 
41
- ![Conda](https://img.shields.io/conda/dn/conda-forge/hdlib?label=hdlib%20on%20Conda)
5
+ ![Conda](https://img.shields.io/conda/dn/conda-forge/hdlib?label=hdlib%20in%20Conda)
42
6
  [![DOI](https://joss.theoj.org/papers/10.21105/joss.05704/status.svg)](https://doi.org/10.21105/joss.05704)
43
7
  [![DOI](https://zenodo.org/badge/485488487.svg)](https://doi.org/10.5281/zenodo.7996502)
44
8
 
@@ -67,6 +31,14 @@ Here is the table of content:
67
31
  - [Clustering](https://github.com/cumbof/hdlib/wiki/Examples#clustering)
68
32
  - [Support and contributions](https://github.com/cumbof/hdlib/wiki/Support-and-contributions)
69
33
 
34
+ ## Agent Skills
35
+
36
+ Want to use `hdlib` with an LLM coding assistant? The [**hdlib-skills**](https://github.com/cumbof/hdlib-skills) repository provides a collection of [Agent Skills](https://github.com/cumbof/hdlib-skills) that teach LLM agents how to use the library effectively.
37
+
38
+ The skills cover foundational concepts (vectors, space, arithmetic, and distance operations), machine learning models (classification, clustering, regression, graph encoding, and feature selection), quantum hyperdimensional computing, and common usage patterns (analogical reasoning, data encoding, and troubleshooting).
39
+
40
+ They are compatible with any tool that supports the Agent Skills standard. See the [hdlib-skills](https://github.com/cumbof/hdlib-skills) repository for installation and usage instructions.
41
+
70
42
  ## Credits
71
43
 
72
44
  Please credit our work in your manuscript by citing:
@@ -82,6 +54,16 @@ Please credit our work in your manuscript by citing:
82
54
  year = {2023},
83
55
  doi = {10.21105/joss.05704}
84
56
  }
57
+
58
+ @misc{cumbo2026hdlib,
59
+ title = {hdlib 2.0: Extending Machine Learning Capabilities of Vector-Symbolic Architectures},
60
+ author = {Fabio Cumbo and Kabir Dhillon and Daniel Blankenberg},
61
+ year = {2026},
62
+ eprint = {2601.02509},
63
+ archivePrefix = {arXiv},
64
+ primaryClass = {cs.LG},
65
+ url = {https://arxiv.org/abs/2601.02509}
66
+ }
85
67
  ```
86
68
 
87
69
  ## Other publications
@@ -96,7 +78,13 @@ Please credit our work in your manuscript by citing:
96
78
  >
97
79
  > Cumbo et al., (2025). Hyperdimensional computing in biomedical sciences: a brief review. _PeerJ Computer Science_, 11, e2885. https://doi.org/10.7717/peerj-cs.2885
98
80
  >
99
- > Cumbo et al., (2025). A novel Vector-Symbolic Architecture for graph encoding and its application to viral pangenome-based species classification. _bioRxiv_, 2025-09. https://doi.org/10.1101/2025.09.08.674958
81
+ > Cumbo et al., (2026). A novel Vector-Symbolic Architecture for graph encoding and its application to viral pangenome-based species classification. _BioData Mining_, 2026-05. https://doi.org/10.1186/s13040-026-00561-1
82
+ >
83
+ > Cumbo et al., (2026). Quantum Hyperdimensional Computing: a foundational paradigm for quantum neuromorphic architectures. _npj Unconventional Computing_, 3(1), 21. https://doi.org/10.1038/s44335-026-00064-6
84
+ >
85
+ > Cumbo et al., (2026). Designing vector-symbolic architectures for biomedical applications: ten tips and common pitfalls. _PeerJ Computer Science_, 12, e3682. https://doi.org/10.7717/peerj-cs.3682
86
+ >
87
+ > Cumbo et al., (2026). Predicting the toxicity of chemical compounds via Hyperdimensional Computing. _Molecular Informatics_, 45(9), e70052. https://doi.org/10.1002/minf.70052
100
88
 
101
89
  ## Support and contributions
102
90
 
@@ -3,10 +3,11 @@
3
3
 
4
4
  __author__ = ("Fabio Cumbo (fabio.cumbo@gmail.com)")
5
5
 
6
- __version__ = "1.1.0"
7
- __date__ = "Jul 16, 2023"
6
+ __version__ = "1.1.1"
7
+ __date__ = "Nov 7, 2025"
8
8
 
9
9
  import argparse as ap
10
+ import contextlib
10
11
  import errno
11
12
  import os
12
13
  import statistics
@@ -102,6 +103,12 @@ def read_params():
102
103
  default=1,
103
104
  help="Make it parallel when possible",
104
105
  )
106
+ p.add_argument(
107
+ "--output",
108
+ type=os.path.abspath,
109
+ default=None,
110
+ help="Path to the output file (full path). If not specified, output is printed to stdout",
111
+ )
105
112
  p.add_argument(
106
113
  "-v",
107
114
  "--version",
@@ -388,7 +395,7 @@ def chopin2():
388
395
 
389
396
  print("Class labels: {}\n".format(class_labels))
390
397
 
391
- for fold, (y_indices, y_pred, retrainings, error_rate, _) in enumerate(predictions):
398
+ for fold, (y_indices, y_pred, _, retrainings, error_rate, _) in enumerate(predictions):
392
399
  # Produce the confusion matrix for each fold
393
400
  print("Fold {} ({} retrainings)".format(fold + 1, retrainings))
394
401
  retraining_iterations.append(retrainings)
@@ -447,9 +454,20 @@ def chopin2():
447
454
 
448
455
 
449
456
  if __name__ == "__main__":
450
- t0 = time.time()
457
+ # Pre-parse --output only so redirection is set up before full argument parsing
458
+ _pre = ap.ArgumentParser(add_help=False)
459
+ _pre.add_argument("--output", default=None)
460
+ _output_arg, _ = _pre.parse_known_args()
451
461
 
452
- chopin2()
462
+ t0 = time.time()
453
463
 
454
- t1 = time.time()
455
- print("Total elapsed time: {}s".format(int(t1 - t0)))
464
+ if _output_arg.output:
465
+ with open(_output_arg.output, "w") as _outfile, contextlib.redirect_stdout(_outfile):
466
+ chopin2()
467
+ t1 = time.time()
468
+ print("Total elapsed time: {}s".format(int(t1 - t0)))
469
+ print("Output written to: {}".format(_output_arg.output))
470
+ else:
471
+ chopin2()
472
+ t1 = time.time()
473
+ print("Total elapsed time: {}s".format(int(t1 - t0)))
@@ -12,5 +12,5 @@ modules and how to use the library."""
12
12
 
13
13
  __author__ = ("Fabio Cumbo (fabio.cumbo@gmail.com)")
14
14
 
15
- __version__ = "2.0.0"
16
- __date__ = "Sep 23, 2025"
15
+ __version__ = "2.1.0"
16
+ __date__ = "Mar 10, 2026"
@@ -1,4 +1,4 @@
1
- """Implementation of the arithmetic operators.
1
+ """Implementation of the MAP arithmetic operators.
2
2
 
3
3
  This library also provides the same set of arithmetic functions also accessible as _Vector_'s class methods.
4
4
  However, while the result of calling these functions from a _Vector_ object woule be applied in place,
@@ -71,7 +71,13 @@ def bind(vector1: Vector, vector2: Vector) -> Vector:
71
71
  if vector1.vtype != vector2.vtype:
72
72
  raise Exception("Vector types are not compatible")
73
73
 
74
- vector = vector1.vector * vector2.vector
74
+ if vector1.vtype == "bipolar":
75
+ # Element-wise multiplication
76
+ vector = vector1.vector * vector2.vector
77
+
78
+ elif vector1.vtype == "binary":
79
+ # Element-wise XOR
80
+ vector = vector1.vector.astype(int) ^ vector2.vector.astype(int)
75
81
 
76
82
  tags = set(vector1.tags).union(set(vector2.tags))
77
83
 
@@ -140,7 +146,13 @@ def bundle(vector1: Vector, vector2: Vector) -> Vector:
140
146
  if vector1.vtype != vector2.vtype:
141
147
  raise Exception("Vector types are not compatible")
142
148
 
143
- vector = vector1.vector + vector2.vector
149
+ if vector1.vtype == "bipolar":
150
+ # Element-wise addition
151
+ vector = vector1.vector + vector2.vector
152
+
153
+ elif vector1.vtype == "binary":
154
+ # Element-wise majority vote
155
+ vector = ((vector1.vector + vector2.vector) > 1).astype(int)
144
156
 
145
157
  tags = set(vector1.tags).union(set(vector2.tags))
146
158
 
@@ -165,7 +177,8 @@ def subtraction(vector1: Vector, vector2: Vector) -> Vector:
165
177
  Raises
166
178
  ------
167
179
  Exception
168
- If vectors have different sizes or different vector types.
180
+ - If vectors have different sizes or different vector types;
181
+ - If vectors type is binary.
169
182
 
170
183
  Examples
171
184
  --------
@@ -201,7 +214,12 @@ def subtraction(vector1: Vector, vector2: Vector) -> Vector:
201
214
  if vector1.vtype != vector2.vtype:
202
215
  raise Exception("Vector types are not compatible")
203
216
 
204
- vector = vector1.vector - vector2.vector
217
+ if vector1.vtype == "bipolar":
218
+ # Element-wise subtraction
219
+ vector = vector1.vector - vector2.vector
220
+
221
+ elif vector1.vtype == "binary":
222
+ raise Exception("Subtraction is not available for binary vectors")
205
223
 
206
224
  return Vector(size=vector1.size, vector=vector, tags=vector1.tags, vtype=vector1.vtype, seed=vector1.seed)
207
225