Browse code

Upgrade requirements to Python 3.8

Joseph Weston authored on 13/09/2021 02:02:38
Showing 5 changed files
... ...
@@ -9,7 +9,7 @@ jobs:
9 9
             max-parallel: 4
10 10
             matrix:
11 11
                 os: [ubuntu-latest, macos-latest, windows-latest]
12
-                python-version: [3.6, 3.7]
12
+                python-version: [3.8, 3.9]
13 13
         steps:
14 14
             - uses: actions/checkout@v1
15 15
             - shell: bash
... ...
@@ -3,7 +3,7 @@ repos:
3 3
     rev: 19.3b0
4 4
     hooks:
5 5
     - id: black
6
-      language_version: python3.7
6
+      language_version: python3.8
7 7
 -   repo: https://github.com/pre-commit/pre-commit-hooks
8 8
     rev: v2.1.0
9 9
     hooks:
... ...
@@ -17,8 +17,8 @@ classifiers = [
17 17
     "Intended Audience :: Science/Research",
18 18
     "Topic :: Scientific/Engineering",
19 19
     "Topic :: Scientific/Engineering :: Physics",
20
-    "Programming Language :: Python :: 3.6",
21
-    "Programming Language :: Python :: 3.7",
20
+    "Programming Language :: Python :: 3.8",
21
+    "Programming Language :: Python :: 3.9",
22 22
 ]
23 23
 requires = [
24 24
     "numpy",
... ...
@@ -34,6 +34,7 @@ test = [
34 34
     "hypothesis[numpy]",
35 35
     "tox",
36 36
     "flake8-per-file-ignores",
37
+    "flake8>=3.7.2",  # https://github.com/pycqa/flake8/issues/668
37 38
 ]
38 39
 docs = [
39 40
     "sphinx",
... ...
@@ -21,7 +21,9 @@ def select_n_qubits(gate_size):
21 21
     def _strat(n_qubits):
22 22
         assert n_qubits >= gate_size
23 23
         possible_qubits = st.integers(0, n_qubits - 1)
24
-        return st.lists(possible_qubits, gate_size, gate_size, unique=True).map(tuple)
24
+        return st.lists(
25
+            possible_qubits, min_size=gate_size, max_size=gate_size, unique=True
26
+        ).map(tuple)
25 27
 
26 28
     return _strat
27 29
 
... ...
@@ -35,7 +37,7 @@ phases = st.floats(
35 37
 def unitary(n_qubits):
36 38
     size = 1 << n_qubits
37 39
     return (
38
-        hnp.arrays(complex, (size, size), valid_complex)
40
+        hnp.arrays(complex, (size, size), elements=valid_complex)
39 41
         .map(lambda a: np.linalg.qr(a)[0])
40 42
         .filter(lambda u: np.all(np.isfinite(u)))
41 43
     )
... ...
@@ -44,7 +46,7 @@ def unitary(n_qubits):
44 46
 def ket(n_qubits):
45 47
     size = 1 << n_qubits
46 48
     return (
47
-        hnp.arrays(complex, (size,), valid_complex)
49
+        hnp.arrays(complex, (size,), elements=valid_complex)
48 50
         .filter(lambda v: np.linalg.norm(v) > 0)  # vectors must be normalizable
49 51
         .map(lambda v: v / np.linalg.norm(v))
50 52
     )
... ...
@@ -148,7 +150,7 @@ def test_swap():
148 150
 
149 151
 @given(single_qubit_gates, n_qubits.flatmap(ket), n_qubits.flatmap(select_n_qubits(1)))
150 152
 def test_applying_single_gates(gate, state, selected):
151
-    qubit, = selected
153
+    (qubit,) = selected
152 154
     n_qubits = state.shape[0].bit_length() - 1
153 155
     parts = [np.identity(2)] * n_qubits
154 156
     parts[qubit] = gate
... ...
@@ -1,11 +1,11 @@
1 1
 [tox]
2 2
 isolated_build = True
3
-envlist = clean,py{36,37},report
3
+envlist = clean,py{38,39},report
4 4
 
5 5
 [gh-actions]
6 6
 python =
7
-  3.6: clean,py36,report
8
-  3.7: clean,py37,report
7
+  3.8: clean,py38,report
8
+  3.9: clean,py39,report
9 9
 
10 10
 [pytest]
11 11
 addopts =
... ...
@@ -38,8 +38,8 @@ output = .coverage.xml
38 38
 deps = .[test]
39 39
 commands = pytest
40 40
 depends =
41
-  {py36,py37}: clean
42
-  report: {py36,py37}
41
+  {py38,py39}: clean
42
+  report: {py38,py39}
43 43
 
44 44
 [testenv:report]
45 45
 deps = coverage