ruvector-cluster 0.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.
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ dist/
4
+ .pytest_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 rUv
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: ruvector-cluster
3
+ Version: 0.1.0
4
+ Summary: Embedding clustering for Python using RuVector native Rust libraries
5
+ Project-URL: Homepage, https://github.com/ruvnet/RuVector
6
+ Project-URL: Documentation, https://github.com/ruvnet/RuVector/tree/main/python/portfolio/ruvector-cluster
7
+ Project-URL: Repository, https://github.com/ruvnet/RuVector
8
+ Project-URL: Issues, https://github.com/ruvnet/RuVector/issues
9
+ Project-URL: Changelog, https://github.com/ruvnet/RuVector/blob/main/python/portfolio/CHANGELOG.md
10
+ Author: RuVector Team
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: cluster,embeddings,rag,rust,ruvector
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Rust
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: numpy>=1.21
20
+ Requires-Dist: ruvector==0.1.2
21
+ Description-Content-Type: text/markdown
22
+
23
+ # ruvector-cluster: Embedding clustering in Python
24
+
25
+ ![Embedding clustering: Python API to PyO3 to Rust](https://raw.githubusercontent.com/ruvnet/RuVector/main/docs/python-portfolio/cluster.svg)
26
+
27
+ ## What is ruvector-cluster?
28
+
29
+ ruvector-cluster provides embedding clustering through `ruvector-cluster-rag` in the RuVector Rust library family. It adds a focused Python API over the existing `ruvector` PyO3 runtime. It does not ship a separate native engine or reduce the shared runtime's installation size.
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pip install ruvector-cluster==0.1.0
35
+ ```
36
+
37
+ Release candidate: this command works only after publication. From a checkout, install `ruvector==0.1.2` and then `pip install ./python/portfolio/ruvector-cluster`. Python 3.10 or newer; native platform support follows the shared runtime wheels.
38
+
39
+ ## Quick start
40
+
41
+ ```python
42
+ from ruvector_cluster import cluster
43
+ result = cluster([[1, 0], [1.1, 0], [10, 10], [10.1, 10]], 2)
44
+ assert result.labels[0] == result.labels[1]
45
+ assert result.labels[2] == result.labels[3]
46
+ assert result.labels[0] != result.labels[2]
47
+ assert result.sizes.sum() == 4
48
+ ```
49
+
50
+ ## API and limitations
51
+
52
+ Public exports: `ClusterResult, cluster`. Lloyd clustering for numeric embeddings. No embedding model download or network service. Quality and latency depend on your data; no universal speedup or recall claim.
53
+
54
+ Input conversion can copy arrays. Reuse contiguous float32 arrays for repeated operations. No service, telemetry or credentials are added by this package. Apply application memory and request limits for untrusted data.
55
+
56
+ ## How does it relate to RuVector?
57
+
58
+ The algorithm executes through the existing Rust PyO3 binding, pinned to `ruvector==0.1.2`. Python implements convenience conversion and result formatting. For vector search use `pip install ruvector`; for other capabilities see the [Python portfolio](https://github.com/ruvnet/RuVector/tree/main/python/portfolio).
59
+
60
+ ## Verification and security
61
+
62
+ CI tests built wheels against a native runtime compiled from this repository, checks sdists and README rendering, audits resolved dependencies and publishes through PyPI Trusted Publishing. Native vulnerability scanning is a separate required gate. See [security scope](https://github.com/ruvnet/RuVector/blob/main/python/portfolio/SECURITY.md).
@@ -0,0 +1,40 @@
1
+ # ruvector-cluster: Embedding clustering in Python
2
+
3
+ ![Embedding clustering: Python API to PyO3 to Rust](https://raw.githubusercontent.com/ruvnet/RuVector/main/docs/python-portfolio/cluster.svg)
4
+
5
+ ## What is ruvector-cluster?
6
+
7
+ ruvector-cluster provides embedding clustering through `ruvector-cluster-rag` in the RuVector Rust library family. It adds a focused Python API over the existing `ruvector` PyO3 runtime. It does not ship a separate native engine or reduce the shared runtime's installation size.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install ruvector-cluster==0.1.0
13
+ ```
14
+
15
+ Release candidate: this command works only after publication. From a checkout, install `ruvector==0.1.2` and then `pip install ./python/portfolio/ruvector-cluster`. Python 3.10 or newer; native platform support follows the shared runtime wheels.
16
+
17
+ ## Quick start
18
+
19
+ ```python
20
+ from ruvector_cluster import cluster
21
+ result = cluster([[1, 0], [1.1, 0], [10, 10], [10.1, 10]], 2)
22
+ assert result.labels[0] == result.labels[1]
23
+ assert result.labels[2] == result.labels[3]
24
+ assert result.labels[0] != result.labels[2]
25
+ assert result.sizes.sum() == 4
26
+ ```
27
+
28
+ ## API and limitations
29
+
30
+ Public exports: `ClusterResult, cluster`. Lloyd clustering for numeric embeddings. No embedding model download or network service. Quality and latency depend on your data; no universal speedup or recall claim.
31
+
32
+ Input conversion can copy arrays. Reuse contiguous float32 arrays for repeated operations. No service, telemetry or credentials are added by this package. Apply application memory and request limits for untrusted data.
33
+
34
+ ## How does it relate to RuVector?
35
+
36
+ The algorithm executes through the existing Rust PyO3 binding, pinned to `ruvector==0.1.2`. Python implements convenience conversion and result formatting. For vector search use `pip install ruvector`; for other capabilities see the [Python portfolio](https://github.com/ruvnet/RuVector/tree/main/python/portfolio).
37
+
38
+ ## Verification and security
39
+
40
+ CI tests built wheels against a native runtime compiled from this repository, checks sdists and README rendering, audits resolved dependencies and publishes through PyPI Trusted Publishing. Native vulnerability scanning is a separate required gate. See [security scope](https://github.com/ruvnet/RuVector/blob/main/python/portfolio/SECURITY.md).
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["hatchling==1.27.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ruvector-cluster"
7
+ version = "0.1.0"
8
+ description = "Embedding clustering for Python using RuVector native Rust libraries"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [{name = "RuVector Team"}]
13
+ dependencies = ["ruvector==0.1.2", "numpy>=1.21"]
14
+ keywords = ["ruvector", "rust", "cluster", "embeddings", "rag"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Rust",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/ruvnet/RuVector"
24
+ Documentation = "https://github.com/ruvnet/RuVector/tree/main/python/portfolio/ruvector-cluster"
25
+ Repository = "https://github.com/ruvnet/RuVector"
26
+ Issues = "https://github.com/ruvnet/RuVector/issues"
27
+ Changelog = "https://github.com/ruvnet/RuVector/blob/main/python/portfolio/CHANGELOG.md"
28
+
29
+ [tool.hatch.build.targets.wheel]
30
+ packages = ["src/ruvector_cluster"]
31
+
32
+ [tool.hatch.build.targets.sdist]
33
+ include = ["src", "README.md", "LICENSE", "pyproject.toml"]
@@ -0,0 +1,31 @@
1
+ """Embedding clustering backed by RuVector Rust bindings."""
2
+ from dataclasses import dataclass
3
+ import numpy as np
4
+ from numpy.typing import NDArray
5
+ from ruvector import kmeans
6
+
7
+ __all__ = ["ClusterResult", "cluster"]
8
+
9
+ @dataclass(frozen=True)
10
+ class ClusterResult:
11
+ labels: NDArray[np.int64]
12
+ centroids: NDArray[np.float32]
13
+ cohesion: NDArray[np.float32]
14
+ sizes: NDArray[np.int64]
15
+
16
+ def cluster(vectors, k: int, *, iterations: int = 20) -> ClusterResult:
17
+ """Cluster embeddings with the native Rust Lloyd implementation.
18
+
19
+ Converts numeric array inputs to contiguous float32. Cohesion is cosine
20
+ similarity, not Euclidean inertia. Labels are not stable identifiers.
21
+ """
22
+ if isinstance(k, bool) or not isinstance(k, int) or k < 1:
23
+ raise ValueError("k must be a positive integer")
24
+ if isinstance(iterations, bool) or not isinstance(iterations, int) or not 1 <= iterations <= 10000:
25
+ raise ValueError("iterations must be between 1 and 10000")
26
+ data = np.ascontiguousarray(vectors, dtype=np.float32)
27
+ if data.ndim != 2 or not all(data.shape) or k > data.shape[0]:
28
+ raise ValueError("vectors must be nonempty rows by dimensions and k <= rows")
29
+ if not np.isfinite(data).all():
30
+ raise ValueError("vectors must be finite")
31
+ return ClusterResult(*kmeans(data, k, iters=iterations))
File without changes