Skip to content

Commit 9bead0b

Browse files
Remove special CXPowGate.on. (#5471)
Fixes #3011
1 parent bf8805c commit 9bead0b

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

cirq-core/cirq/ops/common_gates.py

-13
Original file line numberDiff line numberDiff line change
@@ -1264,19 +1264,6 @@ def __repr__(self) -> str:
12641264
f'global_shift={self._global_shift!r})'
12651265
)
12661266

1267-
def on(self, *args: 'cirq.Qid', **kwargs: 'cirq.Qid') -> raw_types.Operation:
1268-
if not kwargs:
1269-
return super().on(*args)
1270-
if not args and set(kwargs.keys()) == {'control', 'target'}:
1271-
return super().on(kwargs['control'], kwargs['target'])
1272-
raise ValueError(
1273-
"Expected two positional argument or else 'target' AND 'control' "
1274-
"keyword arguments. But got args={!r}, kwargs={!r}.".format(args, kwargs)
1275-
)
1276-
1277-
def __call__(self, *qubits: 'cirq.Qid', **kwargs: 'cirq.Qid'):
1278-
return self.on(*qubits, **kwargs)
1279-
12801267

12811268
def rx(rads: value.TParamVal) -> Rx:
12821269
"""Returns a gate with the matrix e^{-i X rads / 2}."""

cirq-core/cirq/ops/common_gates_test.py

-41
Original file line numberDiff line numberDiff line change
@@ -740,47 +740,6 @@ def test_cnot_unitary():
740740
)
741741

742742

743-
def test_cnot_keyword_arguments():
744-
a = cirq.NamedQubit('a')
745-
b = cirq.NamedQubit('b')
746-
747-
eq_tester = cirq.testing.EqualsTester()
748-
eq_tester.add_equality_group(cirq.CNOT(a, b), cirq.CNOT(control=a, target=b))
749-
eq_tester.add_equality_group(cirq.CNOT(b, a), cirq.CNOT(control=b, target=a))
750-
751-
752-
def test_cnot_keyword_not_equal():
753-
a = cirq.NamedQubit('a')
754-
b = cirq.NamedQubit('b')
755-
756-
with pytest.raises(AssertionError):
757-
eq_tester = cirq.testing.EqualsTester()
758-
eq_tester.add_equality_group(cirq.CNOT(a, b), cirq.CNOT(target=a, control=b))
759-
760-
761-
def test_cnot_keyword_too_few_arguments():
762-
a = cirq.NamedQubit('a')
763-
764-
with pytest.raises(ValueError):
765-
_ = cirq.CNOT(control=a)
766-
767-
768-
def test_cnot_mixed_keyword_and_positional_arguments():
769-
a = cirq.NamedQubit('a')
770-
b = cirq.NamedQubit('b')
771-
772-
with pytest.raises(ValueError):
773-
_ = cirq.CNOT(a, target=b)
774-
775-
776-
def test_cnot_unknown_keyword_argument():
777-
a = cirq.NamedQubit('a')
778-
b = cirq.NamedQubit('b')
779-
780-
with pytest.raises(ValueError):
781-
_ = cirq.CNOT(target=a, controlled=b)
782-
783-
784743
def test_cnot_decompose():
785744
a = cirq.NamedQubit('a')
786745
b = cirq.NamedQubit('b')

0 commit comments

Comments
 (0)