Skip to content

MatrixGate: the name is not taken over during exponentiation #5938

Closed
@mschroemann

Description

@mschroemann

Description of the issue
When you create a matrix gate with a name and exponentiate it, the initial name is lost as the name is not handed over to the power gate:
def pow(self, exponent: Any) -> 'MatrixGate':
if not isinstance(exponent, (int, float)):
return NotImplemented
new_mat = linalg.map_eigenvalues(self._matrix, lambda b: b**exponent)
return MatrixGate(new_mat, qid_shape=self._qid_shape)

How to reproduce the issue

Create a matrix gate with name and print a circuit containing a power of the gate

u = cirq.MatrixGate(np.identity(2), name = "U")
print(cirq.Circuit(u(cirq.LineQubit(1)),u(cirq.LineQubit(1))**2))

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/gateskind/bug-reportSomething doesn't seem to work.triage/discussNeeds decision / discussion, bring these up during Cirq Cynque

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions