Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Commit

Permalink
Revert accidental breaking backports (#427)
Browse files Browse the repository at this point in the history
* Revert #400/#401 from stable branch

The change made in #400 (which was missed because it got integrated into
the #401 PR which was needed to unblock CI on master) should not have
been backported. It was only necessary for compat with terra master and
terra 0.15.0 because the validation module is removed in 0.15.0. This is
breaking measurement mitigation on the stable branch and 0.3.1 release
which needs to work with terra 0.14.x. This commit reverts that change
so the we're wrapping the counts in qiskit.validation.Obj and the
Results object is useable in marshmallow with released terra.
  • Loading branch information
mtreinish authored Jun 18, 2020
1 parent 015c64e commit 08ffae0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
10 changes: 6 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ jobs:
displayName: Add conda to PATH
- script: conda create --yes --quiet --name qiskit-ignis python=%PYTHON_VERSION%
displayName: Create Anaconda environment
- script: |
call activate qiskit-ignis
- bash: |
set -e
set -x
source activate qiskit-ignis
conda config --add channels conda-forge
conda install cvxopt
conda install cvxopt -y
python -m pip install -c constraints.txt --upgrade pip virtualenv setuptools
pip install -c constraints.txt -U tox
tox --sitepackages -e%TOXENV%
tox --sitepackages
displayName: 'Install dependencies and run tests'
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.3.1'
release = '0.3.2'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion qiskit/ignis/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1
0.3.2
3 changes: 2 additions & 1 deletion qiskit/ignis/measurement/discriminator/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
BaseDiscriminationFitter
from qiskit.result.result import Result
from qiskit.result.models import ExperimentResultData
from qiskit.validation.base import Obj


class DiscriminationFilter:
Expand Down Expand Up @@ -87,7 +88,7 @@ def apply(self, raw_data: Result) -> Result:
start = 0
for idx, n_shots in enumerate(shots_per_experiment_result):
memory = y_data[start:(start+n_shots)]
counts = self.count(memory)
counts = Obj.from_dict(self.count(memory))
new_results.results[idx].data = ExperimentResultData(counts=counts,
memory=memory)
start += n_shots
Expand Down
5 changes: 3 additions & 2 deletions qiskit/ignis/mitigation/measurement/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import scipy.linalg as la
import numpy as np
import qiskit
from qiskit.validation.base import Obj
from qiskit import QiskitError
from qiskit.tools import parallel_map
from ...verification.tomography import count_keys
Expand Down Expand Up @@ -150,7 +151,7 @@ def apply(self,
task_args=(raw_data, method))

for resultidx, new_counts in new_counts_list:
new_result.results[resultidx].data.counts = new_counts
new_result.results[resultidx].data.counts = Obj(**new_counts)

return new_result

Expand Down Expand Up @@ -329,7 +330,7 @@ def apply(self, raw_data, method='least_squares'):
task_args=(raw_data, method))

for resultidx, new_counts in new_counts_list:
new_result.results[resultidx].data.counts = new_counts
new_result.results[resultidx].data.counts = Obj(**new_counts)

return new_result

Expand Down
12 changes: 7 additions & 5 deletions qiskit/ignis/verification/accreditation/fitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=invalid-name


"""
Class for accreditation protocol
Expand Down Expand Up @@ -38,7 +40,7 @@ class AccreditationFitter:

bound = 1
confidence = 1
n_acc = 0
N_acc = 0
num_runs = 0
flag = 'accepted'
outputs = []
Expand Down Expand Up @@ -90,7 +92,7 @@ def single_protocol_run(self, results, postp_list, v_zero):
else:
output_target = count
if self.flag == 'accepted':
self.n_acc += 1
self.N_acc += 1
self.outputs.append(output_target)

def bound_variation_distance(self, theta):
Expand All @@ -101,12 +103,12 @@ def bound_variation_distance(self, theta):
Args:
theta (float): number between 0 and 1
"""
if self.n_acc == 0:
if self.N_acc == 0:
QiskitError("ERROR: Variation distance requires"
"at least one accepted run")
if self.n_acc/self.num_runs > theta:
if self.N_acc/self.num_runs > theta:
self.bound = self.g_num*1.7/(self.num_traps+1)
self.bound = self.bound/(self.n_acc/self.num_runs-theta)
self.bound = self.bound/(self.N_acc/self.num_runs-theta)
self.bound = self.bound+1-self.g_num
self.confidence = 1-2*np.exp(-2*theta*self.num_runs*self.num_runs)
if self.bound > 1:
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ deps = numpy>=1.13
Cython>=0.27.1
setuptools>=40.1.0
commands =
pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra.git
pip install -U -c constraints.txt qiskit-terra
pip install -U -c constraints.txt -r{toxinidir}/requirements-dev.txt
pip check
stestr run {posargs}

[testenv:lint]
basepython = python3
deps =
git+https://github.com/Qiskit/qiskit-terra.git
qiskit-terra
qiskit-aer
scikit-learn>=0.17
ddt
Expand All @@ -36,7 +36,7 @@ commands =
[testenv:docs]
basepython = python3
deps =
git+https://github.com/Qiskit/qiskit-terra.git
qiskit-terra
-r{toxinidir}/requirements-dev.txt
qiskit-ibmq-provider
commands =
Expand Down

0 comments on commit 08ffae0

Please sign in to comment.