Skip to content

Commit b5987c0

Browse files
committed
Moved _from_text methods [skip ci]
1 parent eeb1b7e commit b5987c0

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

pgvector/halfvec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def from_binary(cls, value: bytes) -> HalfVector:
7979
vec._value.byteswap()
8080
return vec
8181

82+
@classmethod
83+
def _from_text(cls, value: str) -> list[float]:
84+
return [float(v) for v in value[1:-1].split(',')]
85+
8286
@classmethod
8387
def _to_db(cls, value: object) -> str | None:
8488
if value is None:
@@ -102,7 +106,3 @@ def _from_db(cls, value: str | HalfVector | None) -> list[float] | None:
102106
return value.to_list()
103107

104108
return cls._from_text(value)
105-
106-
@classmethod
107-
def _from_text(cls, value: str) -> list[float]:
108-
return [float(v) for v in value[1:-1].split(',')]

pgvector/vector.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def from_binary(cls, value: bytes) -> Vector:
7777
vec._value.byteswap()
7878
return vec
7979

80+
@classmethod
81+
def _from_text(cls, value: str) -> list[float]:
82+
return [float(v) for v in value[1:-1].split(',')]
83+
8084
@classmethod
8185
def _to_db(cls, value: object) -> str | None:
8286
if value is None:
@@ -100,7 +104,3 @@ def _from_db(cls, value: str | Vector | None) -> list[float] | None:
100104
return value.to_list()
101105

102106
return cls._from_text(value)
103-
104-
@classmethod
105-
def _from_text(cls, value: str) -> list[float]:
106-
return [float(v) for v in value[1:-1].split(',')]

0 commit comments

Comments
 (0)