Skip to content

Commit 900cbb3

Browse files
committed
Improved error message
1 parent ac1a543 commit 900cbb3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pgvector/bit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, value):
1515
else:
1616
value = np.asarray(value)
1717
if value.dtype != np.bool:
18-
raise ValueError('expected dtype to be bool')
18+
raise ValueError('expected all elements to be boolean')
1919

2020
if value.ndim != 1:
2121
raise ValueError('expected ndim to be 1')

tests/test_bit.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ class TestBit:
77
def test_list(self):
88
assert Bit([True, False, True]).to_list() == [True, False, True]
99

10+
def test_list_none(self):
11+
with pytest.raises(ValueError) as error:
12+
Bit([True, None, True])
13+
assert str(error.value) == 'expected all elements to be boolean'
14+
1015
def test_list_int(self):
1116
with pytest.raises(ValueError) as error:
1217
Bit([254, 7, 0])
13-
assert str(error.value) == 'expected dtype to be bool'
18+
assert str(error.value) == 'expected all elements to be boolean'
1419

1520
def test_tuple(self):
1621
assert Bit((True, False, True)).to_list() == [True, False, True]

0 commit comments

Comments
 (0)