@@ -118,13 +118,15 @@ def circuit():
118
118
@pytest .mark .parametrize (
119
119
"cases" ,
120
120
[
121
- [[1 , 0 ], [0.9165164490394898 , 0.08348355096051052 , 0.0 , 0.0 ]],
121
+ [[0 , 1 ], [1 , 0 ]],
122
+ [[1 , 0 ], [0 , 1 ]],
122
123
],
123
124
)
124
- def test_fail_probs_tape_unordered_wires (self , cases , tol , dev ):
125
- """Test probs with a circuit on wires=[0]"""
125
+ def test_fail_probs_tape_unordered_wires (self , cases , tol ):
126
+ """Test probs with a circuit on wires=[0] fails for out-of-order wires passed to probs. """
126
127
127
128
x , y , z = [0.5 , 0.3 , - 0.7 ]
129
+ dev = qml .device ("lightning.qubit" , wires = cases [1 ])
128
130
129
131
@qml .qnode (dev )
130
132
def circuit ():
@@ -137,7 +139,29 @@ def circuit():
137
139
RuntimeError ,
138
140
match = "Lightning does not currently support out-of-order indices for probabilities" ,
139
141
):
140
- assert np .allclose (circuit (), cases [1 ], atol = tol , rtol = 0 )
142
+ _ = circuit ()
143
+
144
+ @pytest .mark .parametrize (
145
+ "cases" ,
146
+ [
147
+ [[1 , 0 ], [1 , 0 ], [0.9165164490394898 , 0.08348355096051052 , 0.0 , 0.0 ]],
148
+ [[2 , 0 ], [2 , 0 , 1 ], [0.9165164490394898 , 0.08348355096051052 , 0.0 , 0.0 ]],
149
+ ],
150
+ )
151
+ def test_probs_matching_device_wire_order (self , cases , tol ):
152
+ """Test probs with a circuit on wires=[0] passes if wires are sorted wrt device wires."""
153
+
154
+ x , y , z = [0.5 , 0.3 , - 0.7 ]
155
+ dev = qml .device ("lightning.qubit" , wires = cases [1 ])
156
+
157
+ @qml .qnode (dev )
158
+ def circuit ():
159
+ qml .RX (0.4 , wires = [0 ])
160
+ qml .Rot (x , y , z , wires = [0 ])
161
+ qml .RY (- 0.2 , wires = [0 ])
162
+ return qml .probs (wires = cases [0 ])
163
+
164
+ assert np .allclose (circuit (), cases [2 ], atol = tol , rtol = 0 )
141
165
142
166
@pytest .mark .parametrize (
143
167
"cases" ,
0 commit comments