qiskit-documentation/docs/api/qiskit/0.40/qiskit.primitives.BaseSampl...

103 lines
2.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: BaseSampler
description: API reference for qiskit.primitives.BaseSampler
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.primitives.BaseSampler
---
# BaseSampler
<Class id="qiskit.primitives.BaseSampler" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.23/qiskit/primitives/base/base_sampler.py" signature="BaseSampler(circuits: Iterable[QuantumCircuit] | QuantumCircuit | None = None, parameters: Iterable[Iterable[Parameter]] | None = None, **kwargs)" modifiers="class">
Bases: `qiskit.primitives.base.base_primitive.BasePrimitive`
Sampler base class
Base class of Sampler that calculates quasi-probabilities of bitstrings from quantum circuits.
**Parameters**
* **circuits** Quantum circuits to be executed.
* **parameters** Parameters of each of the quantum circuits. Defaults to `[circ.parameters for circ in circuits]`.
* **options** Default options.
**Raises**
**ValueError** For mismatch of circuits and parameters list.
## Methods
### close
<Function id="qiskit.primitives.BaseSampler.close" signature="BaseSampler.close()">
Close the session and free resources
</Function>
### run
<Function id="qiskit.primitives.BaseSampler.run" signature="BaseSampler.run(circuits, parameter_values=None, **run_options)">
Run the job of the sampling of bitstrings.
**Parameters**
* **circuits** One of more circuit objects.
* **parameter\_values** Parameters to be bound to the circuit.
* **run\_options** Backend runtime options used for circuit execution.
**Returns**
The job object of the result of the sampler. The i-th result corresponds to `circuits[i]` evaluated with parameters bound as `parameter_values[i]`.
**Raises**
**ValueError** Invalid arguments are given.
</Function>
### set\_options
<Function id="qiskit.primitives.BaseSampler.set_options" signature="BaseSampler.set_options(**fields)">
Set options values for the estimator.
**Parameters**
**\*\*fields** The fields to update the options
</Function>
## Attributes
### circuits
<Attribute id="qiskit.primitives.BaseSampler.circuits">
Quantum circuits to be sampled.
**Returns**
The quantum circuits to be sampled.
</Attribute>
### options
<Attribute id="qiskit.primitives.BaseSampler.options">
Return options values for the estimator.
**Return type**
[`Options`](qiskit.providers.Options "qiskit.providers.options.Options")
**Returns**
options
</Attribute>
### parameters
<Attribute id="qiskit.primitives.BaseSampler.parameters">
Parameters of quantum circuits.
**Returns**
List of the parameters in each quantum circuit.
</Attribute>
</Class>