semi_cr.core.lab.parameters package¶
Submodules¶
semi_cr.core.lab.parameters.betterdelegate module¶
- class semi_cr.core.lab.parameters.betterdelegate.BetterDelegateParameter(name: str, *, source: Parameter | None, **kwargs: Unpack[ParameterKWArgs[ParameterDataTypeVar, InstrumentTypeVar_co]])[source]¶
Bases:
DelegateParameter- validate(value: Any | None) None[source]¶
Validate the supplied value. If it has a source parameter, validate the value as well with the source validator.
- Parameters:
value – value to validate
- Raises:
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- __getitem__(keys: Any) SweepFixedValues¶
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- add_validator(vals: Validator) None¶
Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.
- Parameters:
vals – Validator to add to the parameter.
- property depends_on: ParameterSet¶
- extra_validator(vals: Validator) Generator[None, None, None]¶
Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.
- property full_name: str¶
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]¶
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters:
value – target value
step – maximum step size
- Returns:
List of stepped values, including target value.
- get_raw() Any¶
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- global_on_set_callback = None¶
- property has_control_of: ParameterSet¶
- increment(value: ParameterDataTypeVar) None¶
Increment the parameter with a value
- Parameters:
value – Value to be added to the parameter.
- property instrument: InstrumentTypeVar_co¶
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float¶
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter:
Returns the current inter_delay.
- Setter:
Sets the value of the inter_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property is_controlled_by: ParameterSet¶
- property label: str¶
Label of the data used for plots etc. Read from source if not explicitly overwritten. Set to None to disable overwrite.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Name of the parameter. This is identical to
short_name().
- property param_spec: ParamSpecBase¶
- property post_delay: float¶
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter:
Returns the current post_delay.
- Setter:
Sets the value of the post_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any¶
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter:
Returns the cached raw value of the parameter.
- property register_name: str¶
Name that will be used to register this parameter in a dataset By default, this returns
full_nameor the value of theregister_nameargument if it was passed at initialization.
- remove_validator() Validator | None¶
Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.
- Returns:
The last validator added to the parameter or None if there are no validators associated with the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext¶
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None¶
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None¶
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext¶
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str¶
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters:
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns:
base snapshot
- property source: Parameter | None¶
The source parameter that this
DelegateParameteris bound to orNoneif thisDelegateParameteris unbound.- Getter:
Returns the current source.
- Setter:
Sets the source.
- property step: int | float | integer | floating | None¶
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter:
Returns the current stepsize.
- Setter:
Sets the value of the step.
- Raises:
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues¶
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters:
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns:
Collection of parameter values to be iterated over.
- Return type:
SweepFixedValues
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None¶
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- property unit: str¶
The unit of measure. Read from source if not explicitly overwritten. Set to None to disable overwrite.
- property validators: tuple[Validator, ...]¶
Tuple of all validators associated with the parameter. Note that this includes validators of the source parameter if source parameter is set and has any validators.
- Getter:
All validators associated with the parameter.
- property vals: Validator | None¶
The first validator of the parameter. None if no validators are set for this parameter.
- Getter:
Returns the first validator or None if no validators.
- Setter:
Sets the first validator. Set to None to remove the first validator.
- Raises:
RuntimeError – If removing the first validator when more than one validator is set.
- metadata¶
- class semi_cr.core.lab.parameters.betterdelegate.NoneParameter(**kwargs: Any)[source]¶
Bases:
Parameter- __getitem__(keys: Any) SweepFixedValues¶
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- add_validator(vals: Validator) None¶
Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.
- Parameters:
vals – Validator to add to the parameter.
- property depends_on: ParameterSet¶
- extra_validator(vals: Validator) Generator[None, None, None]¶
Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.
- property full_name: str¶
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]¶
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters:
value – target value
step – maximum step size
- Returns:
List of stepped values, including target value.
- get_raw() Any¶
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- global_on_set_callback = None¶
- property has_control_of: ParameterSet¶
- increment(value: ParameterDataTypeVar) None¶
Increment the parameter with a value
- Parameters:
value – Value to be added to the parameter.
- property instrument: InstrumentTypeVar_co¶
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float¶
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter:
Returns the current inter_delay.
- Setter:
Sets the value of the inter_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property is_controlled_by: ParameterSet¶
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Name of the parameter. This is identical to
short_name().
- property param_spec: ParamSpecBase¶
- property post_delay: float¶
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter:
Returns the current post_delay.
- Setter:
Sets the value of the post_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any¶
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter:
Returns the cached raw value of the parameter.
- property register_name: str¶
Name that will be used to register this parameter in a dataset By default, this returns
full_nameor the value of theregister_nameargument if it was passed at initialization.
- remove_validator() Validator | None¶
Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.
- Returns:
The last validator added to the parameter or None if there are no validators associated with the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext¶
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None¶
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None¶
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext¶
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str¶
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: bool | None = False) dict[str, Any]¶
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters:
update – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters:
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns:
base snapshot
- property step: int | float | integer | floating | None¶
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter:
Returns the current stepsize.
- Setter:
Sets the value of the step.
- Raises:
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues¶
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters:
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns:
Collection of parameter values to be iterated over.
- Return type:
SweepFixedValues
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None¶
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: ParameterDataTypeVar) None¶
Validate the value supplied.
- Parameters:
value – value to validate
- Raises:
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- property validators: tuple[Validator, ...]¶
Tuple of all validators associated with the parameter.
- Getter:
All validators associated with the parameter.
- property vals: Validator | None¶
The first validator of the parameter. None if no validators are set for this parameter.
- Getter:
Returns the first validator or None if no validators.
- Setter:
Sets the first validator. Set to None to remove the first validator.
- Raises:
RuntimeError – If removing the first validator when more than one validator is set.
- get_parser¶
- set_parser¶
- cache¶
- get_latest¶
- get¶
- set¶
- metadata¶
semi_cr.core.lab.parameters.multiplexer module¶
- class semi_cr.core.lab.parameters.multiplexer.SetpointParams(swept: semi_cr.core.lab.utils.data.collection.ParameterCollection, fixed: semi_cr.core.lab.utils.data.collection.ParameterCollection)[source]¶
Bases:
object- swept: ParameterCollection¶
- fixed: ParameterCollection¶
- class semi_cr.core.lab.parameters.multiplexer.MultiplexerParams(setpoints: semi_cr.core.lab.parameters.multiplexer.SetpointParams, measured: semi_cr.core.lab.utils.data.collection.ParameterCollection)[source]¶
Bases:
object- setpoints: SetpointParams¶
- measured: ParameterCollection¶
- class semi_cr.core.lab.parameters.multiplexer.SetpointData(swept: semi_cr.core.lab.utils.data.collection.DataCollection, fixed: semi_cr.core.lab.utils.data.collection.DataCollection)[source]¶
Bases:
object- swept: DataCollection¶
- fixed: DataCollection¶
- class semi_cr.core.lab.parameters.multiplexer.MultiplexerSweepResult(setpoints: semi_cr.core.lab.parameters.multiplexer.SetpointData, measured: semi_cr.core.lab.utils.data.collection.DataCollection)[source]¶
Bases:
object- setpoints: SetpointData¶
- measured: DataCollection¶
semi_cr.core.lab.parameters.resistor module¶
- class semi_cr.core.lab.parameters.resistor.ResistorParams(setpoints: semi_cr.core.lab.utils.data.collection.ParameterCollection, measured: semi_cr.core.lab.utils.data.collection.ParameterCollection)[source]¶
Bases:
object- setpoints: ParameterCollection¶
- measured: ParameterCollection¶
- class semi_cr.core.lab.parameters.resistor.ResistorSweepResult(setpoints: semi_cr.core.lab.utils.data.collection.DataCollection, measured: semi_cr.core.lab.utils.data.collection.DataCollection)[source]¶
Bases:
object- setpoints: DataCollection¶
- measured: DataCollection¶
semi_cr.core.lab.parameters.tankinductor module¶
- class semi_cr.core.lab.parameters.tankinductor.TankInductorParams(setpoints: semi_cr.core.lab.utils.data.collection.ParameterCollection, measpoints: semi_cr.core.lab.utils.data.collection.ParameterCollection)[source]¶
Bases:
object- setpoints: ParameterCollection¶
- measpoints: ParameterCollection¶
- class semi_cr.core.lab.parameters.tankinductor.TankInductorSweepResult(setpoints: semi_cr.core.lab.utils.data.collection.DataCollection, measpoints: semi_cr.core.lab.utils.data.collection.DataCollection)[source]¶
Bases:
object- setpoints: DataCollection¶
- measpoints: DataCollection¶
semi_cr.core.lab.parameters.tenqubit module¶
- class semi_cr.core.lab.parameters.tenqubit.SetpointParams(swept: semi_cr.core.lab.utils.data.collection.ParameterCollection, fixed: semi_cr.core.lab.utils.data.collection.ParameterCollection)[source]¶
Bases:
object- swept: ParameterCollection¶
- fixed: ParameterCollection¶
- class semi_cr.core.lab.parameters.tenqubit.TenQubitParams(setpoints: semi_cr.core.lab.parameters.tenqubit.SetpointParams, measured: semi_cr.core.lab.utils.data.collection.ParameterCollection)[source]¶
Bases:
object- setpoints: SetpointParams¶
- measured: ParameterCollection¶
- class semi_cr.core.lab.parameters.tenqubit.SetpointData(swept: semi_cr.core.lab.utils.data.collection.DataCollection, fixed: semi_cr.core.lab.utils.data.collection.DataCollection)[source]¶
Bases:
object- swept: DataCollection¶
- fixed: DataCollection¶
- class semi_cr.core.lab.parameters.tenqubit.TenQubitSweepResult(setpoints: semi_cr.core.lab.parameters.tenqubit.SetpointData, measured: semi_cr.core.lab.utils.data.collection.DataCollection)[source]¶
Bases:
object- setpoints: SetpointData¶
- measured: DataCollection¶