From 63068e69e0cde62c5e860e1a708d620ffff303d8 Mon Sep 17 00:00:00 2001 From: Matthew Harrigan Date: Wed, 30 Jan 2019 11:07:36 -0800 Subject: [PATCH] Code for saving tomography data --- examples/state_tomography.ipynb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/examples/state_tomography.ipynb b/examples/state_tomography.ipynb index 2e952e98..8e8ca3c9 100644 --- a/examples/state_tomography.ipynb +++ b/examples/state_tomography.ipynb @@ -105,6 +105,34 @@ "results" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### We'll optionally save the raw data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def program_slug(program):\n", + " lines = program.out().splitlines()\n", + " return '-'.join(l.replace(' ', '-') for l in lines)\n", + "\n", + "def state_tomo_filename(qc, experiment):\n", + " from datetime import date\n", + " return f'{date.today().isoformat()}_{qc.name}_state-tomo_{program_slug(experiment.program)}.json'\n", + "\n", + "print(state_tomo_filename(qc, experiment))\n", + "\n", + "## Uncomment below to save:\n", + "# from pyquil.operator_estimation import to_json, _abbrev_program\n", + "# to_json(fn=state_tomo_filename(qc, experiment), obj=(experiment, results))" + ] + }, { "cell_type": "markdown", "metadata": {},