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

Define returns_state in capabilities #107

Merged
merged 10 commits into from
Jun 12, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@

### Bug fixes

* Defines the missing `returns_state` entry of the
`capabilities` dictionary for devices.
[(#107)](https://github.com/PennyLaneAI/pennylane-cirq/pull/107)

### Contributors

This release contains contributions from (in alphabetical order):

Antal Száva

---

# Release 0.22.0
Expand Down
6 changes: 3 additions & 3 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ alabaster==0.7.12
appdirs==1.4.4
attrs==20.3.0
autograd==1.4
autoray==0.2.5
autoray==0.3.1
backports.cached-property==1.0.1
Babel==2.9.1
cachetools==4.2.4
Expand Down Expand Up @@ -41,7 +41,7 @@ openfermion==1.3.0
openfermionpyscf==0.5
packaging==21.0
pandas==1.3.5
git+https://github.com/XanaduAI/pennylane.git#egg=pennylane
pennylane==0.23.0
PennyLane-Lightning==0.23
Pillow==9.1.0
pluggy==1.0.0
Expand Down Expand Up @@ -77,4 +77,4 @@ tqdm==4.64.0
traitlets==5.1.0
typing_extensions==3.10.0.0
urllib3==1.26.9
zipp==3.8.0
zipp==3.8.0
11 changes: 6 additions & 5 deletions pennylane_cirq/qsim_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def operations(self):
}
return ops

@classmethod
def capabilities(cls):
def capabilities(self):
# pylint: disable=missing-function-docstring

# Note: this is an instance method as parent's capabilities is an
# instance method too
capabilities = super().capabilities().copy()
capabilities.update(
supports_inverse_operations=False,
Expand Down Expand Up @@ -135,11 +137,10 @@ def operations(self):
}
return ops

@classmethod
def capabilities(cls):
# pylint: disable=missing-function-docstring
def capabilities(self): # pylint: disable=missing-function-docstring
capabilities = super().capabilities().copy()
capabilities.update(
returns_state=(self.shots is None), # State information is only set if obtaining shots
supports_inverse_operations=False,
)
return capabilities
Expand Down
14 changes: 14 additions & 0 deletions pennylane_cirq/simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def reset(self):
self._result = None
self._state = None

def capabilities(self): # pylint: disable=missing-function-docstring
capabilities = super().capabilities().copy()
capabilities.update(
returns_state=(self.shots is None) # State information is only set if obtaining shots
)
return capabilities

def _apply_basis_state(self, basis_state_operation):
# pylint: disable=missing-function-docstring
if not self.shots is None:
Expand Down Expand Up @@ -297,6 +304,13 @@ def __init__(self, wires, shots=None, qubits=None):
self._result = None
self._state = None

def capabilities(self): # pylint: disable=missing-function-docstring
capabilities = super().capabilities().copy()
capabilities.update(
returns_state=(self.shots is None) # State information is only set if obtaining shots
)
return capabilities

def expval(self, observable, shot_range=None, bin_size=None):
# The simulate_expectation_values from Cirq for mixed states involves
# a density matrix check, which does not always pass because the tolerance
Expand Down
4 changes: 2 additions & 2 deletions requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pennylane
git+https://github.com/PennyLaneAI/pennylane.git
cirq-core
cirq-pasqal
numpy
numpy
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
appdirs==1.4.4
autograd==1.4
autoray==0.2.5
autoray==0.3.1
cachetools==5.0.0
certifi==2021.10.8
charset-normalizer==2.0.12
Expand Down Expand Up @@ -28,7 +28,7 @@ openfermion==1.1.0
openfermionpyscf==0.5
packaging==21.0
pandas==1.3.3
git+https://github.com/XanaduAI/pennylane.git#egg=pennylane
pennylane==0.23.0
PennyLane-Lightning==0.22.1
Pillow==9.1.0
pluggy==1.0.0
Expand Down