Skip to content

Commit e86d7c4

Browse files
committed
Improved type hints [skip ci]
1 parent 0178236 commit e86d7c4

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

pgvector/bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __eq__(self, other: object) -> bool:
4444
def to_list(self) -> list[bool]:
4545
return self.to_numpy().tolist()
4646

47-
def to_numpy(self) -> np.ndarray:
47+
def to_numpy(self) -> np.ndarray[tuple[int], np.dtype[np.bool]]:
4848
return np.unpackbits(np.frombuffer(self._data, dtype=np.uint8), count=self._len).astype(bool)
4949

5050
def to_text(self) -> str:

pgvector/halfvec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def dimensions(self) -> int:
3232
def to_list(self) -> list[float]:
3333
return self._value.tolist()
3434

35-
def to_numpy(self) -> np.ndarray:
35+
def to_numpy(self) -> np.ndarray[tuple[int], np.dtype[np.float16]]:
36+
# TODO return native endian
3637
return self._value
3738

3839
def to_text(self) -> str:

pgvector/vector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def dimensions(self) -> int:
3232
def to_list(self) -> list[float]:
3333
return self._value.tolist()
3434

35-
def to_numpy(self) -> np.ndarray:
35+
def to_numpy(self) -> np.ndarray[tuple[int], np.dtype[np.float32]]:
36+
# TODO return native endian
3637
return self._value
3738

3839
def to_text(self) -> str:

0 commit comments

Comments
 (0)