Skip to content
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 .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Qiskit Experiments

[![License](https://img.shields.io/github/license/Qiskit/qiskit-experiments.svg?style=popout-square)](https://opensource.org/licenses/Apache-2.0)
[![Release](https://img.shields.io/github/release/Qiskit/qiskit-experiments.svg?style=popout-square)](https://github.com/Qiskit/qiskit-experiments/releases)
![Python](https://img.shields.io/pypi/pyversions/qiskit-experiments.svg?style=popout-square)


**Qiskit Experiments** is a repository that builds tools for building, running,
and analyzing experiments on noisy quantum computers using Qiskit.
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Installation

Qiskit Experiments is built on top of Qiskit, so we recommend that you first install
Qiskit following its :external+qiskit:doc:`installation guide <getting_started>`. Qiskit
Experiments supports the same platforms and Python versions (currently **3.7+**) as
Qiskit itself.
Experiments supports the same platforms as Qiskit itself and Python versions 3.8,
3.9, 3.10, and 3.11.

Qiskit Experiments releases can be installed via the Python package manager ``pip``:

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 100
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
target-version = ['py38', 'py39', 'py310', 'py311']
9 changes: 5 additions & 4 deletions qiskit_experiments/curve_analysis/base_curve_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ def _default_options(cls) -> Options:
instance that defines the `self.__call__` method.
normalization (bool): Set ``True`` to normalize y values within range [-1, 1].
Default to ``False``.
average_method (str): Method to average the y values when the same x values
appear multiple times. One of "sample", "iwv" (i.e. inverse weighted variance),
"shots_weighted". See :func:`.mean_xy_data` for details. Default to
"shots_weighted".
average_method (Literal["sample", "iwv", "shots_weighted"]): Method
to average the y values when the same x values
appear multiple times. One of "sample", "iwv" (i.e. inverse
weighted variance), "shots_weighted". See :func:`.mean_xy_data`
for details. Default to "shots_weighted".
p0 (Dict[str, float]): Initial guesses for the fit parameters.
The dictionary is keyed on the fit parameter names.
bounds (Dict[str, Tuple[float, float]]): Boundary of fit parameters.
Expand Down
1 change: 1 addition & 0 deletions qiskit_experiments/framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@
)
from .json import ExperimentEncoder, ExperimentDecoder
from .restless_mixin import RestlessMixin
from .package_deps import numpy_version
21 changes: 21 additions & 0 deletions qiskit_experiments/framework/package_deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
Functions for checking dependency versions.
"""

from importlib.metadata import version


def numpy_version():
"""Returns the current numpy version in (major, minor) form."""
return tuple(map(int, version("numpy").split(".")[:2]))
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,7 @@ def _transpiled_circuits(self) -> List[QuantumCircuit]:
inst_prop = self.backend.target[op_name].get(qargs, None)
if inst_prop is None:
continue
try:
schedule = inst_prop.calibration
except AttributeError:
# TODO remove after qiskit-terra/#9681 is in stable release.
schedule = None
schedule = inst_prop.calibration
if schedule is None:
continue
publisher = schedule.metadata.get("publisher", CalibrationPublisher.QISKIT)
Expand Down
3 changes: 2 additions & 1 deletion qiskit_experiments/library/tomography/qpt_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def _default_options(cls) -> Options:
preparation_qubits (Sequence[int]): Optional, the physical qubits with tomographic
preparations. If not specified will be set to ``[0, ..., N-1]`` for N-qubit
tomographic preparations.
This can be a string to select one of the built-in fitters, or a callable to
fitter (str or Callable): The fitter function to use for reconstruction.
This can be a string to select one of the built-in fitters, or a callable to
supply a custom fitter function. See the `Fitter Functions` section for
additional information.
target (str or
Expand Down
2 changes: 1 addition & 1 deletion qiskit_experiments/library/tomography/qst_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _default_options(cls) -> Options:
:class:`~qiskit_experiments.library.tomography.basis.MeasurementBasis`
to use for tomographic state reconstruction.
fitter (str or Callable): The fitter function to use for reconstruction.
This can be a string to select one of the built-in fitters, or a callable to
This can be a string to select one of the built-in fitters, or a callable to
supply a custom fitter function. See the `Fitter Functions` section for
additional information.
fitter_options (dict): Any addition kwarg options to be supplied to the fitter
Expand Down
17 changes: 9 additions & 8 deletions qiskit_experiments/library/tomography/tomography_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from qiskit.quantum_info.operators.channel.quantum_channel import QuantumChannel

from qiskit_experiments.exceptions import AnalysisError
from qiskit_experiments.framework import BaseAnalysis, AnalysisResultData, Options
from qiskit_experiments.framework import BaseAnalysis, AnalysisResultData, Options, numpy_version
from .fitters import (
tomography_fitter_data,
postprocess_fitter,
Expand Down Expand Up @@ -326,13 +326,14 @@ def _fidelity_result(
prob_data = outcome_data / shot_data[None, :, None]
bs_fidelities = []
for _ in range(self.options.target_bootstrap_samples):
# Once python 3.7 support is dropped and minimum NumPy
# version can be set to 1.22 this can be replaced with
# `sampled_data = rng.multinomial(shot_data, probs)`
sampled_data = np.zeros_like(outcome_data)
for i in range(prob_data.shape[0]):
for j in range(prob_data.shape[1]):
sampled_data[i, j] = rng.multinomial(shot_data[j], prob_data[i, j])
# TODO: remove conditional once numpy is pinned at 1.22 and above
if numpy_version() >= (1, 22):
sampled_data = rng.multinomial(shot_data, prob_data)
else:
sampled_data = np.zeros_like(outcome_data)
for i in range(prob_data.shape[0]):
for j in range(prob_data.shape[1]):
sampled_data[i, j] = rng.multinomial(shot_data[j], prob_data[i, j])

try:
state_results = self._fit_state_results(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Dropped support for Python 3.7.
5 changes: 1 addition & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ qiskit-aer>=0.11.0
pandas>=1.1.5
cvxpy>=1.1.15
pylatexenc
# Pin `importlib-metadata` because of a bug relating to version 5.0.0. See #931 for more.
importlib-metadata==4.13.0;python_version<'3.8'
scikit-learn
sphinx-copybutton
# Pin versions below because of build errors
ipykernel<=6.21.3
jupyter-client<=8.0.3
# Pin symengine because there are no wheels for 0.10 for Python 3.7
symengine<=0.9.2;python_version<'3.8'

3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -61,7 +60,7 @@
packages=find_packages(exclude=["test*"]),
install_requires=REQUIREMENTS,
include_package_data=True,
python_requires=">=3.7",
python_requires=">=3.8",
project_urls={
"Bug Tracker": "https://github.com/Qiskit/qiskit-experiments/issues",
"Documentation": "https://qiskit.org/documentation/",
Expand Down
37 changes: 25 additions & 12 deletions test/visualization/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from qiskit.exceptions import QiskitError

from qiskit_experiments.visualization.utils import DataExtentCalculator
from qiskit_experiments.framework.package_deps import numpy_version


@ddt
Expand All @@ -42,22 +43,34 @@ def _dummy_data(
]

# Iterate over pairs of adjacent bin edges, which define the maximum and minimum for the region.
# This is done by zipping over shifted subarrays of bin_edges as follows:
# This is done by generating sliding windows of bin_edges as follows:
# [[a], [b], [c], [d], [e], [f]], g]
# [a, [[b], [c], [d], [e], [f], [g]]
# The result is a list of pairs representing a moving window of size 2.
# TODO: Replace this with numpy.[...].sliding_window_view when Qiskit requires numpy>=0.20.0
# TODO: remove the old code once numpy is above 1.20.
dummy_data = []
for (x_min, x_max), (y_min, y_max) in it.product(
*tuple(list(zip(b[0:-1], b[1:])) for b in bin_edges)
):
_dummy_data = np.asarray(
[
np.linspace(x_min, x_max, n_points),
np.linspace(y_min, y_max, n_points),
]
)
dummy_data.append(_dummy_data.swapaxes(-1, -2))
if numpy_version() >= (1, 20):
for (x_min, x_max), (y_min, y_max) in it.product(
*np.lib.stride_tricks.sliding_window_view(bin_edges, 2, 1)
):
_dummy_data = np.asarray(
[
np.linspace(x_min, x_max, n_points),
np.linspace(y_min, y_max, n_points),
]
)
dummy_data.append(_dummy_data.swapaxes(-1, -2))
else:
for (x_min, x_max), (y_min, y_max) in it.product(
*tuple(list(zip(b[0:-1], b[1:])) for b in bin_edges)
):
_dummy_data = np.asarray(
[
np.linspace(x_min, x_max, n_points),
np.linspace(y_min, y_max, n_points),
]
)
dummy_data.append(_dummy_data.swapaxes(-1, -2))
return dummy_data

@data(*list(it.product([1.0, 1.1, 2.0], [None, 1.0, np.sqrt(2)])))
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 3.3.0
envlist = py311,py310,py39,py38,py37,lint
envlist = py311,py310,py39,py38,lint
isolated_build = true

[testenv]
Expand Down