c3.qiskit.c3_options
¶
Module to implement a C3Options class derived from the native qiskit Options class
Module Contents¶
- class c3.qiskit.c3_options.C3Options(**kwargs)[source]¶
Bases:
qiskit.providers.Options
A derived class of the base Options class in Qiskit.
It only provides an additional to_dict() method to obtain all the options as a single dictionary
- Parameters
Options (qiskit.providers.Options) – Base class for Options. The get() and update_options() are used from this base class
- to_dict() Dict[str, Any] [source]¶
Return a dict representation of the options
- Returns
The Options in the form of a dictionary
- Return type
Dict[str, Any]
- __setattr__(key, value)¶
Implement setattr(self, name, value).
- __copy__()¶
Return a copy of the Options.
The returned option and validator values are shallow copies of the originals.
- __repr__()¶
Return repr(self).
- __eq__(other)¶
Return self==value.
- set_validator(field, validator_value)¶
Set an optional validator for a field in the options
Setting a validator enables changes to an options values to be validated for correctness when
update_options()
is called. For example if you have a numeric field likeshots
you can specify a bounds tuple that set an upper and lower bound on the value such as:options.set_validator("shots", (1, 4096))
In this case whenever the
"shots"
option is updated by the user it will enforce that the value is >=1 and <=4096. AValueError
will be raised if it’s outside those bounds. If a validator is already present for the specified field it will be silently overriden.- Parameters
field (str) – The field name to set the validator on
validator_value (list or tuple or type) – The value to use for the validator depending on the type indicates on how the value for a field is enforced. If a tuple is passed in it must have a length of two and will enforce the min and max value (inclusive) for an integer or float value option. If it’s a list it will list the valid values for a field. If it’s a
type
the validator will just enforce the value is of a certain type.
- Raises
KeyError – If field is not present in the options object
ValueError – If the
validator_value
has an invalid value for a given typeTypeError – If
validator_value
is not a valid type
- update_options(**fields)¶
Update options with kwargs
- get(field, default=None)¶
Get an option value for a given key.
- __str__()¶
Return str(self).