diff --git a/examples/tomography_state.ipynb b/examples/tomography_state.ipynb index 2e952e98..8e8ca3c9 100644 --- a/examples/tomography_state.ipynb +++ b/examples/tomography_state.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": {},