MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _make_seed_index

Function _make_seed_index

tests/test_signal_embedding.py:14–31  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

12
13
14def _make_seed_index(tmp_path: Path):
15 dim = 384
16 rng = np.random.RandomState(42)
17 # Create cluster of similar vectors for tier 0 so KNN has enough
18 # same-label neighbors to exceed MIN_CONFIDENCE_TO_VOTE (0.30).
19 base = rng.randn(dim).astype(np.float32)
20 vecs = [base + rng.randn(dim).astype(np.float32) * 0.2 for _ in range(5)]
21 # Add a distant vector for tier 3
22 far = rng.randn(dim).astype(np.float32)
23 vecs.append(far)
24 embeddings = np.array(vecs, dtype=np.float32)
25 norms = np.linalg.norm(embeddings, axis=1, keepdims=True)
26 embeddings = embeddings / norms
27 labels = [0, 0, 0, 0, 0, 3]
28 np.save(tmp_path / "seed_embeddings.npy", embeddings)
29 with open(tmp_path / "seed_labels.json", "w") as f:
30 json.dump(labels, f)
31 return embeddings, labels
32
33
34def test_embedding_signal_with_seed_index(tmp_path):

Calls 3

openFunction · 0.85
appendMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected