Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop python 3.8 support #639

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ runs:
if [ "${{ inputs.event-name }}" == "schedule" ] || [ "${{ inputs.run-slow }}" == "true" ]; then
export QISKIT_TESTS="run_slow"
fi
if [ "${{ inputs.os }}" == "ubuntu-latest" ] && [ "${{ inputs.python-version }}" == "3.8" ]; then
if [ "${{ inputs.os }}" == "ubuntu-latest" ] && [ "${{ inputs.python-version }}" == "3.9" ]; then
export PYTHON="coverage3 run --source qiskit_optimization --parallel-mode"
fi
stestr --test-path test run 2> >(tee /dev/stderr out.txt > /dev/null)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
id-token: write
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: [3.9]
steps:
- uses: actions/checkout@v4
with:
Expand Down
34 changes: 15 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: [3.9]
steps:
- name: Print Concurrency Group
env:
Expand Down Expand Up @@ -119,14 +119,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9, '3.10', 3.11, 3.12]
python-version: [3.9, '3.10', 3.11, 3.12]
include:
- os: macos-latest
python-version: 3.8
python-version: 3.9
- os: macos-latest
python-version: 3.11
- os: windows-latest
python-version: 3.8
python-version: 3.9
- os: windows-latest
python-version: 3.11
steps:
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
fi
coverage3 combine
mv .coverage ./ci-artifact-data/opt.dat
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == 3.8 }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == 3.9 }}
shell: bash
- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.11]
python-version: [3.9, 3.11]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -290,30 +290,26 @@ jobs:
cd docs/_build/html
mkdir artifacts
tar -zcvf artifacts/tutorials.tar.gz --exclude=./artifacts .
if: ${{ matrix.python-version == 3.8 && !startsWith(github.ref, 'refs/heads/stable') && !startsWith(github.base_ref, 'stable/') }}
if: ${{ matrix.python-version == 3.9 && !startsWith(github.ref, 'refs/heads/stable') && !startsWith(github.base_ref, 'stable/') }}
shell: bash
- name: Run upload stable tutorials
uses: actions/upload-artifact@v4
with:
name: tutorials-stable${{ matrix.python-version }}
path: docs/_build/html/artifacts/tutorials.tar.gz
if: ${{ matrix.python-version == 3.8 && !startsWith(github.ref, 'refs/heads/stable') && !startsWith(github.base_ref, 'stable/') }}
if: ${{ matrix.python-version == 3.9 && !startsWith(github.ref, 'refs/heads/stable') && !startsWith(github.base_ref, 'stable/') }}
Deprecation_Messages_and_Coverage:
if: github.repository_owner == 'qiskit-community'
needs: [Checks, Optimization, Tutorials]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: ubuntu-latest-3.8
path: /tmp/o38
- uses: actions/download-artifact@v4
with:
name: ubuntu-latest-3.9
Expand All @@ -332,16 +328,16 @@ jobs:
path: /tmp/o312
- uses: actions/download-artifact@v4
with:
name: macos-latest-3.8
path: /tmp/m38
name: macos-latest-3.9
path: /tmp/m39
- uses: actions/download-artifact@v4
with:
name: macos-latest-3.11
path: /tmp/m311
- uses: actions/download-artifact@v4
with:
name: windows-latest-3.8
path: /tmp/w38
name: windows-latest-3.9
path: /tmp/w39
- uses: actions/download-artifact@v4
with:
name: windows-latest-3.11
Expand All @@ -351,10 +347,10 @@ jobs:
shell: bash
- name: Combined Deprecation Messages
run: |
sort -f -u /tmp/o38/opt.dep /tmp/o39/opt.dep /tmp/o310/opt.dep /tmp/o311/opt.dep /tmp/o312/opt.dep /tmp/m38/opt.dep /tmp/m311/opt.dep /tmp/w38/opt.dep /tmp/w311/opt.dep || true
sort -f -u /tmp/o39/opt.dep /tmp/o310/opt.dep /tmp/o311/opt.dep /tmp/o312/opt.dep /tmp/m39/opt.dep /tmp/m311/opt.dep /tmp/w39/opt.dep /tmp/w311/opt.dep || true
shell: bash
- name: Coverage combine
run: coverage3 combine /tmp/o38/opt.dat
run: coverage3 combine /tmp/o39/opt.dat
shell: bash
- name: Upload to Coveralls
env:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 100
target-version = ['py38', 'py39', 'py310', 'py311']
target-version = ['py39', 'py310', 'py311', 'py312']
4 changes: 3 additions & 1 deletion qiskit_optimization/algorithms/optimization_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def __init__( # pylint: disable=too-many-positional-arguments
f"variables: size {len(variables)} {[v.name for v in variables]}"
)
self._x = np.asarray(x)
self._variables_dict = dict(zip(self._variable_names, self._x))
self._variables_dict = {
name: val.item() for name, val in zip(self._variable_names, self._x)
}

self._fval = fval
self._raw_results = raw_results
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -72,7 +71,7 @@
packages=setuptools.find_packages(include=["qiskit_optimization", "qiskit_optimization.*"]),
install_requires=REQUIREMENTS,
include_package_data=True,
python_requires=">=3.8",
python_requires=">=3.9",
extras_require={
"cplex": ["cplex; python_version < '3.12' and platform_machine != 'arm64'"],
"cvx": ["cvxpy"],
Expand Down
16 changes: 9 additions & 7 deletions test/problems/test_quadratic_program.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2020, 2023.
# (C) Copyright IBM 2020, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -857,18 +857,20 @@ def test_write_to_lp_file(self):
with tempfile.TemporaryDirectory() as tmp:
temp_output_path = path.join(tmp, "temp.lp")
q_p.write_to_lp_file(temp_output_path)
with open(reference_file_name, encoding="utf8") as reference, open(
temp_output_path, encoding="utf8"
) as temp_output_file:
with (
open(reference_file_name, encoding="utf8") as reference,
open(temp_output_path, encoding="utf8") as temp_output_file,
):
lines1 = temp_output_file.readlines()
lines2 = reference.readlines()
self.assertListEqual(lines1, lines2)

with tempfile.TemporaryDirectory() as temp_problem_dir:
q_p.write_to_lp_file(temp_problem_dir)
with open(path.join(temp_problem_dir, "my_problem.lp"), encoding="utf8") as file1, open(
reference_file_name, encoding="utf8"
) as file2:
with (
open(path.join(temp_problem_dir, "my_problem.lp"), encoding="utf8") as file1,
open(reference_file_name, encoding="utf8") as file2,
):
lines1 = file1.readlines()
lines2 = file2.readlines()
self.assertListEqual(lines1, lines2)
Expand Down
32 changes: 19 additions & 13 deletions test/translators/test_prettyprint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2022, 2023.
# (C) Copyright IBM 2022, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -495,43 +495,49 @@ def test_error(self):
q_p = QuadraticProgram(name)
_ = q_p.prettyprint()

with self.subTest("linear variable name - func"), self.assertRaises(
QiskitOptimizationError
with (
self.subTest("linear variable name - func"),
self.assertRaises(QiskitOptimizationError),
):
q_p = QuadraticProgram()
q_p.binary_var(name)
_ = prettyprint(q_p)

with self.subTest("linear variable name - meth"), self.assertRaises(
QiskitOptimizationError
with (
self.subTest("linear variable name - meth"),
self.assertRaises(QiskitOptimizationError),
):
q_p = QuadraticProgram()
q_p.binary_var(name)
_ = q_p.prettyprint()

with self.subTest("linear constraint name - func"), self.assertRaises(
QiskitOptimizationError
with (
self.subTest("linear constraint name - func"),
self.assertRaises(QiskitOptimizationError),
):
q_p = QuadraticProgram()
q_p.linear_constraint(name=name)
_ = prettyprint(q_p)

with self.subTest("linear constraint name - meth"), self.assertRaises(
QiskitOptimizationError
with (
self.subTest("linear constraint name - meth"),
self.assertRaises(QiskitOptimizationError),
):
q_p = QuadraticProgram()
q_p.linear_constraint(name=name)
_ = q_p.prettyprint()

with self.subTest("quadratic constraint name - func"), self.assertRaises(
QiskitOptimizationError
with (
self.subTest("quadratic constraint name - func"),
self.assertRaises(QiskitOptimizationError),
):
q_p = QuadraticProgram()
q_p.quadratic_constraint(name=name)
_ = prettyprint(q_p)

with self.subTest("quadratic constraint name - meth"), self.assertRaises(
QiskitOptimizationError
with (
self.subTest("quadratic constraint name - meth"),
self.assertRaises(QiskitOptimizationError),
):
q_p = QuadraticProgram()
q_p.quadratic_constraint(name=name)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 3.3.0
envlist = py38, py39, py310, py311, py312, lint
envlist = py39, py310, py311, py312, lint
skipsdist = True

[testenv]
Expand Down