@@ -69,6 +69,11 @@ def test_qty_str() -> None:
69
69
assert str (gate_time ) == "5.325 ns "
70
70
71
71
72
+ @pytest .mark .unit
73
+ def test_qty_item () -> None :
74
+ assert gate_time [0 ] == gate_time .numpy ()
75
+
76
+
72
77
@pytest .mark .unit
73
78
def test_qty_set () -> None :
74
79
gate_time .set_value (7e-9 )
@@ -98,6 +103,16 @@ def test_qty_matrix_str() -> None:
98
103
assert str (matrix ) == "0.000 1.000 1.000 0.000 "
99
104
100
105
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
+
101
116
@pytest .mark .unit
102
117
def test_qty_matrix_set () -> None :
103
118
matrix .set_value ([[1.0 , 0.0 ], [0.0 , 1.0 ]])
@@ -165,3 +180,16 @@ def get_and_set() -> None:
165
180
opt_val = a .get_opt_value ()
166
181
a .set_opt_value (opt_val )
167
182
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