Skip to content
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

create read-only pauli_rep property #4017

Closed
wants to merge 4 commits into from
Closed

Conversation

timmysilv
Copy link
Contributor

@timmysilv timmysilv commented Apr 20, 2023

op._pauli_rep is now being read in various places, effectively making it part of the Operator API. However, the attribute is private, which suggests otherwise. It seems we want it to stick around, so I'm making it a public (read-only) property.

I'm not adding a setter because I don't want to encourage other places to set it. If you should, you know who you are (probably an arithmetic op, notice that every file changed in pennylane/ is in ops/op_math 😉 ) and you can use the private property. If it gets messy in the future, we can re-consider. But for now, I think this gives the best overall picture of the state of things.

Suggested by Lee in this comment because I was using it in pennylane-lightning as if it was part of the Operator API.

UPDATE: I see @albi3ro you are hesitant to add more to the Operator API. I'd argue that this is effectively already part of it, so it should at least be codified. I agree that the Operator class is getting a touch bloated, but I'd prefer to address that as a separate concern. Perhaps we can make it a bit more of a priority

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Merging #4017 (ba35a07) into master (2c394b7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4017   +/-   ##
=======================================
  Coverage   99.58%   99.58%           
=======================================
  Files         351      351           
  Lines       30832    30835    +3     
=======================================
+ Hits        30703    30706    +3     
  Misses        129      129           
Impacted Files Coverage Δ
pennylane/operation.py 97.24% <100.00%> (+0.01%) ⬆️
pennylane/ops/op_math/composite.py 100.00% <100.00%> (ø)
pennylane/ops/op_math/pow.py 99.33% <100.00%> (ø)
pennylane/ops/op_math/prod.py 100.00% <100.00%> (ø)
pennylane/ops/op_math/sprod.py 96.38% <100.00%> (ø)
pennylane/ops/op_math/sum.py 98.21% <100.00%> (ø)
pennylane/ops/op_math/symbolicop.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@timmysilv
Copy link
Contributor Author

converting to draft, can be used while addressing story 37494

@timmysilv timmysilv marked this pull request as draft May 18, 2023 16:24
@timmysilv timmysilv closed this Dec 4, 2023
@timmysilv timmysilv deleted the pauli-rep-property branch December 4, 2023 18:13
timmysilv added a commit that referenced this pull request Dec 6, 2023
**Context:**
The `pauli_rep` property is widely used, and should be made public

**Description of the Change:**
- Introduce the `pauli_rep` read-only property to the `Operator` class
- Change all (read) references to `op._pauli_rep` into `op.pauli_rep`
(the public version)

**Benefits:**
We're committing to having `pauli_rep` be part of the public API, making
it less scary to lean on while moving forward with other improvements
(eg. combining all the hamiltonian expansion transforms)

**Possible Drawbacks:**
We might want to change things related to it again, and it would require
more careful work because it's public. I'm not so worried about this
because it has existed (and been used) for a while now.

**Related GitHub Issues:**
previously attempted in #4017 
[sc-37494]

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
mudit2812 pushed a commit that referenced this pull request Dec 7, 2023
**Context:**
The `pauli_rep` property is widely used, and should be made public

**Description of the Change:**
- Introduce the `pauli_rep` read-only property to the `Operator` class
- Change all (read) references to `op._pauli_rep` into `op.pauli_rep`
(the public version)

**Benefits:**
We're committing to having `pauli_rep` be part of the public API, making
it less scary to lean on while moving forward with other improvements
(eg. combining all the hamiltonian expansion transforms)

**Possible Drawbacks:**
We might want to change things related to it again, and it would require
more careful work because it's public. I'm not so worried about this
because it has existed (and been used) for a while now.

**Related GitHub Issues:**
previously attempted in #4017 
[sc-37494]

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
mudit2812 pushed a commit that referenced this pull request Jan 19, 2024
**Context:**
The `pauli_rep` property is widely used, and should be made public

**Description of the Change:**
- Introduce the `pauli_rep` read-only property to the `Operator` class
- Change all (read) references to `op._pauli_rep` into `op.pauli_rep`
(the public version)

**Benefits:**
We're committing to having `pauli_rep` be part of the public API, making
it less scary to lean on while moving forward with other improvements
(eg. combining all the hamiltonian expansion transforms)

**Possible Drawbacks:**
We might want to change things related to it again, and it would require
more careful work because it's public. I'm not so worried about this
because it has existed (and been used) for a while now.

**Related GitHub Issues:**
previously attempted in #4017 
[sc-37494]

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant