Skip to content

Operations on MutableDensePauliString return a DensePauliString #4835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tanujkhattar opened this issue Jan 13, 2022 · 3 comments · Fixed by #5624
Closed

Operations on MutableDensePauliString return a DensePauliString #4835

tanujkhattar opened this issue Jan 13, 2022 · 3 comments · Fixed by #5624
Assignees
Labels
area/gates area/paulis good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. no QC knowledge needed Want to contribute to Cirq, but don't know quantum computing? This issue is for you. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@tanujkhattar
Copy link
Collaborator

tanujkhattar commented Jan 13, 2022

Description of the issue
Doing operations like __pow__, __mul__, __rmul__, __abs__, tensor_product etc. on a MutableDensePauliString return a DensePauliString because these methods are inherited from BaseDensePauliString which returns DensePauliString(...) instead of type(self)(...) in these methods.

https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/ops/dense_pauli_string.py#L206-L208

How to reproduce the issue

>>> import cirq
>>> m = cirq.MutableDensePauliString("Z")
>>> type(m) == type(-m)
False

Cirq version
0.14.0.dev

@tanujkhattar tanujkhattar added kind/bug-report Something doesn't seem to work. area/gates area/paulis labels Jan 13, 2022
@tanujkhattar tanujkhattar added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Jan 13, 2022
@tanujkhattar
Copy link
Collaborator Author

From cirq sync: +1, should be done.

@tanujkhattar tanujkhattar added triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. no QC knowledge needed Want to contribute to Cirq, but don't know quantum computing? This issue is for you. and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Jan 19, 2022
@alexbouayad
Copy link

alexbouayad commented Jan 25, 2022

Hi, I've opened a PR (#4892).

@alexbouayad
Copy link

@tanujkhattar could someone quickly review my PR? I don't think there's anything complex or obscure here, but I'd still be happy to know if I have correctly tackled the issue. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gates area/paulis good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. no QC knowledge needed Want to contribute to Cirq, but don't know quantum computing? This issue is for you. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
2 participants