Skip to content

Commit 175b160

Browse files
committed
Add failing test based on the bug report in 7717
1 parent 852c06e commit 175b160

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from typing import TYPE_CHECKING
2+
3+
import numpy as np
4+
5+
from qcodes.dataset import Measurement
6+
from qcodes.parameters import ManualParameter, ParameterWithSetpoints
7+
from qcodes.validators import Arrays
8+
9+
if TYPE_CHECKING:
10+
from qcodes.dataset.experiment_container import Experiment
11+
12+
13+
def test_parameter_with_setpoints_has_control(experiment: "Experiment"):
14+
class MySp(ParameterWithSetpoints):
15+
def unpack_self(self, value):
16+
res = super().unpack_self(value)
17+
res.append((p1, p1()))
18+
return res
19+
20+
mp = ManualParameter("mp", vals=Arrays(shape=(10,)), initial_value=np.arange(10))
21+
p1 = ParameterWithSetpoints(
22+
"p1", vals=Arrays(shape=(10,)), setpoints=(mp,), set_cmd=None
23+
)
24+
p2 = MySp("p2", vals=Arrays(shape=(10,)), setpoints=(mp,), set_cmd=None)
25+
p2.has_control_of.add(p1)
26+
27+
p1(np.linspace(-1, 1, 10))
28+
p2(np.random.randn(10))
29+
30+
meas = Measurement()
31+
meas.register_parameter(p2)
32+
with meas.run() as ds:
33+
ds.add_result((p2, p2()))
34+
35+
xds = ds.dataset.to_xarray_dataset() # does not unravel to grid
36+
37+
assert (
38+
list(xds.sizes.keys()) == ["mp"]
39+
) # without p1 this correctly has mp as the only dim, with p1 this is turned into a generic 'index' dim

0 commit comments

Comments
 (0)