microsoft / microsoft/Qcodes

ParameterWithSetpoints with DelegateParameter as setpoints

Open
#7,637 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
459
Forks
359
Avg merge
3d 6h
Merged PRs (30d)
73

Description

The following setup is disallowed by qcodes:
```py
from qcodes.validators import Arrays
from qcodes.parameters import Parameter, ParameterWithSetpoints
from qcodes.dataset import Measurement

p=Parameter('p', vals=Arrays(shape=(10,)), get_cmd=lambda : np.arange(10))
ps1 = ParameterWithSetpoints('ps1', vals=p.vals, setpoints=(p,), get_cmd=lambda : np.linspace(0, 1, 10))
ps2 = ParameterWithSetpoints('ps2', vals=p.vals, setpoints=(ps1,), get_cmd=lambda : np.random.randn(10))

meas = Measurement()
meas.register_parameter(ps2)
# ValueError: Paramspec ps1 both depends on ['p'] and is depended upon by ['ps2']
# This was caused while adding these interdependencies {ParamSpecBase('ps1', 'array', 'ps1', ''): (ParamSpecBase('p', 'array', 'p', ''),)}
```
When instead `ps2` has a `DelegateParameter` as setpoints that points to `ps1`, the measurement works (but probably shouldn't according to the current logic):
```py
from qcodes.parameters import DelegateParameter
dp = DelegateParameter('dp', source=ps1)
ps2.setpoints = (dp,)

meas = Measurement()
meas.register_parameter(ps2) # p is just forgotten about here
```
Finally, I'm wondering if the dual dependency should not indeed be *allowed*. Take a `ParameterWithSetpoints` whose setpoints are maybe some voltages that are being ramped. We could want to attach time stamp information to the voltage ramp (maybe the measurement of the `ParameterWithSetpoints` is not continuous, but only during certain windows of the ramp), the natural way of doing which would be to make the voltage ramp a `ParameterWithSetpoints` itself, with setpoints given by the time stamps. I.e., `ps2 -> measured_data, ps1 -> voltage_ramp, p -> time_axis`. Another conceivable option would be to define the time stamps also as setpoints of the measured data parameter (`ps2`), but this is also illegal (two setpoint params imply a 2d setpoint grid rather than two independent setpoints).

The first question here would be if this is even possible with the current dataset structure.

Contributor guide

Open the contributing guide

Research direction

Start at Measurement.register_parameter and the dataset dependency validation that produces the shown ValueError. Examine whether nested ParameterWithSetpoints dependencies can be represented without treating them as a two-dimensional setpoint grid, and whether the current dataset structure supports the proposed time-axis/ramp model. Done means a clear feasibility or design decision for this dependency model.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.