Skip to content

Commit

Permalink
Fix fitter selection logic in process tomography (qiskit-community#431)
Browse files Browse the repository at this point in the history
This commit fixes an issue in the process tomography module. When cvxpy
was not installed the module would fail to import. That's because the
selection logic was reworked in qiskit-community#422 but never updated in process
tomography to reflect that change. Since no CI job runs without cvxpy
installed we never caught this edge case. This commit fixes the
underlying issue to rework the process tomography fitter selection logic
to mirror the changes to state tomography in qiskit-community#422 and then also try and
add ci coverage it removes cvxpy from the docs tox job. With warnings
set to fatal this should ensure we are always able to import everything
and build the docs if cvxpy is not installed.

Fixes qiskit-community#429
  • Loading branch information
mtreinish authored Jun 22, 2020
1 parent e8a559f commit 01e9070
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from qiskit import QiskitError
from qiskit.quantum_info.operators import Choi
from .base_fitter import TomographyFitter
from .cvx_fit import cvxpy, cvx_fit
from .cvx_fit import cvx_fit
from .lstsq_fit import lstsq_fit


Expand Down Expand Up @@ -137,10 +137,11 @@ def fit(self, # pylint: disable=arguments-differ
"to a process matrix.")
# Choose automatic method
if method == 'auto':
if cvxpy is None:
method = 'lstsq'
else:
self._check_for_sdp_solver()
if self._HAS_SDP_SOLVER:
method = 'cvx'
else:
method = 'lstsq'
if method == 'lstsq':
return Choi(lstsq_fit(data, basis_matrix, weights=weights,
trace=dim, **kwargs))
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cvxpy>=1.0.15
pylint==2.4.4
pycodestyle
qiskit-aer>=0.3.0
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ setenv =
deps = numpy>=1.13
Cython>=0.27.1
setuptools>=40.1.0
cvxpy>=1.0.15
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
Expand Down

0 comments on commit 01e9070

Please sign in to comment.