Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Qiskit/qiskit-terra into is…
Browse files Browse the repository at this point in the history
…sue1160text
  • Loading branch information
TharrmashasthaPV committed Jul 13, 2021
2 parents 335592e + 4403b6a commit 54387af
Show file tree
Hide file tree
Showing 171 changed files with 3,052 additions and 1,070 deletions.
1 change: 1 addition & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ numpy>=1.20.0 ; python_version>'3.6'
decorator==4.4.2
jax==0.2.13
jaxlib==0.1.67
networkx==2.5
1 change: 1 addition & 0 deletions qiskit/algorithms/optimizers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
SPSA
QNSPSA
TNC
SciPyOptimizer
Qiskit also provides the following optimizers, which are built-out using the optimizers from
the `scikit-quant` package. The `scikit-quant` package is not installed by default but must be
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, name, num_qubits, num_clbits, params, duration=None, unit="dt
# NOTE: The conditional statement checking if the `_label` attribute is
# already set is a temporary work around that can be removed after
# the next stable qiskit-aer release
if label is not None or not hasattr(self, "_label"):
if not hasattr(self, "_label"):
self._label = label
# tuple (ClassicalRegister, int), tuple (Clbit, bool) or tuple (Clbit, int)
# when the instruction has a conditional ("if")
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/blueprintcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ def append(self, instruction, qargs=None, cargs=None):
self._build()
return super().append(instruction, qargs, cargs)

def compose(self, other, qubits=None, clbits=None, front=False, inplace=False):
def compose(self, other, qubits=None, clbits=None, front=False, inplace=False, wrap=False):
if self._data is None:
self._build()
return super().compose(other, qubits, clbits, front, inplace)
return super().compose(other, qubits, clbits, front, inplace, wrap)

def inverse(self):
if self._data is None:
Expand Down
7 changes: 4 additions & 3 deletions qiskit/circuit/library/grover_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import List, Optional, Union
import numpy
from qiskit.circuit import QuantumCircuit, QuantumRegister, AncillaRegister
from qiskit.exceptions import QiskitError
from qiskit.quantum_info import Statevector, Operator, DensityMatrix
from .standard_gates import MCXGate

Expand Down Expand Up @@ -274,10 +275,10 @@ def _build(self):
circuit.global_phase = numpy.pi

self.add_register(*circuit.qregs)
if self._insert_barriers:
circuit_wrapped = circuit.to_instruction()
else:
try:
circuit_wrapped = circuit.to_gate()
except QiskitError:
circuit_wrapped = circuit.to_instruction()

self.compose(circuit_wrapped, qubits=self.qubits, inplace=True)

Expand Down
3 changes: 3 additions & 0 deletions qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from qiskit.circuit import Instruction, Parameter, ParameterVector, ParameterExpression
from qiskit.circuit.parametertable import ParameterTable
from qiskit.exceptions import QiskitError
from qiskit.utils.deprecation import deprecate_arguments

from ..blueprintcircuit import BlueprintCircuit

Expand Down Expand Up @@ -793,10 +794,12 @@ def add_layer(

return self

@deprecate_arguments({"param_dict": "parameters"})
def assign_parameters(
self,
parameters: Union[dict, List[float], List[Parameter], ParameterVector],
inplace: bool = False,
param_dict: Optional[dict] = None,
) -> Optional[QuantumCircuit]:
"""Assign parameters to the n-local circuit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import warnings
import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit.exceptions import QiskitError
from .normal import _check_bounds_valid, _check_dimensions_match


Expand Down Expand Up @@ -178,7 +179,13 @@ def __init__(
circuit.compose(distribution, inplace=True)

super().__init__(*circuit.qregs, name=name)
self.compose(circuit.to_instruction(), qubits=self.qubits, inplace=True)

try:
instr = circuit.to_gate()
except QiskitError:
instr = circuit.to_instruction()

self.compose(instr, qubits=self.qubits, inplace=True)

@property
def values(self) -> np.ndarray:
Expand Down
9 changes: 8 additions & 1 deletion qiskit/circuit/library/probability_distributions/normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import warnings
import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit.exceptions import QiskitError


class NormalDistribution(QuantumCircuit):
Expand Down Expand Up @@ -216,7 +217,13 @@ def __init__(
circuit.compose(distribution, inplace=True)

super().__init__(*circuit.qregs, name=name)
self.compose(circuit.to_instruction(), qubits=self.qubits, inplace=True)

try:
instr = circuit.to_gate()
except QiskitError:
instr = circuit.to_instruction()

self.compose(instr, qubits=self.qubits, inplace=True)

@property
def values(self) -> np.ndarray:
Expand Down
Loading

0 comments on commit 54387af

Please sign in to comment.