From aadc0df36c42634dc1a2162c0d5b7c0bab4ccb40 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 14:34:19 -0400 Subject: [PATCH 1/8] 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. --- qiskit/ignis/mitigation/measurement/filters.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qiskit/ignis/mitigation/measurement/filters.py b/qiskit/ignis/mitigation/measurement/filters.py index 7f5abf8e1..15f87539e 100644 --- a/qiskit/ignis/mitigation/measurement/filters.py +++ b/qiskit/ignis/mitigation/measurement/filters.py @@ -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 @@ -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 @@ -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 From 18ccfe4bfc44d47ab41d5463f13b94d04fe8d806 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 14:44:36 -0400 Subject: [PATCH 2/8] Add missing revert spot --- qiskit/ignis/measurement/discriminator/filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qiskit/ignis/measurement/discriminator/filters.py b/qiskit/ignis/measurement/discriminator/filters.py index f855e4fb4..0827eb32b 100644 --- a/qiskit/ignis/measurement/discriminator/filters.py +++ b/qiskit/ignis/measurement/discriminator/filters.py @@ -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: @@ -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 From 1a0c944e248ecc968ee4cdfcdfff9036a4cf34c8 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 15:10:33 -0400 Subject: [PATCH 3/8] Use terra stable for tox on stable --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index d4328aa45..e65355431 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ 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} From c0f0442d7ac59fea62a5b9dfe3dbd41ee75662f5 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 15:17:53 -0400 Subject: [PATCH 4/8] Revert breaking name change --- qiskit/ignis/verification/accreditation/fitters.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qiskit/ignis/verification/accreditation/fitters.py b/qiskit/ignis/verification/accreditation/fitters.py index f309b88b8..6bbdda236 100644 --- a/qiskit/ignis/verification/accreditation/fitters.py +++ b/qiskit/ignis/verification/accreditation/fitters.py @@ -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 @@ -38,7 +40,7 @@ class AccreditationFitter: bound = 1 confidence = 1 - n_acc = 0 + N_acc = 0 num_runs = 0 flag = 'accepted' outputs = [] @@ -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): @@ -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: From 8f7fb4b96e9d73ae265f3bd1700e04a711a0152a Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 15:23:45 -0400 Subject: [PATCH 5/8] Fix ci --- azure-pipelines.yml | 6 ++++-- tox.ini | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 02e634c64..893c2c579 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -70,8 +70,10 @@ 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 python -m pip install -c constraints.txt --upgrade pip virtualenv setuptools diff --git a/tox.ini b/tox.ini index e65355431..ee4337e16 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ commands = [testenv:lint] basepython = python3 deps = - git+https://github.com/Qiskit/qiskit-terra.git + qiskit-terra qiskit-aer scikit-learn>=0.17 ddt @@ -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 = From 6f246c827f0c04a5bfdb5022ed0f603768bff62a Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 15:25:42 -0400 Subject: [PATCH 6/8] Bump version to prepare for release --- docs/conf.py | 2 +- qiskit/ignis/VERSION.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 45fdfd362..59e928bcc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 --------------------------------------------------- diff --git a/qiskit/ignis/VERSION.txt b/qiskit/ignis/VERSION.txt index 9e11b32fc..d15723fbe 100644 --- a/qiskit/ignis/VERSION.txt +++ b/qiskit/ignis/VERSION.txt @@ -1 +1 @@ -0.3.1 +0.3.2 From 198328cce4ad7e2041a14e3b72c856df668c6a82 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 15:31:33 -0400 Subject: [PATCH 7/8] Fix conda isntall The windows ci jobs were stuck waiting for a prompt on windows this commit fixes the conda install command to auto accept the prompt so we actually can install in ci. --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 893c2c579..4cbcd457d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -75,7 +75,7 @@ jobs: 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% From 9e142a220abe33189b749adb58bdf8348ff378e2 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 18 Jun 2020 15:39:03 -0400 Subject: [PATCH 8/8] Just rely on toxenv env var instead of -e --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4cbcd457d..4cce9d8bc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,5 +78,5 @@ jobs: 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'