weft-kernel 0.1.0__py3-none-any.whl

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,28 @@
1
+ """An embedding: an ordered, non-empty tuple of components.
2
+
3
+ Settled in G4: persistence accepts a vector already computed elsewhere; it
4
+ is never computed from content directly. `Node.embedding` is this type, or
5
+ `None` before an embedding has been computed. Excluded from a node's
6
+ content-addressed identity (`node.py`) because it is derived from content
7
+ and would otherwise bind an id to whichever model produced it.
8
+ """
9
+
10
+ from pydantic import BaseModel, ConfigDict, model_validator
11
+
12
+
13
+ class Vector(BaseModel):
14
+ """An embedding: an ordered, non-empty tuple of components."""
15
+
16
+ model_config = ConfigDict(frozen=True, extra="forbid")
17
+
18
+ values: tuple[float, ...]
19
+
20
+ @model_validator(mode="after")
21
+ def _non_empty(self) -> "Vector":
22
+ if not self.values:
23
+ raise ValueError("Vector must carry at least one dimension")
24
+ return self
25
+
26
+ @property
27
+ def dimension(self) -> int:
28
+ return len(self.values)