Skip to content

Commit 8a44381

Browse files
authored
Remove analytic keyword argument and v0.15 version bump (#69)
* Remove analytic keyword argument and v0.15 version bump * fix * fix * fix * fix * Update setup.py * fix * fix * fix * fix * fix * fix * update header
1 parent 35b8d5b commit 8a44381

File tree

10 files changed

+44
-49
lines changed

10 files changed

+44
-49
lines changed

.github/CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Release 0.15.0-dev
1+
# Release 0.15.0
22

3-
### New features since last release
43

54
### Breaking changes
65

7-
### Improvements
8-
9-
### Documentation
10-
11-
### Bug fixes
6+
* For compatibility with PennyLane v0.15, the `analytic` keyword argument
7+
has been removed from all devices. Analytic expectation values can
8+
still be computed by setting `shots=None`.
9+
[(#69)](https://github.com/XanaduAI/pennylane-pq/pull/69)
1210

1311
### Contributors
1412

1513
This release contains contributions from (in alphabetical order):
1614

15+
Josh Izaac
16+
1717
---
1818

1919
# Release 0.11.0

.github/workflows/tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
uses: styfle/cancel-workflow-action@0.4.1
1717
with:
1818
access_token: ${{ github.token }}
19-
- uses: actions/checkout@v1
19+
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 2
2022
- name: Set up Python
2123
uses: actions/setup-python@v2
2224
with:
@@ -33,8 +35,8 @@ jobs:
3335
- name: Run tests
3436
env:
3537
IBMQX_TOKEN: ${{ secrets.IBMQX_TOKEN }}
36-
run: python -m pytest tests --cov=pennylane_pq --cov-report=term-missing -p no:warnings --tb=native
38+
run: python -m pytest tests --cov=pennylane_pq --cov-report=term-missing --cov-report=xml -p no:warnings --tb=native
3739
- name: Upload coverage to Codecov
38-
uses: codecov/codecov-action@v1.0.7
40+
uses: codecov/codecov-action@v1.0.12
3941
with:
40-
file: ./.coverage
42+
file: ./coverage.xml

doc/xanadu_theme/header.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
</li>
3434
<li class="nav-item active">
3535
<a class="nav-link" href="https://pennylane.ai/plugins.html">Plugins</a>
36+
<span class="sr-only">(current)</span>
3637
</li>
3738
<li class="nav-item">
3839
<a class="nav-link" href="https://pennylane.readthedocs.io">Documentation</a>
39-
<span class="sr-only">(current)</span>
40+
</li>
41+
<li class="nav-item">
42+
<a class="nav-link" href="https://pennylane.ai/blog">Blog</a>
4043
</li>
4144
<li class="nav-item">
4245
<a class="nav-link" href="https://qhack.ai"><img src="https://pennylane.ai/img/qhack_plain_black.png"></a>

doc/xanadu_theme/layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{# Do this so that bootstrap is included before the main css file #}
44
{%- block htmltitle %}
55
<link href="https://fonts.googleapis.com/css?family=Noto+Serif" rel="stylesheet">
6+
<link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
67
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
78

89
<!-- Font Awesome -->

doc/xanadu_theme/static/xanadu.css_t

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
/* Sphinx themes
22
-------------------------------------------------- */
3-
@font-face {
4-
font-family: 'Product Sans';
5-
font-style: normal;
6-
font-weight: 400;
7-
src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/productsans/v5/HYvgU2fE2nRJvZ5JFAumwegdm0LZdjqr5-oayXSOefg.woff2) format('woff2');
8-
}
9-
10-
11-
123
body {
134
/*background-color: #edf0f2;*/
145
margin: 0;
@@ -92,7 +83,7 @@ h1, h2, h3, h4, h5, h6 {
9283
color: black;
9384
font-weight: normal;
9485
padding: 0;
95-
font-family: 'Product Sans', 'Roboto', sans-serif!important;
86+
font-family: 'Noto Sans', 'Roboto', sans-serif!important;
9687
}
9788

9889
h1, h2, h3 {
@@ -371,7 +362,7 @@ div.sphinxsidebar p {
371362
margin: 20px 0px 10px 21px;
372363
font-weight: normal;
373364
padding: 0;
374-
font-family: 'Product Sans', 'Roboto', sans-serif!important;
365+
font-family: 'Noto Sans', 'Roboto', sans-serif!important;
375366
font-size: 24px;
376367
color: #515151;
377368
/*text-align: center;*/
@@ -2012,7 +2003,7 @@ footer.page-footer .footer-copyright {
20122003
margin-left: 20px;
20132004
font-size: initial;
20142005
color: black;
2015-
font-family: 'Product Sans', 'Roboto', sans-serif !important;
2006+
font-family: 'Noto Sans', 'Roboto', sans-serif !important;
20162007
margin-bottom: -9px;
20172008
border-bottom: 3px solid;
20182009
border-bottom-color: white;

pennylane_pq/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
Version number (major.minor.patch[-label])
1717
"""
1818

19-
__version__ = "0.15.0-dev"
19+
__version__ = "0.15.0"

pennylane_pq/devices.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,9 @@ class _ProjectQDevice(Device): # pylint: disable=abstract-method
111111
wires (int or Iterable[Number, str]]): Number of subsystems represented by the device,
112112
or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
113113
or strings (``['ancilla', 'q1', 'q2']``). Default 1 if not specified.
114-
shots (int): How many times the circuit should be evaluated (or sampled) to estimate
115-
the expectation values. Defaults to 1024 if not specified.
116-
If ``analytic == True``, then the number of shots is ignored
117-
in the calculation of expectation values and variances, and only controls the number
118-
of samples returned by ``sample``.
119-
analytic (bool): indicates if the device should calculate expectations
120-
and variances analytically
114+
shots (None, int): How many times the circuit should be evaluated (or sampled) to estimate
115+
the expectation values. Defaults to ``None`` if not specified, which means that the device
116+
returns analytical results.
121117
122118
Keyword Args:
123119
backend (string): Name of the backend, i.e., either "Simulator",
@@ -165,7 +161,7 @@ def _observable_map(self):
165161
def _backend_kwargs(self):
166162
raise NotImplementedError
167163

168-
def __init__(self, wires=1, shots=1024, analytic=True, *, backend, **kwargs):
164+
def __init__(self, wires=1, shots=None, *, backend, **kwargs):
169165
# overwrite shots with num_runs if given
170166
if "num_runs" in kwargs:
171167
shots = kwargs["num_runs"]
@@ -176,7 +172,6 @@ def __init__(self, wires=1, shots=1024, analytic=True, *, backend, **kwargs):
176172
if "verbose" not in kwargs:
177173
kwargs["verbose"] = False
178174

179-
self.analytic = analytic
180175
self._backend = backend
181176
self._kwargs = kwargs
182177
self._eng = None
@@ -276,13 +271,9 @@ class ProjectQSimulator(_ProjectQDevice):
276271
wires (int or Iterable[Number, str]]): Number of subsystems represented by the device,
277272
or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
278273
or strings (``['ancilla', 'q1', 'q2']``).
279-
shots (int): How many times the circuit should be evaluated (or sampled) to estimate
280-
the expectation values. Defaults to 1000 if not specified.
281-
If ``analytic == True``, then the number of shots is ignored
282-
in the calculation of expectation values and variances, and only controls the number
283-
of samples returned by ``sample``.
284-
analytic (bool): indicates if the device should calculate expectations
285-
and variances analytically
274+
shots (None, int): How many times the circuit should be evaluated (or sampled) to estimate
275+
the expectation values. Defaults to ``None`` if not specified, which means that the device
276+
returns analytical results.
286277
287278
Keyword Args:
288279
gate_fusion (bool): If True, operations are cached and only executed once a
@@ -337,9 +328,9 @@ class ProjectQSimulator(_ProjectQDevice):
337328
_circuits = {}
338329
_backend_kwargs = ["gate_fusion", "rnd_seed"]
339330

340-
def __init__(self, wires=1, shots=1024, analytic=True, **kwargs):
331+
def __init__(self, wires=1, shots=None, **kwargs):
341332
kwargs["backend"] = "Simulator"
342-
super().__init__(wires=wires, shots=shots, analytic=analytic, **kwargs)
333+
super().__init__(wires=wires, shots=shots, **kwargs)
343334

344335
def reset(self):
345336
"""Reset/initialize the device by initializing the backend and engine, and allocating qubits."""
@@ -372,7 +363,7 @@ def expval(self, observable, wires, par):
372363
# pq.ops.QubitOperator("Z"+'0'), [qubit])
373364
# for qubit in self._reg]
374365

375-
if not self.analytic and observable != "Identity":
366+
if not self.shots is None and observable != "Identity":
376367
p0 = (expval + 1) / 2
377368
p0 = max(min(p0, 1), 0)
378369
n0 = np.random.binomial(self.shots, p0)
@@ -516,7 +507,7 @@ def __init__(self, wires=1, shots=1024, **kwargs):
516507
) # pylint: disable=line-too-long
517508

518509
kwargs["backend"] = "IBMBackend"
519-
super().__init__(wires=wires, shots=shots, analytic=False, **kwargs)
510+
super().__init__(wires=wires, shots=shots, **kwargs)
520511

521512
def reset(self):
522513
"""Reset/initialize the device by initializing the backend and engine, and allocating qubits."""
@@ -658,7 +649,7 @@ class ProjectQClassicalSimulator(_ProjectQDevice):
658649

659650
def __init__(self, wires=1, **kwargs):
660651
kwargs["backend"] = "ClassicalSimulator"
661-
super().__init__(wires=wires, shots=1024, analytic=True, **kwargs)
652+
super().__init__(wires=wires, shots=None, **kwargs)
662653

663654
def reset(self):
664655
"""Reset/initialize the device by initializing the backend and engine, and allocating qubits."""

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
projectq>=0.5.1
2-
pennylane>=0.11
2+
git+https://github.com/PennyLaneAI/pennylane.git
33
pybind11

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
version = f.readlines()[-1].split()[-1].strip("\"'") # pylint: disable=invalid-name
2020

2121

22-
requirements = ["projectq>=0.5.1", "pennylane>=0.11"] # pylint: disable=invalid-name
22+
requirements = [
23+
"projectq>=0.5.1",
24+
"pennylane @ git+https://github.com/PennyLaneAI/pennylane.git@master"
25+
] # pylint: disable=invalid-name
2326

2427

2528
info = { # pylint: disable=invalid-name

tests/test_compare_with_default_qubit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ def circuit():
134134
operation_class(*operation_pars, wires=operation_wires)
135135
return qml.expval(observable_class(*observable_pars, wires=observable_wires))
136136

137-
output = circuit()
137+
try:
138+
output = circuit()
139+
except IgnoreOperationException:
140+
continue
141+
138142
if (operation, observable) not in outputs:
139143
outputs[(operation, observable)] = {}
140144

0 commit comments

Comments
 (0)