Skip to content

Commit 0e8ec39

Browse files
committed
Fixed tests [skip ci]
1 parent b0b1b61 commit 0e8ec39

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pgvector/bit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ def __init__(self, value: bytes | str | list[bool] | np.ndarray[tuple[int], np.d
99
length = 8 * len(value)
1010
data = value
1111
else:
12+
import numpy as np
13+
1214
if isinstance(value, str):
1315
value = [v != '0' for v in value]
1416
else:
15-
import numpy as np
16-
1717
value = np.asarray(value)
1818

1919
# for mypy
@@ -52,6 +52,7 @@ def to_list(self) -> list[bool]:
5252
return self.to_numpy().tolist()
5353

5454
def to_numpy(self) -> np.ndarray[tuple[int], np.dtype[np.bool]]:
55+
import numpy as np
5556
return np.unpackbits(np.frombuffer(self._value[4:], dtype=np.uint8), count=self._length()).astype(bool)
5657

5758
def to_text(self) -> str:

0 commit comments

Comments
 (0)