Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix qcvv progress bars when using cli #1072

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion supermarq-benchmarks/supermarq/qcvv/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import cirq
import cirq_superstaq as css
import pandas as pd
from tqdm.notebook import tqdm
from tqdm.auto import tqdm


@dataclass
Expand Down
6 changes: 0 additions & 6 deletions supermarq-benchmarks/supermarq/qcvv/base_experiment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from __future__ import annotations

import os
from dataclasses import dataclass
from unittest.mock import MagicMock, call, patch

Expand All @@ -38,11 +37,6 @@ class ExampleResults(BenchmarkingResults):
experiment_name = "Example results"


@pytest.fixture(scope="session", autouse=True)
def patch_tqdm() -> None:
os.environ["TQDM_DISABLE"] = "1"


@pytest.fixture
@patch.multiple(BenchmarkingExperiment, __abstractmethods__=set())
def abc_experiment() -> BenchmarkingExperiment[ExampleResults]:
Expand Down
14 changes: 14 additions & 0 deletions supermarq-benchmarks/supermarq/qcvv/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import annotations

import os
from collections.abc import Generator
from unittest import mock

import pytest


@pytest.fixture(scope="session", autouse=True)
def patch_tqdm() -> Generator[None, None, None]:
"""Disable progress bars during tests."""
with mock.patch.dict(os.environ, {"TQDM_DISABLE": "1"}):
yield
4 changes: 2 additions & 2 deletions supermarq-benchmarks/supermarq/qcvv/irb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import pandas as pd
import scipy
import seaborn as sns
from tqdm.auto import trange
from tqdm.contrib.itertools import product
from tqdm.notebook import tqdm

from supermarq.qcvv.base_experiment import BenchmarkingExperiment, BenchmarkingResults, Sample

Expand Down Expand Up @@ -408,7 +408,7 @@ def gates_per_clifford(self, samples: int = 500) -> dict[str, float]:
"""
sample = [
self._clifford_gate_to_circuit(self.random_clifford())
for _ in tqdm(range(samples), desc="Sampling Clifford operations")
for _ in trange(samples, desc="Sampling Clifford operations")
]
return {
"single_qubit_gates": np.mean(
Expand Down
6 changes: 0 additions & 6 deletions supermarq-benchmarks/supermarq/qcvv/irb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# mypy: disable-error-code="union-attr"
from __future__ import annotations

import os
from unittest.mock import MagicMock, patch

import cirq
Expand All @@ -28,11 +27,6 @@
from supermarq.qcvv.irb import IRB


@pytest.fixture(scope="session", autouse=True)
def patch_tqdm() -> None:
os.environ["TQDM_DISABLE"] = "1"


def test_irb_init() -> None:
with patch("cirq_superstaq.service.Service"):
experiment = IRB()
Expand Down
5 changes: 2 additions & 3 deletions supermarq-benchmarks/supermarq/qcvv/xeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import pandas as pd
import scipy
import seaborn as sns
import tqdm
import tqdm.contrib
import tqdm.auto
import tqdm.contrib.itertools

from supermarq.qcvv import BenchmarkingExperiment, BenchmarkingResults, Sample
Expand Down Expand Up @@ -252,7 +251,7 @@ def _process_probabilities(
sample.sample_probabilities = sample.probabilities
sample.probabilities = {}

for sample in tqdm.notebook.tqdm(samples, desc="Evaluating circuits"):
for sample in tqdm.auto.tqdm(samples, desc="Evaluating circuits"):
sample.target_probabilities = self._simulate_sample(sample)

records = []
Expand Down
6 changes: 0 additions & 6 deletions supermarq-benchmarks/supermarq/qcvv/xeb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from __future__ import annotations

import itertools
import os
from unittest.mock import MagicMock, patch

import cirq
Expand All @@ -27,11 +26,6 @@
from supermarq.qcvv import XEB, XEBSample


@pytest.fixture(scope="session", autouse=True)
def patch_tqdm() -> None:
os.environ["TQDM_DISABLE"] = "1"


def test_xeb_init() -> None:
with patch("cirq_superstaq.service.Service"):
experiment = XEB()
Expand Down