Skip to content

Commit

Permalink
Set CUGate as not implemented to avoid misleading error message (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneGasperini committed Aug 11, 2023
1 parent ecfce4f commit f5f98ec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/qiskit_symb/circuit/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
'ctdg': CTdgGate,
'u': UGate,
'u3': UGate,
'cu': CUGate,
# https:/SimoneGasperini/qiskit-symb/issues/4
# 'cu': CUGate,
'cu3': CUGate,
'rx': RXGate,
'crx': CRXGate,
Expand Down
2 changes: 1 addition & 1 deletion src/qiskit_symb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_init(name):
"""todo"""
if name not in NAME_TO_INIT:
raise NotImplementedError(
f'Gate "{name}" is not implemented in qiskit-symb')
f'Gate "{name}" is not implemented in qiskit-symb, use Qiskit transpiler!')
return NAME_TO_INIT[name]


Expand Down
Empty file added tests/__init__.py
Empty file.
7 changes: 4 additions & 3 deletions tests/test_ctrl_parametric_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from qiskit.circuit import ParameterVector, Parameter
from qiskit.quantum_info import Operator
from qiskit.circuit.library import (
UGate, RXGate, RYGate, RZGate,
RXGate, RYGate, RZGate,
PhaseGate, RGate,
RXXGate, RYYGate,
RZZGate, RZXGate
Expand All @@ -15,14 +15,14 @@

val_range = {'min_value': -2*numpy.pi, 'max_value': 2*numpy.pi}


# https:/SimoneGasperini/qiskit-symb/issues/4
"""
@settings(deadline=None, max_examples=10)
@given(theta=strategies.floats(**val_range),
phi=strategies.floats(**val_range),
lam=strategies.floats(**val_range),
seed=strategies.integers(min_value=0))
def test_cu(theta, phi, lam, seed):
"""todo"""
pars_vals = [theta, phi, lam]
pars = ParameterVector(name='pars', length=len(pars_vals))
circuit = get_random_controlled(base_gate=UGate(*pars), seed=seed)
Expand All @@ -34,6 +34,7 @@ def test_cu(theta, phi, lam, seed):
arr2 = symb_Operator(
circuit).subs({pars: pars_vals}).to_numpy()
assert numpy.allclose(arr1, arr2)
"""


@settings(deadline=None, max_examples=10)
Expand Down

0 comments on commit f5f98ec

Please sign in to comment.