Skip to content

Commit 947e49f

Browse files
authored
Merge pull request #137 from jpmorganchase/pybobyqa-to-py-bobyqa
Update pyproject.toml and add tests
2 parents c890fc9 + 59e9fe0 commit 947e49f

4 files changed

Lines changed: 31 additions & 15 deletions

File tree

.github/workflows/qokit-package.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
os: [ubuntu-latest, macos-latest]
2020
python-version: ["3.10", "3.11"]
21-
21+
2222
steps:
2323
- uses: actions/checkout@v3
2424
- name: Set up Python ${{ matrix.python-version }}
@@ -33,18 +33,22 @@ jobs:
3333
- name: black check
3434
run: |
3535
black --check .
36-
37-
- name: pip install
36+
37+
- name: pip install
38+
run: |
39+
pip install .
40+
41+
- name: Verify xorsat-optimize extra installs cleanly
3842
run: |
39-
pip install .
40-
41-
- name: Run tests
43+
pip install '.[xorsat-optimize]'
44+
45+
- name: Run tests
4246
run: |
43-
pytest --cov=qokit --cov-fail-under=75 -rs tests
47+
pytest --cov=qokit --cov-fail-under=75 -rs tests
4448
- name: License check
4549
run: |
4650
pip-licenses --format=markdown --order=license
47-
51+
4852
- name: SPDX check
4953
run: |
5054
addheader -t header.txt .

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ pip install -e .
2727
```
2828

2929
Some optional parts of the package require additional dependencies.
30-
- GPU simulation: `pip install -e .[GPU-CUDA12]`
31-
- Generating LP files to solve LABS using commercial IP solvers (`qokit/classical_methods` and `examples/advanced/classical_solvers_for_LABS/`): `pip install -e .[solvers]`
32-
- Max-k-XOR-SAT with JAX (CPU-only): `pip install -e .[xorsat-jax]`
33-
- Max-k-XOR-SAT with JAX + CUDA GPU: `pip install -e .[xorsat-gpu]`
34-
- Max-k-XOR-SAT angle optimization (requires BOBYQA): `pip install -e .[xorsat-optimize]`
30+
- GPU simulation: `pip install -e '.[GPU-CUDA12]'`
31+
- Generating LP files to solve LABS using commercial IP solvers (`qokit/classical_methods` and `examples/advanced/classical_solvers_for_LABS/`): `pip install -e '.[solvers]'`
32+
- Max-k-XOR-SAT with JAX (CPU-only): `pip install -e '.[xorsat-jax]'`
33+
- Max-k-XOR-SAT with JAX + CUDA GPU: `pip install -e '.[xorsat-gpu]'`
34+
- Max-k-XOR-SAT angle optimization (requires BOBYQA): `pip install -e '.[xorsat-optimize]'`
3535

3636
Please note that the GPU dependency is specified for CUDA 12x. For other versions of CUDA, please follow cupy installation instructions.
3737

@@ -57,7 +57,7 @@ It ships two backends (at least one must be available):
5757
make -j
5858
```
5959
If `cmake` is not installed, the C++ backend is silently skipped.
60-
- **JAX**: float64 only, forward-mode JVP gradient, JIT-compiled. Install with `pip install -e .[xorsat-jax]` (CPU) or `pip install -e .[xorsat-gpu]` (CUDA GPU).
60+
- **JAX**: float64 only, forward-mode JVP gradient, JIT-compiled. Install with `pip install -e '.[xorsat-jax]'` (CPU) or `pip install -e '.[xorsat-gpu]'` (CUDA GPU).
6161

6262
See [`examples/QAOA_max_k_xor_sat.ipynb`](./examples/QAOA_max_k_xor_sat.ipynb) for a usage demo.
6363

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ xorsat-gpu = [
5454
'jax[cuda12]'
5555
]
5656
xorsat-optimize = [
57-
'pybobyqa',
57+
'py-bobyqa',
5858
'scipy>=1.10.1'
5959
]
6060

tests/test_max_k_xor_sat.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# // Copyright : JP Morgan Chase & Co
44
###############################################################################
55
"""Tests for the max_k_xor_sat module."""
6+
import importlib.metadata
67
import numpy as np
78
import pytest
89

@@ -203,6 +204,17 @@ def test_load_nonexistent_config():
203204
load_precomputed_results(99, 99)
204205

205206

207+
def test_xorsat_optimize_dep_name():
208+
"""xorsat-optimize must declare 'Py-BOBYQA'"""
209+
requires = importlib.metadata.requires("qokit") or []
210+
bobyqa_deps = [r for r in requires if "bobyqa" in r.lower()]
211+
assert bobyqa_deps, "No bobyqa dependency found in qokit metadata"
212+
for dep in bobyqa_deps:
213+
pkg = dep.split(";")[0].strip().split()[0].lower()
214+
assert pkg != "pybobyqa", f"Dependency '{dep}' uses the typo'd name 'pybobyqa' — use 'Py-BOBYQA' instead"
215+
assert pkg in ("py-bobyqa", "py_bobyqa"), f"Unexpected bobyqa dependency name '{pkg}' — expected 'py-bobyqa'"
216+
217+
206218
# ============================================================
207219
# C++ backend tests
208220
# ============================================================

0 commit comments

Comments
 (0)