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

Update to support Operator.eigvals as a method #35

Merged
merged 4 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

### Bug fixes

* Updates the plugin to be compatible with the use of `Operator.eigvals` as a method.
albi3ro marked this conversation as resolved.
Show resolved Hide resolved
[(#35)](https://github.com/PennyLaneAI/pennylane-qulacs/pull/35)

### Contributors

This release contains contributions from (in alphabetical order):

Christina Lee

---

# Release 0.16.0
Expand Down
5 changes: 4 additions & 1 deletion pennylane_qulacs/qulacs_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ def expval(self, observable, **kwargs):
return qulacs_observable.get_expectation_value(self._pre_rotated_state)

# exact expectation value
eigvals = self._asarray(observable.eigvals, dtype=self.R_DTYPE)
if callable(observable.eigvals):
eigvals = self._asarray(observable.eigvals(), dtype=self.R_DTYPE)
else: # older version of pennylane
eigvals = self._asarray(observable.eigvals, dtype=self.R_DTYPE)
prob = self.probability(wires=observable.wires)
return self._dot(eigvals, prob)

Expand Down