Skip to content

Commit 33293bf

Browse files
committed
Added more tests for NumPy arrays [skip ci]
1 parent 6c1238c commit 33293bf

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

tests/test_half_vector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def test_ndarray(self) -> None:
4141
assert HalfVector(arr.astype('>f2')).to_list() == [1, 2, 3]
4242
assert HalfVector(arr.astype('>f2')).to_binary() == HalfVector([1, 2, 3]).to_binary()
4343

44+
with pytest.raises(ValueError) as error:
45+
HalfVector(np.array(['one', 'two', 'three']))
46+
assert 'could not convert string to float' in str(error.value)
47+
4448
def test_int(self) -> None:
4549
with pytest.raises(ValueError) as error:
4650
HalfVector(1) # type: ignore

tests/test_vector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def test_ndarray(self) -> None:
4141
assert Vector(arr.astype('>f4')).to_list() == [1, 2, 3]
4242
assert Vector(arr.astype('>f4')).to_binary() == Vector([1, 2, 3]).to_binary()
4343

44+
with pytest.raises(ValueError) as error:
45+
Vector(np.array(['one', 'two', 'three']))
46+
assert 'could not convert string to float' in str(error.value)
47+
4448
def test_int(self) -> None:
4549
with pytest.raises(ValueError) as error:
4650
Vector(1) # type: ignore

0 commit comments

Comments
 (0)