Skip to content

Commit

Permalink
Fix ignis on no optional requirements
Browse files Browse the repository at this point in the history
In qiskit-community#500 type hints were added for the plotting functions using the
optional matplotlib dependencies. This breaks ignis installations
without matplotlib present since it's an optional dependency. Since type
hints are really just for documentation and not necessary this commit
just removes those problematic hints and uses the docstring to document
the types.

At the same time the testing job verifying ignis works without any
optional dependencies that was lost in the migration from travis to
github actions is restored to verify that everything works moving
forward.
  • Loading branch information
mtreinish committed Nov 4, 2020
1 parent c572b34 commit 6556d46
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@ jobs:
QISKIT_IN_PARALLEL: TRUE
run: tox -e py
if: runner.os == 'macOS'
tests-no-opt:
name: tests-python${{ matrix.python-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8]
os: ["ubuntu-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
- name: Install and Run Tests
run: tox -e no-opt
windows-tests:
name: tests-python${{ matrix.python-version }}-windows
runs-on: windows-latest
Expand Down
22 changes: 11 additions & 11 deletions qiskit/ignis/mitigation/expval/base_meas_mitigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ def stddev_upper_bound(self, shots: int = 1, qubits: Optional[List[int]] = None)
return gamma / np.sqrt(shots)

def plot_assignment_matrix(self,
qubits: Optional[List[int]] = None,
ax: Optional[plt.axes] = None) -> plt.axes:
qubits=None,
ax=None):
"""Matrix plot of the readout error assignment matrix.
Args:
qubits: Optional, qubits being measured for operator expval.
ax: Optional. Axes object to add plot to.
qubits (list): Optional, qubits being measured for operator expval.
ax (axes: Optional. Axes object to add plot to.
Returns:
plt.axes: the figure axes object.
Expand All @@ -195,13 +195,13 @@ def plot_assignment_matrix(self,
return ax

def plot_mitigation_matrix(self,
qubits: Optional[List[int]] = None,
ax: Optional[plt.axes] = None) -> plt.axes:
qubits=None,
ax= None):
"""Matrix plot of the readout error mitigation matrix.
Args:
qubits: Optional, qubits being measured for operator expval.
ax: Optional. Axes object to add plot to.
qubits (list): Optional, qubits being measured for operator expval.
ax (plt.axes): Optional. Axes object to add plot to.
Returns:
plt.axes: the figure axes object.
Expand Down Expand Up @@ -247,12 +247,12 @@ def _int_to_bitstring(i, num_qubits=None):
return label

@staticmethod
def _plot_axis(mat: np.ndarray, ax: plt.axes) -> plt.axes:
def _plot_axis(mat, ax):
"""Helper function for setting up axes for plots.
Args:
mat: the N-qubit matrix to plot.
ax: Optional. Axes object to add plot to.
mat (np.ndarray): the N-qubit matrix to plot.
ax (plt.axes): Optional. Axes object to add plot to.
Returns:
plt.axes: the figure object and axes object.
Expand Down

0 comments on commit 6556d46

Please sign in to comment.