コード例 #1
0
class PulseQobjInstructionSchema(QobjInstructionSchema):
    """Schema for PulseQobjInstruction."""
    # pylint: disable=invalid-name

    # Required properties
    t0 = Integer(required=True, validate=Range(min=0))

    # Optional properties.
    ch = String(validate=Regexp('[dum]([0-9])+'))
    conditional = Integer(validate=Range(min=0))
    phase = Number()
    val = Complex()
    duration = Integer(validate=Range(min=1))
    qubits = List(Integer(validate=Range(min=0)), validate=Length(min=1))
    memory_slot = List(Integer(validate=Range(min=0)), validate=Length(min=1))
    register_slot = List(Integer(validate=Range(min=0)),
                         validate=Length(min=1))
    kernels = Nested(QobjMeasurementOptionSchema, many=True)
    discriminators = Nested(QobjMeasurementOptionSchema, many=True)
    label = String()
    type = String()
コード例 #2
0
ファイル: pulse.py プロジェクト: ymarathe/qiskit-terra
class PulseQobjInstructionSchema(QobjInstructionSchema):
    """Schema for PulseQobjInstruction."""
    # pylint: disable=invalid-name

    # Required properties
    t0 = Integer(required=True, validate=Range(min=0))

    # Optional properties.
    ch = String(validate=Regexp('[dum]([0-9])+'))
    conditional = Integer(validate=Range(min=0))
    val = ByType([Complex(), String()])
    phase = ByType([Float(), String()])
    duration = Integer(validate=Range(min=1))
    qubits = List(Integer(validate=Range(min=0)), validate=Length(min=1))
    memory_slot = List(Integer(validate=Range(min=0)), validate=Length(min=1))
    register_slot = List(Integer(validate=Range(min=0)), validate=Length(min=1))
    kernels = Nested(QobjMeasurementOptionSchema, many=True)
    discriminators = Nested(QobjMeasurementOptionSchema, many=True)
    label = String()
    type = String()
    parameters = DictParameters(valid_value_types=(int, float, bool, complex))
コード例 #3
0
class BackendConfigurationSchema(BaseSchema):
    """Schema for BackendConfiguration."""
    # Required properties.
    backend_name = String(required=True)
    backend_version = String(required=True,
                             validate=Regexp("[0-9]+.[0-9]+.[0-9]+$"))
    n_qubits = Integer(required=True, validate=Range(min=1))
    basis_gates = List(String(), required=True, validate=Length(min=1))
    gates = Nested(GateConfigSchema,
                   required=True,
                   many=True,
                   validate=Length(min=1))
    local = Boolean(required=True)
    simulator = Boolean(required=True)
    conditional = Boolean(required=True)
    memory = Boolean(required=True)
    max_shots = Integer(required=True, validate=Range(min=1))
    open_pulse = Boolean(required=True)

    # Optional properties.
    max_experiments = Integer(validate=Range(min=1))
    sample_name = String()
    coupling_map = List(List(Integer(), validate=Length(min=1)),
                        validate=Length(min=1),
                        allow_none=True)
    n_registers = Integer(validate=Range(min=1))
    register_map = List(List(Integer(validate=OneOf([0, 1])),
                             validate=Length(min=1)),
                        validate=Length(min=1))
    configurable = Boolean()
    credits_required = Boolean()
    online_date = DateTime()
    display_name = String()
    description = String()
    tags = List(String())
コード例 #4
0
ファイル: schema.py プロジェクト: o7s8r6/qiskit-ibmq-provider
class JobResponseSchema(BaseSchema):
    """Schema for ``IBMQJob``.

    The following conventions are in use in order to provide enough
    flexibility in regards to attributes:

        * the "Required properties" reflect attributes that will always be present
          in the model.
        * the "Optional properties with a default value" reflect attributes that
          are always present in the model, but might contain uninitialized values
          depending on the state of the job.
        * some properties are prepended by underscore due to name clashes and extra
          constraints in the ``IBMQJob`` class (for example, existing ``IBMQJob``
          methods that have the same name as a response field).

    The schema is used for ``GET /Jobs``, ``GET /Jobs/{id}``, and ``POST /Jobs``
    responses.
    """
    # pylint: disable=invalid-name

    # Required properties.
    _creation_date = DateTime(required=True)
    _job_id = String(required=True)
    _api_status = Enum(required=True, enum_cls=ApiJobStatus)

    # Optional properties with a default value.
    kind = Enum(enum_cls=ApiJobKind, missing=None)
    _name = String(missing=None)
    _time_per_step = Dict(keys=String, values=String, missing=None)
    _result = Nested(ResultSchema, missing=None)
    _qobj = Raw(missing=None)
    _error = Nested(JobResponseErrorSchema, missing=None)
    _tags = List(String, missing=[])
    _run_mode = String(missing=None)

    # Optional properties
    _backend_info = Nested(JobResponseBackendSchema)
    allow_object_storage = Boolean()

    @pre_load
    def preprocess_field_names(self, data, **_):  # type: ignore
        """Pre-process the job response fields.

        Rename selected fields of the job response due to name clashes, and
        convert the rest of the fields to Python convention.

        TODO: when updating to terra 0.10, check if changes related to
        marshmallow 3 allow to use directly `data_key`, as in 0.9 terra
        duplicates the unknown keys.
        """
        return map_field_names(FIELDS_MAP, data)
コード例 #5
0
class BackendPropertiesSchema(BaseSchema):
    """Schema for BackendProperties."""

    # Required properties.
    backend_name = String(required=True)
    backend_version = String(required=True,
                             validate=Regexp("[0-9]+.[0-9]+.[0-9]+$"))
    last_update_date = DateTime(required=True)
    qubits = List(Nested(NduvSchema, many=True, validate=Length(min=1)),
                  required=True,
                  validate=Length(min=1))
    gates = Nested(GateSchema,
                   required=True,
                   many=True,
                   validate=Length(min=1))
    general = Nested(NduvSchema, required=True, many=True)
コード例 #6
0
class ExperimentResultSchema(BaseSchema):
    """Schema for ExperimentResult."""

    # Required fields.
    shots = ByType([
        Integer(),
        List(Integer(validate=Range(min=1)), validate=Length(equal=2))
    ],
                   required=True)
    success = Boolean(required=True)
    data = Nested(ExperimentResultDataSchema, required=True)

    # Optional fields.
    status = String()
    seed = Integer()
    meas_return = String(validate=OneOf(['single', 'avg']))
    header = Nested(ObjSchema)
コード例 #7
0
ファイル: models.py プロジェクト: jagunnels/qiskit-sdk-py
class ExperimentResultSchema(BaseSchema):
    """Schema for ExperimentResult."""

    # Required fields.
    shots = ByType([Integer(), List(Integer(validate=Range(min=1)),
                                    validate=Length(equal=2))],
                   required=True)
    success = Boolean(required=True)
    data = Nested(ExperimentResultDataSchema, required=True)

    # Optional fields.
    status = String()
    seed = Integer()
    meas_level = Integer(validate=Range(min=0, max=2))
    meas_return = String(validate=OneOf(choices=(MeasReturnType.AVERAGE,
                                                 MeasReturnType.SINGLE)))
    header = Nested(ObjSchema)
コード例 #8
0
class PulseQobjExperimentConfigSchema(QobjExperimentConfigSchema):
    """Schema for PulseQobjExperimentConfig."""

    # Optional properties.
    qubit_lo_freq = List(Number())
    meas_lo_freq = List(Number())
コード例 #9
0
class PulseLibraryItemSchema(BaseSchema):
    """Schema for PulseLibraryItem."""

    # Required properties.
    name = String(required=True)
    samples = List(Complex(), required=True, validate=Length(min=1))
コード例 #10
0
ファイル: root.py プロジェクト: yeralin/qiskit-ibmq-provider
class BackendsResponseSchema(BaseSchema):
    """Schema for BackendResponse"""

    # Required properties
    backends = List(Nested(BackendConfigurationSchema, required=True))
コード例 #11
0
class PulseBackendConfigurationSchema(QasmBackendConfigurationSchema):
    """Schema for pulse backend"""
    # Required properties.
    open_pulse = Boolean(required=True, validate=OneOf([True]))
    n_uchannels = Integer(required=True, validate=Range(min=0))
    u_channel_lo = List(
        Nested(UchannelLOSchema,
               validate=Length(min=1),
               required=True,
               many=True))
    meas_levels = List(Integer(), validate=Length(min=1), required=True)
    qubit_lo_range = List(List(Float(validate=Range(min=0)),
                               validate=Length(equal=2)),
                          required=True)
    meas_lo_range = List(List(Float(validate=Range(min=0)),
                              validate=Length(equal=2)),
                         required=True)
    dt = Float(required=True, validate=Range(min=0))  # pylint: disable=invalid-name
    dtm = Float(required=True, validate=Range(min=0))
    rep_times = List(Float(validate=Range(min=0)), required=True)
    meas_kernels = List(String(), required=True)
    discriminators = List(String(), required=True)

    # Optional properties.
    meas_map = List(List(Integer(), validate=Length(min=1)))
    channel_bandwidth = List(List(Float(), validate=Length(equal=2)))
    acquisition_latency = List(List(Integer()))
    conditional_latency = List(List(Integer()))
    hamiltonian = PulseHamiltonianSchema()