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

Makes Notebooks a part of testing (Issue 74) #123

Merged
merged 18 commits into from
May 20, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ venv.bak/
.mypy_cache/

.idea/

5 changes: 5 additions & 0 deletions examples/distance_measures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
"metadata": {},
"outputs": [],
"source": [
"# NBVAL_SKIP\n",
"# our build environment has problems with cvxpy so we skip this cell\n",
"\n",
"dnorm = dm.diamond_norm_distance(choi0, choi1)\n",
"print(\"This gate is close to the identity as the diamond norm is close to zero. Dnorm= \",dnorm)"
]
Expand All @@ -258,6 +261,8 @@
"metadata": {},
"outputs": [],
"source": [
"# NBVAL_SKIP\n",
"\n",
"dnorm = dm.diamond_norm_distance(choi0, choi2)\n",
"print(\"This gate is far from identity as diamond norm = \",dnorm)"
]
Expand Down
4 changes: 2 additions & 2 deletions examples/robust_phase_estimation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"source": [
"from pyquil import Program\n",
"from pyquil.quil import DefGate, Gate\n",
"from forest.benchmarking.utils import sigma_x, sigma_y, sigma_z\n",
"from forest.benchmarking.utils import X, Y, Z\n",
"\"\"\"\n",
"Procedure and notation follows Sections III A, B, and C in \n",
"[RPE] Robust Calibration of a Universal Single-Qubit Gate-Set via Robust Phase Estimation\n",
Expand All @@ -393,7 +393,7 @@
"\"\"\" \n",
"q = 0 # pick a qubit\n",
"\n",
"pauli_vector = np.array([sigma_x, sigma_y, sigma_z])\n",
"pauli_vector = np.array([X, Y, Z])\n",
"\n",
"alpha = .01\n",
"epsilon = .02\n",
Expand Down
32 changes: 5 additions & 27 deletions examples/tomography_process.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"# version that *only* substitutes gates to Rigetti-native gates.\n",
"# We don't want to accidentally compile away our tomography circuit\n",
"# or map to different qubits.\n",
"from forest_benchmarking.compilation import basic_compile\n",
"from forest.benchmarking.compilation import basic_compile\n",
"qc.compiler.quil_to_native_quil = basic_compile\n",
"\n",
"results = list(measure_observables(qc=qc, tomo_experiment=experiment, n_shots=100_000))\n",
Expand Down Expand Up @@ -130,39 +130,17 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'process_choi_ideal' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m--------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-7-cb314dff65b7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mfig\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0max1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0max2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubplots\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfigsize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m12\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mplot_pauli_transfer_matrix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchoi2pauli_liouville\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprocess_choi_ideal\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0max1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtitle\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'Ideal'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mplot_pauli_transfer_matrix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchoi2pauli_liouville\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprocess_choi_est\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0max2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtitle\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'Estimate'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtight_layout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'process_choi_ideal' is not defined"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsoAAAEzCAYAAAAo4yUMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAEUpJREFUeJzt3VGIpXd5x/HfY7ap1EYtz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cYkdyRJd381yYuTnL8l022fSf/ezyB2tp2dnH07O7G3E3s72cDO3uxQ3olvpbrmOVfVG5J8LIuFe6b/DlSyxjl391PdfX53X9TdF2XxO37XdPeG3nf9BWDK9/Xns3hWIlV1fhY/0nt0K4ec2ZRz/n6SNydJVb02i4V7Ykun3HqHk7xt+Urqy5M81d0/3O6hToOdbWefjTs7sbft7YX17+wteAXi1Vn8X9l3krxved2tWfyjSxYPymeTHEvyX0levdkzvQDO+T+S/E+Sry8/Dm/3zJt9zicd++Wc+a+gXusxrix+dPlQkm8muW67Z96Cc96f5CtZvLL660n+ZLtnnuGcP53kh0l+mcWzTTcmeWeSd656nA8u/5t880z/vp74ONvZdvYZ+WFvn/17ezN2tnfmAwCAAe/MBwAAA0IZAAAGhDIAAAwIZQAAGBDKAAAwIJQBAGBAKAMAwIBQBgCAgf8DeRSHmZAsNtUAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x12c740240>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from forest.benchmarking.superoperator_tools import choi2pauli_liouville\n",
"from forest.benchmarking.plotting.state_process import plot_pauli_transfer_matrix\n",
"\n",
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12,5))\n",
"plot_pauli_transfer_matrix(choi2pauli_liouville(process_choi_ideal), ax1, title='Ideal')\n",
"plot_pauli_transfer_matrix(choi2pauli_liouville(process_choi_est), ax2, title='Estimate')\n",
"plot_pauli_transfer_matrix(np.real(choi2pauli_liouville(process_choi_ideal)), ax1, title='Ideal')\n",
"plot_pauli_transfer_matrix(np.real(choi2pauli_liouville(process_choi_est)), ax2, title='Estimate')\n",
"plt.tight_layout()"
]
},
Expand Down
1 change: 1 addition & 0 deletions forest/benchmarking/plotting/state_process.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import matplotlib.pyplot as plt
import itertools
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

Expand Down
16 changes: 16 additions & 0 deletions forest/benchmarking/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,19 @@ def side_effect(as_dict=True):
return {acorn, agave}
mocked_function.side_effect = side_effect
return mocked_function


def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)


def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)
196 changes: 196 additions & 0 deletions forest/benchmarking/tests/test_example_notebooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import pytest
from os.path import dirname, join, realpath
from subprocess import PIPE, run

EXAMPLES_PATH = join(dirname(realpath(__file__)), '..', '..', '..', 'examples')


# from https://stackoverflow.com/a/36058256
def out(command):
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True)
return result.stdout


def run_notebook(filename: str):
return out('pytest --nbval-lax ' + EXAMPLES_PATH + f'/{filename}')


def _is_not_empty_str(string: str) -> bool:
# bool(string) tests if the string is empty
# bool(string.strip()) tests if the string is full of spaces
return bool(string and string.strip())


def check_for_failure_and_empty_output(output: str):
'''
Searches the string for the word 'failed' and checks if the string is empty of full of spaces.
If any of those conditions are met False is returned.

:param output: stdout from 'pytest --nbval-lax notebook.ipynb'
:return: bool
'''
return (output.find('failed') is -1) and _is_not_empty_str(output)


# NOTES:
# (1) By using the command `out` we are accessing the command line and running the basic command:
#
# >pytest --nbval-lax some_notebook.ipynb
#
# The --nbval flag runs the notebook validation plugin (to collect and test notebook cells,
# comparing their outputs with those saved in the file). By adding the optional -lax flag we fail
# if there is an error in executing a cell.
#
# (2) We are skipping any test that is longer than 30 seconds.
#
# (3) Each test function has a print, if the test fails then you can see where it fails from stdout.


# TODO: go through the slow notebooks and add the comment `# NBVAL_SKIP` on the offending slow
# cells. This will allow us to test imports and other functionality without sacrificing runtime.


# ~ 6 min; passed 2019/05/13
@pytest.mark.slow
def test_direct_fidelity_estimation_nb():
# print(out('ls'))
output_str = run_notebook('direct_fidelity_estimation.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_distance_measures_nb():
output_str = run_notebook('distance_measures.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_direct_entangled_states_nb():
output_str = run_notebook('entangled_states.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_Hinton_Plots_nb():
output_str = run_notebook('Hinton-Plots.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~17 min; passed 2019/05/13
@pytest.mark.slow
def test_quantum_volume_nb():
output_str = run_notebook('quantum_volume.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_qubit_spectroscopy_cz_ramsey_nb():
output_str = run_notebook('qubit_spectroscopy_cz_ramsey.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_qubit_spectroscopy_rabi_nb():
output_str = run_notebook('qubit_spectroscopy_rabi.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_qubit_spectroscopy_t1_nb():
output_str = run_notebook('qubit_spectroscopy_t1.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_qubit_spectroscopy_t2_nb():
output_str = run_notebook('qubit_spectroscopy_t2.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 sec
def test_random_operators_nb():
output_str = run_notebook('random_operators.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~5 min; passed 2019/05/13
@pytest.mark.slow
def test_randomized_benchmarking_interleaved_nb():
output_str = run_notebook('randomized_benchmarking_interleaved.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~14 sec
def test_randomized_benchmarking_simultaneous_nb():
output_str = run_notebook('randomized_benchmarking_simultaneous.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~7 min; passed 2019/05/13
@pytest.mark.slow
def test_randomized_benchmarking_unitarity_nb():
output_str = run_notebook('randomized_benchmarking_unitarity.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~3 sec
def test_readout_fidelity_nb():
output_str = run_notebook('readout_fidelity.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~4 sec
def test_ripple_adder_benchmark_nb():
output_str = run_notebook('ripple_adder_benchmark.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~40 sec; passed 2019/05/13
@pytest.mark.slow
def test_robust_phase_estimation_nb():
output_str = run_notebook('robust_phase_estimation.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~10 sec
def test_state_and_process_plots_nb():
output_str = run_notebook('state_and_process_plots.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# ~4 sec
def test_superoperator_tools_nb():
output_str = run_notebook('superoperator_tools.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)


# Notebook fails at the moment
joshcombes marked this conversation as resolved.
Show resolved Hide resolved
# def test_tomography_process_nb():
# output_str = run_notebook('tomography_process.ipynb')
# print(output_str)
# assert output_str.find('failed') is -1


# ~4 sec
def test_tomography_state_nb():
output_str = run_notebook('tomography_state.ipynb')
print(output_str)
assert check_for_failure_and_empty_output(output_str)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ scikit-learn
# doc dependencies
sphinx
sphinx-autodoc-typehints

# for testing examples
nbval