Skip to content

Commit efcc216

Browse files
committed
Add support for Python 3.11
1 parent 2542b76 commit efcc216

File tree

10 files changed

+30
-67
lines changed

10 files changed

+30
-67
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ jobs:
7070
pip install pyenchant
7171
echo "earliest_version: 0.1.0" >> releasenotes/config.yaml
7272
shell: bash
73-
- run: pip check
73+
- run: pip check
7474
if: ${{ !cancelled() }}
7575
shell: bash
7676
- name: Copyright Check
7777
run: |
7878
python tools/check_copyright.py -check
7979
if: ${{ !cancelled() }}
8080
shell: bash
81-
- run: make spell
81+
- run: make spell
8282
if: ${{ !cancelled() }}
8383
shell: bash
8484
- name: Style Check
@@ -88,7 +88,7 @@ jobs:
8888
if: ${{ !cancelled() }}
8989
shell: bash
9090
- name: Run make html
91-
run: |
91+
run: |
9292
make clean_sphinx
9393
make html
9494
cd docs/_build/html
@@ -102,7 +102,7 @@ jobs:
102102
name: documentation
103103
path: docs/_build/html/artifacts/documentation.tar.gz
104104
if: ${{ !cancelled() }}
105-
- run: make doctest
105+
- run: make doctest
106106
if: ${{ !cancelled() }}
107107
shell: bash
108108
MachineLearning:
@@ -111,16 +111,20 @@ jobs:
111111
fail-fast: false
112112
matrix:
113113
os: [ubuntu-latest]
114-
python-version: [3.7, 3.8, 3.9, '3.10']
114+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
115115
include:
116116
- os: macos-latest
117117
python-version: 3.8
118118
- os: macos-latest
119119
python-version: '3.10'
120+
- os: macos-latest
121+
python-version: 3.11
120122
- os: windows-2019
121123
python-version: 3.8
122124
- os: windows-2019
123125
python-version: '3.10'
126+
- os: windows-2019
127+
python-version: 3.11
124128
steps:
125129
- uses: actions/checkout@v3
126130
- uses: actions/setup-python@v4
@@ -142,11 +146,6 @@ jobs:
142146
- run: make mypy
143147
if: ${{ !cancelled() && matrix.python-version != '3.10' }}
144148
shell: bash
145-
- name: Run make lint latest version
146-
run: |
147-
pip install -U -r requirements-dev.txt
148-
make lint
149-
shell: bash
150149
- name: Machine Learning Unit Tests under Python ${{ matrix.python-version }}
151150
uses: ./.github/actions/run-tests
152151
with:

.pylintrc

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ confidence=
5858
# --enable=similarities". If you want to run only the classes checker, but have
5959
# no Warning level messages displayed, use"--disable=all --enable=classes
6060
# --disable=W"
61-
disable=no-self-use, # disabled as it is too verbose
62-
fixme, # disabled as TODOs would show up as warnings
61+
disable=fixme, # disabled as TODOs would show up as warnings
6362
protected-access, # disabled as we don't follow the public vs private
6463
# convention strictly
6564
duplicate-code, # disabled as it is too verbose
@@ -72,9 +71,6 @@ disable=no-self-use, # disabled as it is too verbose
7271
no-else-return, # relax "elif" after a clause with a return
7372
docstring-first-line-empty, # relax docstring style
7473
import-outside-toplevel,
75-
bad-continuation, bad-whitespace, # differences of opinion with black
76-
77-
7874

7975

8076
[REPORTS]
@@ -84,12 +80,6 @@ disable=no-self-use, # disabled as it is too verbose
8480
# mypackage.mymodule.MyReporterClass.
8581
output-format=text
8682

87-
# Put messages in a separate file for each module / package specified on the
88-
# command line instead of printing them on stdout. Reports (if any) will be
89-
# written in a file name "pylint_global.[txt|html]". This option is deprecated
90-
# and it will be removed in Pylint 2.0.
91-
files-output=no
92-
9383
# Tells whether to display a full report or only the messages
9484
reports=yes
9585

@@ -138,63 +128,33 @@ property-classes=abc.abstractproperty
138128
# Regular expression matching correct module names
139129
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
140130

141-
# Naming hint for module names
142-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
143-
144131
# Regular expression matching correct constant names
145132
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
146133

147-
# Naming hint for constant names
148-
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
149-
150134
# Regular expression matching correct class names
151135
class-rgx=[A-Z_][a-zA-Z0-9]+$
152136

153-
# Naming hint for class names
154-
class-name-hint=[A-Z_][a-zA-Z0-9]+$
155-
156137
# Regular expression matching correct function names
157138
function-rgx=[a-z_][a-z0-9_]{2,30}$
158139

159-
# Naming hint for function names
160-
function-name-hint=[a-z_][a-z0-9_]{2,30}$
161-
162140
# Regular expression matching correct method names
163141
method-rgx=(([a-z_][a-z0-9_]{2,49})|(assert[A-Z][a-zA-Z0-9]{2,43})|(test_[_a-zA-Z0-9]{2,}))$
164142

165-
# Naming hint for method names
166-
method-name-hint=[a-z_][a-z0-9_]{2,30}$ or camelCase `assert*` in tests.
167-
168143
# Regular expression matching correct attribute names
169144
attr-rgx=[a-z_][a-z0-9_]{2,30}$
170145

171-
# Naming hint for attribute names
172-
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
173-
174146
# Regular expression matching correct argument names
175147
argument-rgx=[a-z_][a-z0-9_]{2,30}|ax|dt$
176148

177-
# Naming hint for argument names
178-
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
179-
180149
# Regular expression matching correct variable names
181150
variable-rgx=[a-z_][a-z0-9_]{2,30}$
182151

183-
# Naming hint for variable names
184-
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
185-
186152
# Regular expression matching correct class attribute names
187153
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
188154

189-
# Naming hint for class attribute names
190-
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
191-
192155
# Regular expression matching correct inline iteration names
193156
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
194157

195-
# Naming hint for inline iteration names
196-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
197-
198158
# Regular expression which should only match function or class names that do
199159
# not require a docstring.
200160
no-docstring-rgx=^_
@@ -222,12 +182,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
222182
# else.
223183
single-line-if-stmt=no
224184

225-
# List of optional constructs for which whitespace checking is disabled. `dict-
226-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
227-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
228-
# `empty-line` allows space-only lines.
229-
no-space-check=trailing-comma,dict-separator
230-
231185
# Maximum number of lines in a module
232186
max-module-lines=1000
233187

constraints.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
astroid==2.5.6
2-
pylint==2.8.3
31
numpy>=1.20.0

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tool.black]
22
line-length = 100
3-
target-version = ['py37', 'py38', 'py39', 'py310']
3+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
upgrade:
3+
- |
4+
Added support for running with Python 3.11.
5+
At the the time of the release, Sparse didn't have a python 3.11 version.

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ coverage>=4.4.0
22
matplotlib>=2.1
33
seaborn
44
black[jupyter]~=22.0
5-
pylint>=2.8.3,<2.14.0
5+
pylint>=2.15.0
66
pylatexenc>=1.4
77
stestr>=2.0.0
88
ddt>=1.2.0,!=1.4.0
@@ -14,7 +14,7 @@ sphinx-autodoc-typehints<1.14.0
1414
sphinxcontrib-spelling
1515
jupyter-sphinx
1616
discover
17-
qiskit-aer>=0.11
17+
qiskit-aer>=0.11.2
1818
mypy>=0.981
1919
mypy-extensions>=0.4.3
2020
nbsphinx

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
qiskit-terra>=0.22
1+
qiskit-terra>=0.22.2
22
scipy>=1.4
33
numpy>=1.17
44
psutil>=5

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"Programming Language :: Python :: 3.8",
6262
"Programming Language :: Python :: 3.9",
6363
"Programming Language :: Python :: 3.10",
64+
"Programming Language :: Python :: 3.11",
6465
"Topic :: Scientific/Engineering"
6566
],
6667
keywords='qiskit sdk quantum machine learning ml',
@@ -70,7 +71,7 @@
7071
python_requires=">=3.7",
7172
extras_require={
7273
'torch': ["torch; python_version < '3.10'"],
73-
'sparse': ["sparse"],
74+
'sparse': ["sparse;python_version < '3.11'"],
7475
},
7576
zip_safe=False
7677
)

test/connectors/test_torch_networks.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ def forward(self, x):
6060
return Net()
6161

6262
def _create_circuit_qnn(self) -> CircuitQNN:
63-
output_shape, interpret = 2, lambda x: f"{x:b}".count("1") % 2
63+
output_shape = 2
6464
num_inputs = 2
6565

66+
def interpret(x):
67+
return f"{x:b}".count("1") % 2
68+
6669
feature_map = ZZFeatureMap(num_inputs)
6770
ansatz = RealAmplitudes(num_inputs, entanglement="linear", reps=1)
6871

@@ -111,9 +114,12 @@ def _create_estimator_qnn(self) -> EstimatorQNN:
111114
return qnn
112115

113116
def _create_sampler_qnn(self) -> SamplerQNN:
114-
output_shape, interpret = 2, lambda x: f"{x:b}".count("1") % 2
117+
output_shape = 2
115118
num_inputs = 2
116119

120+
def interpret(x):
121+
return f"{x:b}".count("1") % 2
122+
117123
feature_map = ZZFeatureMap(num_inputs)
118124
ansatz = RealAmplitudes(num_inputs, entanglement="linear", reps=1)
119125

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 3.17
3-
envlist = py37, py38, py39, py310, lint, gpu, gpu-amd
3+
envlist = py37, py38, py39, py310, py311, lint, gpu, gpu-amd
44
skipsdist = True
55

66
[testenv]

0 commit comments

Comments
 (0)