diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09c2ca072..893a6be81 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,7 +70,7 @@ jobs: pip install pyenchant echo "earliest_version: 0.1.0" >> releasenotes/config.yaml shell: bash - - run: pip check + - run: pip check if: ${{ !cancelled() }} shell: bash - name: Copyright Check @@ -78,7 +78,7 @@ jobs: python tools/check_copyright.py -check if: ${{ !cancelled() }} shell: bash - - run: make spell + - run: make spell if: ${{ !cancelled() }} shell: bash - name: Style Check @@ -88,7 +88,7 @@ jobs: if: ${{ !cancelled() }} shell: bash - name: Run make html - run: | + run: | make clean_sphinx make html cd docs/_build/html @@ -102,7 +102,7 @@ jobs: name: documentation path: docs/_build/html/artifacts/documentation.tar.gz if: ${{ !cancelled() }} - - run: make doctest + - run: make doctest if: ${{ !cancelled() }} shell: bash MachineLearning: @@ -111,16 +111,20 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.7, 3.8, 3.9, '3.10'] + python-version: [3.7, 3.8, 3.9, '3.10', 3.11] include: - os: macos-latest python-version: 3.8 - os: macos-latest python-version: '3.10' + - os: macos-latest + python-version: 3.11 - os: windows-2019 python-version: 3.8 - os: windows-2019 python-version: '3.10' + - os: windows-2019 + python-version: 3.11 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -142,11 +146,6 @@ jobs: - run: make mypy if: ${{ !cancelled() && matrix.python-version != '3.10' }} shell: bash - - name: Run make lint latest version - run: | - pip install -U -r requirements-dev.txt - make lint - shell: bash - name: Machine Learning Unit Tests under Python ${{ matrix.python-version }} uses: ./.github/actions/run-tests with: diff --git a/.pylintrc b/.pylintrc index cc3077ebc..04eb1f55d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -58,8 +58,7 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=no-self-use, # disabled as it is too verbose - fixme, # disabled as TODOs would show up as warnings +disable=fixme, # disabled as TODOs would show up as warnings protected-access, # disabled as we don't follow the public vs private # convention strictly duplicate-code, # disabled as it is too verbose @@ -72,9 +71,6 @@ disable=no-self-use, # disabled as it is too verbose no-else-return, # relax "elif" after a clause with a return docstring-first-line-empty, # relax docstring style import-outside-toplevel, - bad-continuation, bad-whitespace, # differences of opinion with black - - [REPORTS] @@ -84,12 +80,6 @@ disable=no-self-use, # disabled as it is too verbose # mypackage.mymodule.MyReporterClass. output-format=text -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". This option is deprecated -# and it will be removed in Pylint 2.0. -files-output=no - # Tells whether to display a full report or only the messages reports=yes @@ -138,63 +128,33 @@ property-classes=abc.abstractproperty # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct constant names const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct class names class-rgx=[A-Z_][a-zA-Z0-9]+$ -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - # Regular expression matching correct function names function-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for function names -function-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct method names method-rgx=(([a-z_][a-z0-9_]{2,49})|(assert[A-Z][a-zA-Z0-9]{2,43})|(test_[_a-zA-Z0-9]{2,}))$ -# Naming hint for method names -method-name-hint=[a-z_][a-z0-9_]{2,30}$ or camelCase `assert*` in tests. - # Regular expression matching correct attribute names attr-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for attribute names -attr-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct argument names argument-rgx=[a-z_][a-z0-9_]{2,30}|ax|dt$ -# Naming hint for argument names -argument-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct variable names variable-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for variable names -variable-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression which should only match function or class names that do # not require a docstring. no-docstring-rgx=^_ @@ -222,12 +182,6 @@ ignore-long-lines=^\s*(# )??$ # else. single-line-if-stmt=no -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Maximum number of lines in a module max-module-lines=1000 diff --git a/constraints.txt b/constraints.txt index 8448ac45c..bba3992ca 100644 --- a/constraints.txt +++ b/constraints.txt @@ -1,3 +1 @@ -astroid==2.5.6 -pylint==2.8.3 numpy>=1.20.0 diff --git a/pyproject.toml b/pyproject.toml index e7cd3e370..afa1ba679 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.black] line-length = 100 -target-version = ['py37', 'py38', 'py39', 'py310'] \ No newline at end of file +target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] diff --git a/releasenotes/notes/add-python311-support-5b71a67a07606405.yaml b/releasenotes/notes/add-python311-support-5b71a67a07606405.yaml new file mode 100644 index 000000000..157791e51 --- /dev/null +++ b/releasenotes/notes/add-python311-support-5b71a67a07606405.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Added support for running with Python 3.11. + At the the time of the release, Sparse didn't have a python 3.11 version. diff --git a/requirements-dev.txt b/requirements-dev.txt index 7b8b459fd..15d24d792 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ coverage>=4.4.0 matplotlib>=2.1 seaborn black[jupyter]~=22.0 -pylint>=2.8.3,<2.14.0 +pylint>=2.15.0 pylatexenc>=1.4 stestr>=2.0.0 ddt>=1.2.0,!=1.4.0 @@ -14,7 +14,7 @@ sphinx-autodoc-typehints<1.14.0 sphinxcontrib-spelling jupyter-sphinx discover -qiskit-aer>=0.11 +qiskit-aer>=0.11.2 mypy>=0.981 mypy-extensions>=0.4.3 nbsphinx diff --git a/requirements.txt b/requirements.txt index f36cb519c..80af3205c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -qiskit-terra>=0.22 +qiskit-terra>=0.22.2 scipy>=1.4 numpy>=1.17 psutil>=5 diff --git a/setup.py b/setup.py index d8ce1af23..e0a7f6805 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Scientific/Engineering" ], keywords='qiskit sdk quantum machine learning ml', @@ -70,7 +71,7 @@ python_requires=">=3.7", extras_require={ 'torch': ["torch; python_version < '3.10'"], - 'sparse': ["sparse"], + 'sparse': ["sparse;python_version < '3.11'"], }, zip_safe=False ) diff --git a/test/connectors/test_torch_networks.py b/test/connectors/test_torch_networks.py index 867fd5285..a0140bee9 100644 --- a/test/connectors/test_torch_networks.py +++ b/test/connectors/test_torch_networks.py @@ -60,9 +60,12 @@ def forward(self, x): return Net() def _create_circuit_qnn(self) -> CircuitQNN: - output_shape, interpret = 2, lambda x: f"{x:b}".count("1") % 2 + output_shape = 2 num_inputs = 2 + def interpret(x): + return f"{x:b}".count("1") % 2 + feature_map = ZZFeatureMap(num_inputs) ansatz = RealAmplitudes(num_inputs, entanglement="linear", reps=1) @@ -111,9 +114,12 @@ def _create_estimator_qnn(self) -> EstimatorQNN: return qnn def _create_sampler_qnn(self) -> SamplerQNN: - output_shape, interpret = 2, lambda x: f"{x:b}".count("1") % 2 + output_shape = 2 num_inputs = 2 + def interpret(x): + return f"{x:b}".count("1") % 2 + feature_map = ZZFeatureMap(num_inputs) ansatz = RealAmplitudes(num_inputs, entanglement="linear", reps=1) diff --git a/tox.ini b/tox.ini index 1a2f41ba2..69fc6b1d3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.17 -envlist = py37, py38, py39, py310, lint, gpu, gpu-amd +envlist = py37, py38, py39, py310, py311, lint, gpu, gpu-amd skipsdist = True [testenv]