QpyDataModel
pydantic model QpyDataModel
Bases: BaseModel, Generic[T]
QPY-encoded Qiskit objects.
b64_data
field
Type: str [Required]
Base-64 encoded data of the QPY serialization of some Qiskit objects.
Validated by
cross_validate_qpy_info
num_programs
field
Type: int [Required]
The number of distinct elements in the Python encoding.
Constraints
- ge = 1
Validated by
cross_validate_qpy_info
qpy_version
field
Type: int [Required]
The QPY encoding version.
Constraints
- ge = 10
Validated by
cross_validate_qpy_info
cross_validate_qpy_info
from_python
classmethod from_python(data, qpy_version=17)
Create a model instance from Python data of the correct type.
The returned instance owns a reference to the provided data. This instance may be returned by to_python() depending on the value of use_cached. Users of this class are responsible for managing cached instances of the data and possible side-effects of their mutations.
Parameters
- data (list[T]) – The data to base64 encode in the new model instance.
- qpy_version (int) – The QPY version to encode with.
Returns
A new model instance.
Return type
Self
to_python
to_python(use_cached=False)
Return a Python representation of the encoded data in the model.
When use_cached is false, or when no cached version exists, b64_data is decoded and loaded into a new Python instance. Users of this class are responsible for managing cached instances of the Python data and possible side-effects of their mutations.
Parameters
use_cached (bool) – Whether to return the cached instance (if it exists).
Returns
Python data.
Return type
list[T]