Skip to content

Commit

Permalink
Pin cvxpy in CI (qiskit-community#554)
Browse files Browse the repository at this point in the history
* Pin cvxpy in CI

The latest cvxpy version is causing CI faiulres because of their change
in the numpy dependency. This commit pins cvxpy to the previous release
where things were known to be working.

* Install cvxpy later

* Fix execute import

* Remove machine learning from tutorials

* Install cvxpy last

* Remove algorithms tutorials too

* Use int instead of np.int

* Use float instead of deprecated np.float

* Don't use scs on mac

* Fix typo
  • Loading branch information
mtreinish authored Feb 4, 2021
1 parent 824372e commit 2295884
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: ["macOS-latest", "ubuntu-latest"]
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -36,6 +36,37 @@ jobs:
run: tox -e py39
if: matrix.python-version == '3.9'

tests-macos:
name: tests-python${{ matrix.python-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: ["macOS-latest"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-tests-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-tests-
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}
- name: Install Deps
run: python -m pip install -U tox setuptools virtualenv wheel cvxopt
- name: Install and Run Tests
run: tox --sitepackages -e py
if: matrix.python-version != '3.9'
- name: Install and Run Tests
run: tox --sitepackages -e py39
if: matrix.python-version == '3.9'

tests-no-opt:
name: tests-python3.8-no-optional-dependencies
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -178,7 +209,7 @@ jobs:
run: |
set -e
cd qiskit-tutorials
rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/simulators
rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/simulators tutorials/machine_learning tutorials/algorithms
sphinx-build -b html . _build/html
- uses: actions/upload-artifact@v2
with:
Expand Down
1 change: 1 addition & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ astroid==2.3.3
pywin32==225
setuptools==49.6.0
pyfakefs==4.1.0
cvxpy==1.1.7
8 changes: 4 additions & 4 deletions qiskit/ignis/mitigation/expval/ctmp_mitigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def expectation_value(self,
gamma = self.noise_strength(qubits)
bmat = self._sampling_matrix(qubits)
values = bmat.data
indices = np.asarray(bmat.indices, dtype=np.int)
indptrs = np.asarray(bmat.indptr, dtype=np.int)
indices = np.asarray(bmat.indices, dtype=int)
indptrs = np.asarray(bmat.indptr, dtype=int)

# Set a minimum number of CTMP samples
shots = sum(counts.values())
Expand Down Expand Up @@ -184,7 +184,7 @@ def generator_matrix(self, qubits: List[int] = None) -> sps.coo_matrix:
if qubits not in self._generator_mats:
# Construct G from subset generators
qubits_set = set(qubits)
g_mat = sps.coo_matrix(2 * (2**len(qubits),), dtype=np.float)
g_mat = sps.coo_matrix(2 * (2**len(qubits),), dtype=float)
for gen, rate in zip(self._generators, self._rates):
if qubits_set.issuperset(gen[2]):
# Keep generator
Expand Down Expand Up @@ -301,7 +301,7 @@ def _ctmp_inverse(

# Apply CTMP sampling
r_vals = rng.random(size=alphas.sum())
y_vals = np.zeros(x_vals.size, dtype=np.int)
y_vals = np.zeros(x_vals.size, dtype=int)
_markov_chain_compiled(y_vals, x_vals, r_vals, alphas, csc_data, csc_indices,
csc_indptrs)

Expand Down
2 changes: 1 addition & 1 deletion test/verification/test_entanglement.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import numpy as np

from qiskit.execute import execute
from qiskit import execute
from qiskit.providers.basicaer import BasicAer
from qiskit.ignis.verification.entanglement import linear

Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ setenv =
VIRTUAL_ENV={envdir}
LANGUAGE=en_US
LC_ALL=en_US.utf-8
deps = numpy>=1.13
deps = numpy>=1.16.3
Cython>=0.27.1
setuptools>=40.1.0
cvxpy>=1.0.15
passenv = QISKIT_IN_PARALLEL
commands =
pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra.git
pip install -U -c constraints.txt -r{toxinidir}/requirements-dev.txt
pip install -c constraints.txt cvxpy<1.1.8
pip check
stestr run {posargs}
# Remove after qiskit-aer 0.8.0 release:
Expand All @@ -26,6 +26,7 @@ commands =
pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra.git
pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-aer.git
pip install -U -c constraints.txt -r{toxinidir}/requirements-dev.txt
pip install -c constraints.txt cvxpy<1.1.8
pip check
stestr run {posargs}

Expand Down

0 comments on commit 2295884

Please sign in to comment.