Skip to content

Commit 20e50c2

Browse files
authored
Merge pull request #31 from OpenQuantumComputing/tests
tests and doi fix
2 parents 81bb646 + 45d71e8 commit 20e50c2

File tree

7 files changed

+54
-5
lines changed

7 files changed

+54
-5
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Thank you for considering contributing! We welcome all kinds of contributions—
55
---
66

77
## How to Contribute
8-
Feel free to submit a "pull request" on GitHub in a designated feature branch. Include comments about what the fix/update does.
8+
Feel free to submit a "pull request" on GitHub in a designated feature branch. Include comments about what the fix/update does, and ensure the tests work by running:
9+
```python
10+
states = res.run(timeseries)
11+
```
912

1013
For new features, please also consider updating the examples folder to show the intended use of the feature.
1114

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ This will return a `np.ndarray` of the same length as the timeseries, correspond
101101

102102
`Incremental` reservoirs run incrementally. For every state, only the last `M` steps of the timeseries is built at a time (`M` being a parameter of `Incremental.__init__`).
103103

104+
## Testing
105+
Some tests have been implemented using pytest. To run them, ensure pytest is installed (*not* installed as runtime dependency) and run
106+
```python
107+
pytest
108+
```
104109
## About
105110

106111
You can find out more about QuantumReservoirPy and contact the authors [here](https://quantumreservoirpy.readthedocs.io/en/latest/about/).

paper.bib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ @InProceedings{trouvain20
1616
and Pedrelli, Luca
1717
and Dinh, Thanh Trung
1818
and Hinaut, Xavier",
19+
doi = {10.1007/978-3-030-61616-8_40},
1920
editor="Farka{\v{s}}, Igor
2021
and Masulli, Paolo
2122
and Wermter, Stefan",

paper.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ The processing methods do not affect the creation of the reservoirs, but are inc
7878

7979
## Dependencies
8080

81-
The three main dependencies of `QuantumReservoirPy` are numpy, qiskit, and scikit-learn.
82-
We strive for `QuantumReservoirPy` to support compatibility with existing reservoir computing and quantum computing workflows.
81+
The three main dependencies of `QuantumReservoirPy` are numpy, qiskit, and scikit-learn, with python versions above 3.9. Qiskit is [deprecating](https://github.com/Qiskit/qiskit/releases) python 3.9 support in the 2.1.0 version, and the package presented here is developed to support qiskit=2.0.x. As for the other packages, the supported versions of scikit-learn and numpy follows from their interrelated constraints as well as the constraint from qiskit. In the install script, we specify numpy>1.17. We strive for `QuantumReservoirPy` to support compatibility with existing reservoir computing and quantum computing workflows.
8382

8483
Much of existing research in QRC is performed on IBM devices and simulators (see [@yasuda23; @suzuki22]), programmed through the Qiskit software package. To minimize disruption in current workflows, `QuantumReservoirPy` is built as a package to interact with Qiskit circuits and backends. It is expected that the user also use Qiskit in the customization of reservoir architecture when working with `QuantumReservoirPy`.
8584

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"matplotlib",
55
"tqdm",
66
"pylatexenc>=2.0",
7-
"qiskit>=1.0",
7+
"qiskit<2.1.0",
88
"qiskit-aer>=0.12.0",
9-
"numpy>=1.21.6",
9+
"numpy>=1.17",
1010
"scikit-learn",
1111
"ipykernel"
1212
]

tests/test_imports.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def test_import_main():
2+
import quantumreservoirpy
3+
4+
def test_import_submodules():
5+
from quantumreservoirpy import music
6+
from quantumreservoirpy import reservoirs
7+
from quantumreservoirpy import plot

tests/test_run.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
3+
def test_incremental():
4+
import numpy as np
5+
from qiskit.quantum_info import random_unitary
6+
from quantumreservoirpy.reservoirs import Incremental
7+
8+
encoder = {0: "00", 1: "01", 2: "10", 3: "11"}
9+
SHOTS = 100
10+
11+
12+
class RandomUnitary(Incremental):
13+
def __init__(self, n_qubits, memory=np.inf, backend=None, num_features=8) -> None:
14+
super().__init__(n_qubits, memory, backend, num_features)
15+
self.operator = random_unitary(2**n_qubits)
16+
17+
def before(self, circuit):
18+
circuit.h(circuit.qubits)
19+
20+
def during(self, circuit, timestep, reservoirnumber):
21+
circuit.measure([0, 1])
22+
circuit.initialize(encoder[timestep], [0, 1])
23+
circuit.append(self.operator, circuit.qubits)
24+
25+
def after(self, circuit):
26+
circuit.measure_all()
27+
28+
29+
res = RandomUnitary(n_qubits=4, memory=8)
30+
31+
timestep = [0, 1, 2, 3, 0, 1, 2, 2, 3]
32+
timeseries = timestep * 10
33+
34+
res.run(timeseries, shots=SHOTS)

0 commit comments

Comments
 (0)