Skip to content

Commit df2adbb

Browse files
committed
More coverage.
1 parent 56a6971 commit df2adbb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test_quantity.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def test_qty_str() -> None:
6969
assert str(gate_time) == "5.325 ns "
7070

7171

72+
@pytest.mark.unit
73+
def test_qty_item() -> None:
74+
assert gate_time[0] == gate_time.numpy()
75+
76+
7277
@pytest.mark.unit
7378
def test_qty_set() -> None:
7479
gate_time.set_value(7e-9)
@@ -98,6 +103,16 @@ def test_qty_matrix_str() -> None:
98103
assert str(matrix) == "0.000 1.000 1.000 0.000 "
99104

100105

106+
@pytest.mark.unit
107+
def test_qty_matrix_list() -> None:
108+
assert matrix.tolist() == [[0, 1], [1, 0]]
109+
110+
111+
@pytest.mark.unit
112+
def test_qty_matrix_item() -> None:
113+
assert matrix[0][1] == 1
114+
115+
101116
@pytest.mark.unit
102117
def test_qty_matrix_set() -> None:
103118
matrix.set_value([[1.0, 0.0], [0.0, 1.0]])
@@ -165,3 +180,16 @@ def get_and_set() -> None:
165180
opt_val = a.get_opt_value()
166181
a.set_opt_value(opt_val)
167182
np.testing.assert_allclose(a, val)
183+
184+
185+
@pytest.mark.unit
186+
def test_qty_matrix_float() -> None:
187+
with pytest.raises(NotImplementedError):
188+
float(matrix)
189+
190+
191+
@pytest.mark.unit
192+
def test_pihalf() -> None:
193+
"Don't use prefixes with pi."
194+
pihalf = Quantity(1500, unit="pi")
195+
assert str(pihalf) == "1500.0 pi "

0 commit comments

Comments
 (0)