Skip to content

StatePrepBase2#9562

Open
comp-phys-marc wants to merge 10 commits into
new-operator-compute-methodsfrom
feature/stateprepbase2
Open

StatePrepBase2#9562
comp-phys-marc wants to merge 10 commits into
new-operator-compute-methodsfrom
feature/stateprepbase2

Conversation

@comp-phys-marc
Copy link
Copy Markdown
Contributor

Context: We want new base abstractions based on Operator2. This includes a StatePrepBase2 class.

Description of the Change: Implements the new StatePrepBase2 base class and its test.

Benefits: We can integrate better with Catalyst, capture, etc.

Possible Drawbacks: N/A

Related GitHub Issues: [sc-120744]

@comp-phys-marc comp-phys-marc changed the base branch from main to new-operator-compute-methods June 2, 2026 21:19
@comp-phys-marc comp-phys-marc marked this pull request as ready for review June 2, 2026 21:21
@comp-phys-marc comp-phys-marc changed the title Feature/stateprepbase2 StatePrepBase2 Jun 2, 2026
Comment thread pennylane/operation2.py Outdated
Co-authored-by: Christina Lee <christina@xanadu.ai>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.45%. Comparing base (a2ccdef) to head (70ff130).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           new-operator-compute-methods    #9562   +/-   ##
=============================================================
  Coverage                         99.45%   99.45%           
=============================================================
  Files                               611      611           
  Lines                             67738    67746    +8     
=============================================================
+ Hits                              67371    67379    +8     
  Misses                              367      367           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pennylane/operation2.py
Comment on lines +1277 to +1284
def label(
self,
decimals: int | None = None,
base_label: str | None = None,
cache: dict | None = None,
) -> str: # pylint: disable=unused-argument
"""The default label for a state prep."""
return "|Ψ⟩"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be problematic. If you create a state prep operator, what its label looks like will depend on the order of inheritance. Consider the following:

class A:
    def foo(self):
        return "hi"

class B:
    def foo(self):
        return "bye"

class C(A, B):
    pass

class D(B, A):
    pass
>>> print(C().foo())
hi
>>> print(D().foo())
bye

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may just need to make StatePrepBase2 a subclass of Operator2. I'm not sure there are other ways to resolve this issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the suggestion. I've done this in my latest change.

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.

3 participants