From ca14bfd2bdd5896b7b4fff6e67e1c88a5056aa93 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 19 Nov 2025 10:39:43 +0100 Subject: [PATCH 01/23] release python restriction --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c5e47b8b..bcf6a9d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ dependencies = [ "tqdm>=4.1.0", "qulacs>=0.6.0", ] -requires-python = ">=3.9,<3.13" +requires-python = ">=3.9" dynamic = ["version", "description"] [project.optional-dependencies] From 59137d434c9479fbbcca01b67b068abd55200fdd Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 19 Nov 2025 10:39:54 +0100 Subject: [PATCH 02/23] update workflow files --- .github/workflows/doc_checks.yml | 11 +++++-- .github/workflows/format.yml | 16 ++++++---- .github/workflows/publish.yml | 4 +-- .github/workflows/publish_docs.yml | 4 +-- .github/workflows/tests.yaml | 49 +++++++++++++++++++----------- 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/.github/workflows/doc_checks.yml b/.github/workflows/doc_checks.yml index c7b51470..29209fb8 100644 --- a/.github/workflows/doc_checks.yml +++ b/.github/workflows/doc_checks.yml @@ -2,6 +2,13 @@ name: Documentation check on: - pull_request +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: doc_checks: runs-on: ubuntu-latest @@ -9,10 +16,8 @@ jobs: QISKIT_SETTINGS: ${{github.workspace}}/docs/qiskit_settings.conf steps: - - name: Cancel Workflow Action - uses: styfle/cancel-workflow-action@0.11.0 - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: sQUlearn/sphinx-action@master with: diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 23f3a7be..20598994 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -2,23 +2,27 @@ name: Formatting check on: - pull_request +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: black: runs-on: ubuntu-latest steps: - - name: Cancel Workflow Action - uses: styfle/cancel-workflow-action@0.11.0 - - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: - python-version: 3.9 + python-version: 3.13 - name: Install dependencies run: pip install black[jupyter] - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Run Black run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6ec40e08..105a81bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,14 +14,14 @@ jobs: id-token: write steps: - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: 3.9 - name: Install dependencies run: pip install flit - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build run: flit build diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml index 0cf92ce5..1239f70b 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -12,9 +12,9 @@ jobs: QISKIT_SETTINGS: ${{github.workspace}}/docs/qiskit_settings.conf steps: - name: Checkout Source Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Checkout GH Pages - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: sQUlearn/squlearn.github.io fetch-depth: 0 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 07b2b6e0..ddbeef29 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,14 +4,21 @@ on: schedule: - cron: '23 1 * * *' +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: pytest_minimal_requirements: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.9' - name: Install dependencies @@ -43,9 +50,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.9' - name: Install dependencies @@ -72,9 +79,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.9' - name: Install dependencies @@ -97,32 +104,40 @@ jobs: run: | rm -rf venv_qiskit_1 - pytest_latest: - runs-on: ubuntu-latest + pytest_latest: + name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: | - 3.12 + ${{ + matrix.python-version + }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m venv venv_latest source venv_latest/bin/activate - pip install .[examples] + pip install . + - name: Install old autoray + if: matrix.python-version == '3.9' + run: | + source venv_latest/bin/activate + pip install autoray==0.7.2 - name: Test with pytest run: | source venv_latest/bin/activate pip install pytest pytest tests/ - - name: Test examples - run: | - source venv_latest/bin/activate - pip install nbmake - pytest --nbmake --nbmake-timeout 600 examples/ - name: clean run: | rm -rf venv_latest From c7d80423258aa625bc076798152725f9a8a1d950 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 19 Nov 2025 10:51:58 +0100 Subject: [PATCH 03/23] move concurrency to jobs --- .github/workflows/tests.yaml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ddbeef29..92f4a597 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,14 +7,16 @@ on: permissions: contents: read -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - jobs: pytest_minimal_requirements: runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${ + (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) + }-minimal_requirements + cancel-in-progress: true + steps: - uses: actions/checkout@v5 - name: Set up Python @@ -49,6 +51,12 @@ jobs: pytest_qiskit_0_46: runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${ + (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) + }-qiskit_0_46 + cancel-in-progress: true + steps: - uses: actions/checkout@v5 - name: Set up Python @@ -78,6 +86,12 @@ jobs: pytest_qiskit_1: runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${ + (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) + }-qiskit_1 + cancel-in-progress: true + steps: - uses: actions/checkout@v5 - name: Set up Python @@ -113,6 +127,12 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + concurrency: + group: ${{ github.workflow }}-${ + (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) + }-${{ matrix.os }}-${{ matrix.python-version }} + cancel-in-progress: true + steps: - uses: actions/checkout@v5 - name: Set up Python From 77c85cbede5fa98a36116557817fd41b0965cab2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 09:49:01 +0100 Subject: [PATCH 04/23] move concurrency to toplevel --- .github/workflows/tests.yaml | 38 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 92f4a597..187a8228 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,16 +7,16 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${ + (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) + } + cancel-in-progress: true + jobs: pytest_minimal_requirements: runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }}-${ - (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) - }-minimal_requirements - cancel-in-progress: true - steps: - uses: actions/checkout@v5 - name: Set up Python @@ -51,12 +51,6 @@ jobs: pytest_qiskit_0_46: runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }}-${ - (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) - }-qiskit_0_46 - cancel-in-progress: true - steps: - uses: actions/checkout@v5 - name: Set up Python @@ -86,12 +80,6 @@ jobs: pytest_qiskit_1: runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }}-${ - (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) - }-qiskit_1 - cancel-in-progress: true - steps: - uses: actions/checkout@v5 - name: Set up Python @@ -127,12 +115,6 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - concurrency: - group: ${{ github.workflow }}-${ - (github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name) - }-${{ matrix.os }}-${{ matrix.python-version }} - cancel-in-progress: true - steps: - uses: actions/checkout@v5 - name: Set up Python @@ -161,3 +143,11 @@ jobs: - name: clean run: | rm -rf venv_latest + - name: Test examples + run: | + source venv_latest/bin/activate + pip install nbmake + pytest --nbmake --nbmake-timeout 600 examples/ + - name: clean + run: | + rm -rf venv_latest From a7bbd22a9846b202bfa05672e40e55ecf835a4be Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 09:52:15 +0100 Subject: [PATCH 05/23] proper venv usage windows --- .github/workflows/tests.yaml | 56 ++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 187a8228..eefbd6b4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -128,26 +128,58 @@ jobs: run: | python -m pip install --upgrade pip python -m venv venv_latest - source venv_latest/bin/activate - pip install . + if [ ${{ runner.os }} == 'windows-latest' ]; then + .\venv_latest\Scripts\pip.exe install . + else + source venv_latest/bin/activate + pip install . + fi + - name: Install old autoray if: matrix.python-version == '3.9' run: | - source venv_latest/bin/activate - pip install autoray==0.7.2 + if [ ${{ runner.os }} == 'windows-latest' ]; then + .\venv_latest\Scripts\pip.exe install autoray==0.7.2 + else + source venv_latest/bin/activate + pip install autoray==0.7.2 + fi + - name: Test with pytest run: | - source venv_latest/bin/activate - pip install pytest - pytest tests/ + if [ ${{ runner.os }} == 'windows-latest' ]; then + .\venv_latest\Scripts\pip.exe install pytest + .\venv_latest\Scripts\pytest.exe tests/ + else + source venv_latest/bin/activate + pip install pytest + pytest tests/ + fi + - name: clean run: | - rm -rf venv_latest + if [ ${{ runner.os }} == 'windows-latest' ]; then + rmdir /S /Q venv_latest + else + rm -rf venv_latest + fi + - name: Test examples run: | - source venv_latest/bin/activate - pip install nbmake - pytest --nbmake --nbmake-timeout 600 examples/ + if [ ${{ runner.os }} == 'windows-latest' ]; then + .\venv_latest\Scripts\pip.exe install nbmake + .\venv_latest\Scripts\pytest.exe --nbmake --nbmake-timeout 600 examples/ + else + source venv_latest/bin/activate + pip install nbmake + pytest --nbmake --nbmake-timeout 600 examples/ + fi + - name: clean run: | - rm -rf venv_latest + if [ ${{ runner.os }} == 'windows-latest' ]; then + rmdir /S /Q venv_latest + else + rm -rf venv_latest + fi + From e7ca15f5bc6c62ec8bde2495127af203f20df076 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 09:57:19 +0100 Subject: [PATCH 06/23] separate out windows tests --- .github/workflows/tests.yaml | 92 +++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index eefbd6b4..9ed44eb0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -112,7 +112,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: @@ -128,58 +128,72 @@ jobs: run: | python -m pip install --upgrade pip python -m venv venv_latest - if [ ${{ runner.os }} == 'windows-latest' ]; then + if [ ${{ runner.os }} == 'Windows' ]; then .\venv_latest\Scripts\pip.exe install . else source venv_latest/bin/activate pip install . fi - - name: Install old autoray if: matrix.python-version == '3.9' run: | - if [ ${{ runner.os }} == 'windows-latest' ]; then - .\venv_latest\Scripts\pip.exe install autoray==0.7.2 - else - source venv_latest/bin/activate - pip install autoray==0.7.2 - fi - + source venv_latest/bin/activate + pip install autoray==0.7.2 - name: Test with pytest run: | - if [ ${{ runner.os }} == 'windows-latest' ]; then - .\venv_latest\Scripts\pip.exe install pytest - .\venv_latest\Scripts\pytest.exe tests/ - else - source venv_latest/bin/activate - pip install pytest - pytest tests/ - fi - + source venv_latest/bin/activate + pip install pytest + pytest tests/ - name: clean run: | - if [ ${{ runner.os }} == 'windows-latest' ]; then - rmdir /S /Q venv_latest - else - rm -rf venv_latest - fi - + rm -rf venv_latest - name: Test examples run: | - if [ ${{ runner.os }} == 'windows-latest' ]; then - .\venv_latest\Scripts\pip.exe install nbmake - .\venv_latest\Scripts\pytest.exe --nbmake --nbmake-timeout 600 examples/ - else - source venv_latest/bin/activate - pip install nbmake - pytest --nbmake --nbmake-timeout 600 examples/ - fi - + source venv_latest/bin/activate + pip install nbmake + pytest --nbmake --nbmake-timeout 600 examples/ - name: clean run: | - if [ ${{ runner.os }} == 'windows-latest' ]; then - rmdir /S /Q venv_latest - else - rm -rf venv_latest - fi + rm -rf venv_latest + + pytest_windows: + name: Test on windows-latest with Python ${{ matrix.python-version }} + runs-on: windows-latest + + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v5 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: | + ${{ + matrix.python-version + }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m venv venv_latest + .\venv_latest\Scripts\pip.exe install . + - name: Install old autoray + if: matrix.python-version == '3.9' + run: | + .\venv_latest\Scripts\pip.exe install autoray==0.7.2 + - name: Test with pytest + run: | + .\venv_latest\Scripts\pip.exe install pytest + .\venv_latest\Scripts\pytest.exe tests/ + - name: clean + run: | + rm -rf venv_latest + - name: Test examples + run: | + .\venv_latest\Scripts\pip.exe venv_latest/bin/activate + pip install nbmake + .\venv_latest\Scripts\pytest.exe --nbmake --nbmake-timeout 600 examples/ + - name: clean + run: | + rmdir /S /Q venv_latest From 2f24f43ff85d2bcf57c15c5bb96195a2c682a70b Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 10:40:22 +0100 Subject: [PATCH 07/23] remove duplicate clean --- .github/workflows/tests.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9ed44eb0..ed6b4120 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -144,9 +144,6 @@ jobs: source venv_latest/bin/activate pip install pytest pytest tests/ - - name: clean - run: | - rm -rf venv_latest - name: Test examples run: | source venv_latest/bin/activate @@ -186,9 +183,6 @@ jobs: run: | .\venv_latest\Scripts\pip.exe install pytest .\venv_latest\Scripts\pytest.exe tests/ - - name: clean - run: | - rm -rf venv_latest - name: Test examples run: | .\venv_latest\Scripts\pip.exe venv_latest/bin/activate From be597a01160c4ca6bad5de34fe9a68f4f9305337 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 10:48:28 +0100 Subject: [PATCH 08/23] add pip upgrade --- .github/workflows/tests.yaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ed6b4120..a54fd8c7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -25,9 +25,9 @@ jobs: python-version: '3.9' - name: Install dependencies run: | - python -m pip install --upgrade pip python -m venv venv_minimal source venv_minimal/bin/activate + python -m pip install --upgrade pip pip install toml autoray==0.7.2 matplotlib-inline==0.1.7 python3 install_lowest_dependencies.py - name: Test with pytest @@ -59,9 +59,9 @@ jobs: python-version: '3.9' - name: Install dependencies run: | - python -m pip install --upgrade pip python -m venv venv_qiskit_0_46 source venv_qiskit_0_46/bin/activate + python -m pip install --upgrade pip pip install .[examples] qiskit==0.46.3 qiskit-ibm-runtime==0.20.0 autoray==0.7.2 - name: Test with pytest run: | @@ -88,9 +88,9 @@ jobs: python-version: '3.9' - name: Install dependencies run: | - python -m pip install --upgrade pip python -m venv venv_qiskit_1 source venv_qiskit_1/bin/activate + python -m pip install --upgrade pip pip install .[examples] qiskit==1.1.2 qiskit-algorithms==0.3.0 qiskit-ibm-runtime==0.27.1 autoray==0.7.2 - name: Test with pytest run: | @@ -126,14 +126,10 @@ jobs: }} - name: Install dependencies run: | - python -m pip install --upgrade pip python -m venv venv_latest - if [ ${{ runner.os }} == 'Windows' ]; then - .\venv_latest\Scripts\pip.exe install . - else - source venv_latest/bin/activate - pip install . - fi + source venv_latest/bin/activate + python -m pip install --upgrade pip + pip install . - name: Install old autoray if: matrix.python-version == '3.9' run: | @@ -174,6 +170,7 @@ jobs: run: | python -m pip install --upgrade pip python -m venv venv_latest + .\venv_latest\Scripts\python.exe -m pip install --upgrade pip .\venv_latest\Scripts\pip.exe install . - name: Install old autoray if: matrix.python-version == '3.9' From 996dd83c82ff76118146625986c9aa9c4a45e889 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 10:51:23 +0100 Subject: [PATCH 09/23] remove 3.13 from windows --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a54fd8c7..e5a1c7ed 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -155,7 +155,7 @@ jobs: strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v5 From d69ab54a22992f236944d7089b0c11406b9500a5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 10:55:35 +0100 Subject: [PATCH 10/23] re-add example dep install --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e5a1c7ed..44659336 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -129,7 +129,7 @@ jobs: python -m venv venv_latest source venv_latest/bin/activate python -m pip install --upgrade pip - pip install . + pip install .[examples] - name: Install old autoray if: matrix.python-version == '3.9' run: | @@ -171,7 +171,7 @@ jobs: python -m pip install --upgrade pip python -m venv venv_latest .\venv_latest\Scripts\python.exe -m pip install --upgrade pip - .\venv_latest\Scripts\pip.exe install . + .\venv_latest\Scripts\pip.exe install .[examples] - name: Install old autoray if: matrix.python-version == '3.9' run: | From 8219dfabd5579bd263caf781752caa07b410a29b Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 11:04:00 +0100 Subject: [PATCH 11/23] remove duplicate pip upgrade --- .github/workflows/tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 44659336..e6f97203 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -168,7 +168,6 @@ jobs: }} - name: Install dependencies run: | - python -m pip install --upgrade pip python -m venv venv_latest .\venv_latest\Scripts\python.exe -m pip install --upgrade pip .\venv_latest\Scripts\pip.exe install .[examples] From 651e0b328456dc6f4d427731397a33fb19b027bc Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 11:08:21 +0100 Subject: [PATCH 12/23] fix scipy version dep in qkode test --- tests/kernel/ml/test_qkode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index f988d970..07b039ae 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -49,7 +49,7 @@ def test_qkode_pqk(self, ode_loss): labels = np.zeros((len(x_train), 1)) qkode.fit(x_train, labels) - if version.parse(scipy_version) < version.parse("1.16"): + if version.parse(scipy_version) < version.parse("1.15"): regressor_result = np.array( [ 0.99663332, From d83e75a64d4e4711363d7f3d238a7b8569674edc Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 20 Nov 2025 11:16:25 +0100 Subject: [PATCH 13/23] fix windows pip isntall --- .github/workflows/tests.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e6f97203..92676849 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -181,8 +181,7 @@ jobs: .\venv_latest\Scripts\pytest.exe tests/ - name: Test examples run: | - .\venv_latest\Scripts\pip.exe venv_latest/bin/activate - pip install nbmake + .\venv_latest\Scripts\pip.exe install nbmake .\venv_latest\Scripts\pytest.exe --nbmake --nbmake-timeout 600 examples/ - name: clean run: | From 48b80d814bc0ac638caa11fe60fde69bb1da96ef Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 09:34:49 +0100 Subject: [PATCH 14/23] make qkode test system dependent --- tests/kernel/ml/test_qkode.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index 07b039ae..78945eac 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -1,5 +1,6 @@ import numpy as np from packaging import version +from platform import system import pytest from scipy import __version__ as scipy_version import sympy as sp @@ -63,7 +64,7 @@ def test_qkode_pqk(self, ode_loss): 2.46206022, ] ) - else: + elif system() == "Windows": regressor_result = np.array( [ 0.9973879, @@ -77,6 +78,20 @@ def test_qkode_pqk(self, ode_loss): 2.46402581, ] ) + else: + regressor_result = np.array( + [ + 0.99689371, + 1.12059708, + 1.25287154, + 1.39998192, + 1.56922034, + 1.75531624, + 1.96360549, + 2.19784202, + 2.46296489, + ] + ) assert qkode._loss.order_of_ode == 1 assert np.allclose( From 8281597f54d582e8d8df557723dac3c751f22f59 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 09:37:52 +0100 Subject: [PATCH 15/23] black test --- tests/kernel/ml/test_qkode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index 78945eac..6f645603 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -64,7 +64,7 @@ def test_qkode_pqk(self, ode_loss): 2.46206022, ] ) - elif system() == "Windows": + elif system() == "Windows": regressor_result = np.array( [ 0.9973879, From 61744676cc594ed715202b4d0aa134ace6c66b8b Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 10:17:31 +0100 Subject: [PATCH 16/23] change windows rm --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 92676849..3c7a5ad9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -185,4 +185,4 @@ jobs: .\venv_latest\Scripts\pytest.exe --nbmake --nbmake-timeout 600 examples/ - name: clean run: | - rmdir /S /Q venv_latest + rm -Recurse -Force venv_latest From 70184f815a0727a6563a41e547bb8c61651e0e5b Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 11:04:10 +0100 Subject: [PATCH 17/23] add darwin test case --- tests/kernel/ml/test_qkode.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index 6f645603..e8cbeeb3 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -78,6 +78,20 @@ def test_qkode_pqk(self, ode_loss): 2.46402581, ] ) + elif system() == "Darwin": + regressor_result = np.array( + [ + 0.99705777, + 1.12080111, + 1.25306857, + 1.40014354, + 1.56938517, + 1.75553607, + 1.96384703, + 2.1980863, + 2.46328302, + ] + ) else: regressor_result = np.array( [ From 1fcd4f32b72728fc266f7916a5895e2914f9aa90 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 13:32:53 +0100 Subject: [PATCH 18/23] use slsqp, lbfgs has issues... --- tests/kernel/ml/test_qkode.py | 77 ++++++++--------------------------- 1 file changed, 16 insertions(+), 61 deletions(-) diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index e8cbeeb3..51781cc4 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -10,7 +10,7 @@ from squlearn.kernel import ProjectedQuantumKernel, FidelityKernel from squlearn.kernel.loss import ODELoss from squlearn.kernel import QKODE -from squlearn.optimizers import LBFGSB +from squlearn.optimizers import SLSQP @pytest.fixture(params=["expr", "callable"]) @@ -44,73 +44,28 @@ def test_qkode_pqk(self, ode_loss): ) # Create the QKODE instance - qkode = QKODE(q_kernel, loss=ode_loss, optimizer=LBFGSB()) + qkode = QKODE(q_kernel, loss=ode_loss, optimizer=SLSQP()) x_train = np.linspace(0, 0.9, 9).reshape(-1, 1) labels = np.zeros((len(x_train), 1)) qkode.fit(x_train, labels) - if version.parse(scipy_version) < version.parse("1.15"): - regressor_result = np.array( - [ - 0.99663332, - 1.12030422, - 1.2525221, - 1.39952847, - 1.56866833, - 1.75470725, - 1.96290259, - 2.19701171, - 2.46206022, - ] - ) - elif system() == "Windows": - regressor_result = np.array( - [ - 0.9973879, - 1.12113415, - 1.25344976, - 1.40061217, - 1.56992748, - 1.7561082, - 1.96445327, - 2.19875868, - 2.46402581, - ] - ) - elif system() == "Darwin": - regressor_result = np.array( - [ - 0.99705777, - 1.12080111, - 1.25306857, - 1.40014354, - 1.56938517, - 1.75553607, - 1.96384703, - 2.1980863, - 2.46328302, - ] - ) - else: - regressor_result = np.array( - [ - 0.99689371, - 1.12059708, - 1.25287154, - 1.39998192, - 1.56922034, - 1.75531624, - 1.96360549, - 2.19784202, - 2.46296489, - ] - ) - assert qkode._loss.order_of_ode == 1 assert np.allclose( qkode.predict(x_train), - regressor_result, + np.array( + [ + 0.99673544, + 1.12042196, + 1.25265393, + 1.39967403, + 1.56883119, + 1.75490046, + 1.96312582, + 2.19726599, + 2.46239031, + ] + ), atol=1e-3, ) @@ -125,7 +80,7 @@ def test_qkode_fqk(self, ode_loss): ) # Create the QKODE instance - qkode = QKODE(q_kernel, loss=ode_loss, optimizer=LBFGSB()) + qkode = QKODE(q_kernel, loss=ode_loss, optimizer=SLSQP()) x_train = np.linspace(0, 0.9, 9).reshape(-1, 1) labels = np.zeros((len(x_train), 1)) From f25a8e396e9ed3e206ab90242a45c2943ea85bce Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 15:16:11 +0100 Subject: [PATCH 19/23] fix ode loss and tests --- src/squlearn/kernel/loss/ode_loss.py | 4 ++-- tests/kernel/ml/test_qkode.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/squlearn/kernel/loss/ode_loss.py b/src/squlearn/kernel/loss/ode_loss.py index 0c65f47a..f5891a93 100644 --- a/src/squlearn/kernel/loss/ode_loss.py +++ b/src/squlearn/kernel/loss/ode_loss.py @@ -95,14 +95,14 @@ def __init__( ode_functional: Union[sp.Expr, Callable], initial_values: Union[Sequence, np.ndarray], symbols_involved_in_ode: Optional[Sequence[sp.Basic]] = None, - eta: float = np.float64(1.0), + eta: float = 1.0, ode_order: Optional[int] = None, ): super().__init__() # normalize initial_values to a 1D numpy array self.initial_values = np.asarray(initial_values).ravel() - self.eta = float(eta) + self.eta = eta if isinstance(ode_functional, sp.Expr): if symbols_involved_in_ode is None: diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index 51781cc4..8496fd83 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -10,7 +10,7 @@ from squlearn.kernel import ProjectedQuantumKernel, FidelityKernel from squlearn.kernel.loss import ODELoss from squlearn.kernel import QKODE -from squlearn.optimizers import SLSQP +from squlearn.optimizers import LBFGSB @pytest.fixture(params=["expr", "callable"]) @@ -44,7 +44,7 @@ def test_qkode_pqk(self, ode_loss): ) # Create the QKODE instance - qkode = QKODE(q_kernel, loss=ode_loss, optimizer=SLSQP()) + qkode = QKODE(q_kernel, loss=ode_loss, optimizer=LBFGSB()) x_train = np.linspace(0, 0.9, 9).reshape(-1, 1) labels = np.zeros((len(x_train), 1)) @@ -80,7 +80,7 @@ def test_qkode_fqk(self, ode_loss): ) # Create the QKODE instance - qkode = QKODE(q_kernel, loss=ode_loss, optimizer=SLSQP()) + qkode = QKODE(q_kernel, loss=ode_loss, optimizer=LBFGSB()) x_train = np.linspace(0, 0.9, 9).reshape(-1, 1) labels = np.zeros((len(x_train), 1)) From 28d55857f248bd4cddd770d4271a8d0aedd7c7fd Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 15:21:50 +0100 Subject: [PATCH 20/23] remove numpy float cast --- src/squlearn/qnn/loss/ode_loss.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/squlearn/qnn/loss/ode_loss.py b/src/squlearn/qnn/loss/ode_loss.py index a4acec55..20cdf7e4 100644 --- a/src/squlearn/qnn/loss/ode_loss.py +++ b/src/squlearn/qnn/loss/ode_loss.py @@ -79,10 +79,10 @@ class ODELoss(QNNLossBase): def __init__( self, - ode_functional=None, - symbols_involved_in_ode=None, + ode_functional = None, + symbols_involved_in_ode = None, initial_values: np.ndarray = None, - eta=np.float64(1.0), + eta: float = 1.0, ): super().__init__() self._verify_size_of_ivp_with_order_of_ode(initial_values, symbols_involved_in_ode) From af9f7b60a4940bf6286cba153afe25cd54750761 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Nov 2025 15:23:04 +0100 Subject: [PATCH 21/23] black --- src/squlearn/qnn/loss/ode_loss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/squlearn/qnn/loss/ode_loss.py b/src/squlearn/qnn/loss/ode_loss.py index 20cdf7e4..53118cbd 100644 --- a/src/squlearn/qnn/loss/ode_loss.py +++ b/src/squlearn/qnn/loss/ode_loss.py @@ -79,8 +79,8 @@ class ODELoss(QNNLossBase): def __init__( self, - ode_functional = None, - symbols_involved_in_ode = None, + ode_functional=None, + symbols_involved_in_ode=None, initial_values: np.ndarray = None, eta: float = 1.0, ): From 9c216ad4c357e33ee1819b6c7b1d701bb0d95488 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 25 Nov 2025 12:16:19 +0100 Subject: [PATCH 22/23] use lbfgsb again --- tests/kernel/ml/test_qkode.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/kernel/ml/test_qkode.py b/tests/kernel/ml/test_qkode.py index 8496fd83..51781cc4 100644 --- a/tests/kernel/ml/test_qkode.py +++ b/tests/kernel/ml/test_qkode.py @@ -10,7 +10,7 @@ from squlearn.kernel import ProjectedQuantumKernel, FidelityKernel from squlearn.kernel.loss import ODELoss from squlearn.kernel import QKODE -from squlearn.optimizers import LBFGSB +from squlearn.optimizers import SLSQP @pytest.fixture(params=["expr", "callable"]) @@ -44,7 +44,7 @@ def test_qkode_pqk(self, ode_loss): ) # Create the QKODE instance - qkode = QKODE(q_kernel, loss=ode_loss, optimizer=LBFGSB()) + qkode = QKODE(q_kernel, loss=ode_loss, optimizer=SLSQP()) x_train = np.linspace(0, 0.9, 9).reshape(-1, 1) labels = np.zeros((len(x_train), 1)) @@ -80,7 +80,7 @@ def test_qkode_fqk(self, ode_loss): ) # Create the QKODE instance - qkode = QKODE(q_kernel, loss=ode_loss, optimizer=LBFGSB()) + qkode = QKODE(q_kernel, loss=ode_loss, optimizer=SLSQP()) x_train = np.linspace(0, 0.9, 9).reshape(-1, 1) labels = np.zeros((len(x_train), 1)) From 1f7bac57e2ab8bf991912a75e25c4cec311b5b16 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 25 Nov 2025 12:33:37 +0100 Subject: [PATCH 23/23] slim down tests --- .github/workflows/tests.yaml | 75 +++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3c7a5ad9..135c8d96 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -35,15 +35,6 @@ jobs: source venv_minimal/bin/activate pip install pytest pytest tests/ - - name: Install example dependencies - run: | - source venv_minimal/bin/activate - python3 install_lowest_dependencies.py --examples - - name: Test examples - run: | - source venv_minimal/bin/activate - pip install nbmake - pytest --nbmake --nbmake-timeout 600 examples/ - name: clean run: | rm -rf venv_minimal @@ -62,17 +53,12 @@ jobs: python -m venv venv_qiskit_0_46 source venv_qiskit_0_46/bin/activate python -m pip install --upgrade pip - pip install .[examples] qiskit==0.46.3 qiskit-ibm-runtime==0.20.0 autoray==0.7.2 + pip install . qiskit==0.46.3 qiskit-ibm-runtime==0.20.0 autoray==0.7.2 - name: Test with pytest run: | source venv_qiskit_0_46/bin/activate pip install pytest pytest tests/ - - name: Test examples - run: | - source venv_qiskit_0_46/bin/activate - pip install nbmake - pytest --nbmake --nbmake-timeout 600 examples/ - name: clean run: | rm -rf venv_qiskit_0_46 @@ -91,28 +77,22 @@ jobs: python -m venv venv_qiskit_1 source venv_qiskit_1/bin/activate python -m pip install --upgrade pip - pip install .[examples] qiskit==1.1.2 qiskit-algorithms==0.3.0 qiskit-ibm-runtime==0.27.1 autoray==0.7.2 + pip install . qiskit==1.1.2 qiskit-algorithms==0.3.0 qiskit-ibm-runtime==0.27.1 autoray==0.7.2 - name: Test with pytest run: | source venv_qiskit_1/bin/activate pip install pytest pytest tests/ - - name: Test examples - run: | - source venv_qiskit_1/bin/activate - pip install nbmake - pytest --nbmake --nbmake-timeout 600 examples/ - name: clean run: | rm -rf venv_qiskit_1 - pytest_latest: - name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} + pytest_full: + name: Tests + Examples on ubuntu-latest with Python ${{ matrix.python-version }} + runs-on: ubuntu-latest strategy: matrix: - os: [ubuntu-latest, macos-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: @@ -155,7 +135,7 @@ jobs: strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.12"] steps: - uses: actions/checkout@v5 @@ -170,7 +150,7 @@ jobs: run: | python -m venv venv_latest .\venv_latest\Scripts\python.exe -m pip install --upgrade pip - .\venv_latest\Scripts\pip.exe install .[examples] + .\venv_latest\Scripts\pip.exe install . - name: Install old autoray if: matrix.python-version == '3.9' run: | @@ -179,10 +159,43 @@ jobs: run: | .\venv_latest\Scripts\pip.exe install pytest .\venv_latest\Scripts\pytest.exe tests/ - - name: Test examples - run: | - .\venv_latest\Scripts\pip.exe install nbmake - .\venv_latest\Scripts\pytest.exe --nbmake --nbmake-timeout 600 examples/ - name: clean run: | rm -Recurse -Force venv_latest + + pytest_macos: + name: Test on macos-latest with Python ${{ matrix.python-version }} + runs-on: macos-latest + + strategy: + matrix: + python-version: ["3.9", "3.12"] + + steps: + - uses: actions/checkout@v5 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: | + ${{ + matrix.python-version + }} + - name: Install dependencies + run: | + python -m venv venv_latest + source venv_latest/bin/activate + python -m pip install --upgrade pip + pip install . + - name: Install old autoray + if: matrix.python-version == '3.9' + run: | + source venv_latest/bin/activate + pip install autoray==0.7.2 + - name: Test with pytest + run: | + source venv_latest/bin/activate + pip install pytest + pytest tests/ + - name: clean + run: | + rm -rf venv_latest