Skip to content

Commit

Permalink
Remove _transpile from BaseExperiment
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseclectic committed May 20, 2021
1 parent 2ae72d7 commit 1795be8
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions qiskit_experiments/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@
"""

from abc import ABC, abstractmethod
from typing import Union, Iterable, Optional, Tuple, List
from typing import Iterable, Optional, Tuple, List
import copy
from numbers import Integral
from typing import List, Optional, Iterable, Tuple, Union

from qiskit import transpile, assemble, QuantumCircuit
from qiskit.providers.options import Options
from qiskit.providers.backend import Backend
from qiskit.providers.basebackend import BaseBackend as LegacyBackend
from qiskit.exceptions import QiskitError
from qiskit.providers.backend import Backend
from qiskit.providers.basebackend import BaseBackend as LegacyBackend

from .experiment_data import ExperimentData

Expand Down Expand Up @@ -107,9 +104,7 @@ def run(
experiment_data = self.__experiment_data__(self, backend=backend)

# Generate and transpile circuits
circuits = self._transpile(
self.circuits(backend), backend, **self.transpile_options.__dict__
)
circuits = transpile(self.circuits(backend), backend, **self.transpile_options.__dict__)

# Run circuits on backend
run_opts = copy.copy(self.run_options)
Expand Down Expand Up @@ -172,7 +167,7 @@ def physical_qubits(self) -> Tuple[int]:
return self._physical_qubits

@classmethod
def analysis(cls, **kwargs) -> "BaseAnalysis":
def analysis(cls, **kwargs):
"""Return the default Analysis class for the experiment."""
if cls.__analysis_class__ is None:
raise QiskitError(f"Experiment {cls.__name__} does not have a default Analysis class")
Expand All @@ -187,7 +182,7 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
backend: Optional, a backend object.
Returns:
A list of :class:`QuantumCircuit`s.
A list of :class:`QuantumCircuit`.
.. note::
These circuits should be on qubits ``[0, .., N-1]`` for an
Expand All @@ -198,20 +193,6 @@ def circuits(self, backend: Optional[Backend] = None) -> List[QuantumCircuit]:
# values for any explicit experiment options that effect circuit
# generation

def _transpile(
self,
circuits: Union[QuantumCircuit, List[QuantumCircuit]],
backend: Optional[Backend] = None,
**transpile_options,
) -> List[QuantumCircuit]:
"""Custom transpilation of circuits for running on backend.
Subclasses may modify this method if they need to customize how
transpilation is done, for example to update metadata in the
transpiled circuits.
"""
return transpile(circuits, backend=backend, **transpile_options)

@classmethod
def _default_options(cls) -> Options:
"""Default kwarg options for experiment"""
Expand Down

0 comments on commit 1795be8

Please sign in to comment.