Skip to content

Commit f74d85c

Browse files
committed
Added tests for to_numpy [skip ci]
1 parent d3e376e commit f74d85c

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

tests/test_half_vector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ def test_equality(self):
3939
def test_dimensions(self):
4040
assert HalfVector([1, 2, 3]).dimensions() == 3
4141

42+
def test_to_numpy_readonly(self):
43+
arr = HalfVector([1, 2, 3]).to_numpy()
44+
with pytest.raises(ValueError) as error:
45+
arr[0] = 4
46+
assert str(error.value) == 'assignment destination is read-only'
47+
4248
def test_from_text(self):
4349
vec = HalfVector.from_text('[1.5,2,3]')
4450
assert vec.to_list() == [1.5, 2, 3]

tests/test_vector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ def test_equality(self):
3939
def test_dimensions(self):
4040
assert Vector([1, 2, 3]).dimensions() == 3
4141

42+
def test_to_numpy_readonly(self):
43+
arr = Vector([1, 2, 3]).to_numpy()
44+
with pytest.raises(ValueError) as error:
45+
arr[0] = 4
46+
assert str(error.value) == 'assignment destination is read-only'
47+
4248
def test_from_text(self):
4349
vec = Vector.from_text('[1.5,2,3]')
4450
assert vec.to_list() == [1.5, 2, 3]

0 commit comments

Comments
 (0)