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

Code for saving state tomography data in notebook #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions examples/tomography_state.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down