Skip to content

Commit c4c46ab

Browse files
committed
Removed support for tuples from Vector, HalfVector, and Bit constructors [skip ci]
1 parent b028150 commit c4c46ab

6 files changed

Lines changed: 3 additions & 12 deletions

File tree

pgvector/bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Bit:
8-
def __init__(self, value: bytes | str | list[bool] | tuple[bool, ...] | np.ndarray) -> None:
8+
def __init__(self, value: bytes | str | list[bool] | np.ndarray) -> None:
99
if isinstance(value, bytes):
1010
self._len = 8 * len(value)
1111
self._data = value

pgvector/halfvec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class HalfVector:
7-
def __init__(self, value: list[float] | tuple[float, ...] | np.ndarray) -> None:
7+
def __init__(self, value: list[float] | np.ndarray) -> None:
88
# asarray still copies if same dtype
99
if not isinstance(value, np.ndarray) or value.dtype != '>f2':
1010
value = np.asarray(value, dtype='>f2')

pgvector/vector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Vector:
7-
def __init__(self, value: list[float] | tuple[float, ...] | np.ndarray) -> None:
7+
def __init__(self, value: list[float] | np.ndarray) -> None:
88
# asarray still copies if same dtype
99
if not isinstance(value, np.ndarray) or value.dtype != '>f4':
1010
value = np.asarray(value, dtype='>f4')

tests/test_bit.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ def test_list_int(self):
1515
with pytest.warns(UserWarning, match='expected elements to be boolean'):
1616
assert Bit([254, 7, 0]).to_text() == '110' # ty: ignore[invalid-argument-type]
1717

18-
def test_tuple(self):
19-
assert Bit((True, False, True)).to_list() == [True, False, True]
20-
2118
def test_str(self):
2219
assert Bit('101').to_list() == [True, False, True]
2320

tests/test_half_vector.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ def test_list_str(self):
1212
with pytest.raises(ValueError, match='could not convert string to float'):
1313
HalfVector([1, 'two', 3]) # ty: ignore[invalid-argument-type]
1414

15-
def test_tuple(self):
16-
assert HalfVector((1, 2, 3)).to_list() == [1, 2, 3]
17-
1815
def test_ndarray(self):
1916
arr = np.array([1, 2, 3])
2017
assert HalfVector(arr).to_list() == [1, 2, 3]

tests/test_vector.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ def test_list_str(self):
1212
with pytest.raises(ValueError, match='could not convert string to float'):
1313
Vector([1, 'two', 3]) # ty: ignore[invalid-argument-type]
1414

15-
def test_tuple(self):
16-
assert Vector((1, 2, 3)).to_list() == [1, 2, 3]
17-
1815
def test_ndarray(self):
1916
arr = np.array([1, 2, 3])
2017
assert Vector(arr).to_list() == [1, 2, 3]

0 commit comments

Comments
 (0)