Skip to content

Commit 435517b

Browse files
authored
Merge pull request #54 from ChitambarLab/pennylane-update-33
Pennylane update 33
2 parents 22799a4 + b12e167 commit 435517b

6 files changed

Lines changed: 23 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $ pip install qnetvo
3232
Install PennyLane:
3333

3434
```
35-
$ pip install pennylane==0.29
35+
$ pip install pennylane==0.33
3636
```
3737

3838
Import packages:
@@ -48,7 +48,7 @@ Note
4848
</p>
4949
<p>
5050
For optimal use, qNetVO should be used with PennyLane.
51-
QNetVO is currently compatible with PennyLane v0.29.
51+
QNetVO is currently compatible with PennyLane v0.33.
5252
</p>
5353
</div>
5454

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: qnetvo-dev
22
channels:
33
- defaults
44
dependencies:
5-
- python=3.8
5+
- python=3.11
66
- black
77
- sphinx
88
- pytest

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pennylane~=0.29
1+
pennylane~=0.33
22
qiskit==0.34
33
pennylane-qiskit==0.20
44
tensorflow>=2.0,<3.0

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = qNetVO
3-
version = 0.4.3
3+
version = 0.4.4
44
author = Brian Doolittle and Tom Bromley
55
author_email = brian.d.doolittle@gmail.com
66
description = The Quantum Network Variational Optimizer
@@ -20,7 +20,7 @@ package_dir =
2020
packages = find:
2121
python_requires = >=3.8
2222
install_requires =
23-
pennylane~=0.29
23+
pennylane~=0.33
2424

2525
[options.packages.find]
2626
where = src

src/qnetvo/information.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,7 @@ def shannon_entropy(probs):
9797
:rtype: float
9898
"""
9999
return -(
100-
math.sum([px * math.log2(px) if px != 0 and not (np.isclose(px, 0)) else 0 for px in probs])
100+
math.sum(
101+
[px * math.log2(px) if px != 0 and not (math.isclose(px, 0)) else 0 for px in probs]
102+
)
101103
)

test/cost/mutual_info_test.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,26 @@ class TestShannonEntropy:
8383
def test_shannon_entropy_pure_state(self):
8484
np.random.seed(123)
8585

86-
prep_node = [qnet.PrepareNode(1, [0, 1], qnet.ghz_state, 0)]
87-
meas_node = [qnet.MeasureNode(1, 4, [0, 1], qml.ArbitraryUnitary, 4**2 - 1)]
86+
def test_meas_circ(settings, wires):
87+
qml.CNOT(wires=wires[0:2])
88+
qml.RZ(settings[0], wires=wires[0])
89+
qml.RY(settings[1], wires=wires[0])
90+
91+
prep_node = [qnet.PrepareNode(wires=[0, 1], ansatz_fn=qnet.ghz_state)]
92+
meas_node = [
93+
qnet.MeasureNode(num_out=4, wires=[0, 1], ansatz_fn=test_meas_circ, num_settings=2)
94+
]
8895

8996
ansatz = qnet.NetworkAnsatz(prep_node, meas_node)
9097
shannon_entropy = qnet.shannon_entropy_cost_fn(ansatz)
9198

9299
settings = ansatz.rand_network_settings()
93100
opt_dict = qnet.gradient_descent(
94-
shannon_entropy, settings, step_size=0.08, sample_width=5, num_steps=30
101+
shannon_entropy,
102+
settings,
103+
step_size=0.15,
104+
sample_width=5,
105+
num_steps=35,
95106
)
96107

97108
assert np.isclose(opt_dict["scores"][-1], 0, atol=0.0005)

0 commit comments

Comments
 (0)