Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@
}
],
"source": [
"job = execute(qprog)\n",
"job.get_sample_result().dataframe"
"execute(qprog).get_sample_result().dataframe"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions algorithms/metrology/classical_shadow_tomography.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@
" # list of parameter sets, `sample` returns one DataFrame per element;\n",
" # with `num_shots=1`, each frame has exactly one row whose `qarr`\n",
" # entry is the measured bitstring as a list of ints.\n",
" result_dfs = sample(\n",
" dfs = sample(\n",
" qprog,\n",
" parameters=param_batch,\n",
" num_shots=1,\n",
" random_seed=int(np.random.randint(1e6)),\n",
" )\n",
" snapshots = [list(df[\"qarr\"].iloc[0]) for df in result_dfs]\n",
" snapshots = [list(df[\"qarr\"].iloc[0]) for df in dfs]\n",
"\n",
" return snapshots, ids"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@
"\n",
"# Execute the quantum circuit\n",
"print(\"Executing quantum circuit...\")\n",
"result = execute(qprog_point_add).result()\n",
"result = execute(qprog_point_add).result_value()\n",
"print(\"Execution complete.\")"
]
},
Expand All @@ -745,7 +745,7 @@
],
"source": [
"# Extract quantum results\n",
"quantum_results = result[0].value.parsed_counts[0].state\n",
"quantum_results = result.parsed_counts[0].state\n",
"ec_point_result = [quantum_results[\"ecp\"][\"x\"], quantum_results[\"ecp\"][\"y\"]]\n",
"# Verify the result\n",
"assert len(quantum_results)\n",
Expand Down Expand Up @@ -903,7 +903,7 @@
"metadata": {},
"outputs": [],
"source": [
"res = execute(qprog_shor_ecdlp).result_value()"
"result_shor = execute(qprog_shor_ecdlp).result_value()"
]
},
{
Expand Down Expand Up @@ -944,7 +944,7 @@
}
],
"source": [
"df = res.dataframe\n",
"df = result_shor.dataframe\n",
"df_sorted = df.sort_values(\"counts\", ascending=False)\n",
"df_sorted[\"probability\"] = df_sorted[\"counts\"] / df[\"counts\"].sum()\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@
}
],
"source": [
"sample_results_simple = execute(qprog_simple).result_value()\n",
"sample_results_simple.counts_of_output(\"s\")"
"result_simple = execute(qprog_simple).result_value()\n",
"result_simple.counts_of_output(\"s\")"
]
},
{
Expand Down Expand Up @@ -308,8 +308,8 @@
}
],
"source": [
"sample_results_complex = execute(qprog_complex).result_value()\n",
"sample_results_complex.counts_of_output(\"s\")"
"result_complex = execute(qprog_complex).result_value()\n",
"result_complex.counts_of_output(\"s\")"
]
},
{
Expand All @@ -320,7 +320,7 @@
"outputs": [],
"source": [
"expected_s = \"\".join(\"1\" if i in shifted_bits else \"0\" for i in range(NUM_VARIABLES))\n",
"assert list(sample_results_complex.counts_of_output(\"s\").keys())[0] == expected_s"
"assert list(result_complex.counts_of_output(\"s\").keys())[0] == expected_s"
]
},
{
Expand Down Expand Up @@ -406,7 +406,7 @@
"metadata": {},
"outputs": [],
"source": [
"sample_results_no_dual = execute(qprog_no_dual).result_value()"
"result_no_dual = execute(qprog_no_dual).result_value()"
]
},
{
Expand Down Expand Up @@ -444,9 +444,7 @@
"\n",
"samples = [\n",
" ([int(i) for i in u], int(b))\n",
" for u, b in sample_results_no_dual.counts_of_multiple_outputs(\n",
" [\"target\", \"ind\"]\n",
" ).keys()\n",
" for u, b in result_no_dual.counts_of_multiple_outputs([\"target\", \"ind\"]).keys()\n",
"]\n",
"\n",
"ind_v = []\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
")\n",
"qprog = synthesize(qmod)\n",
"show(qprog)\n",
"res = execute(qprog).get_sample_result()"
"result_amplified = execute(qprog).get_sample_result()"
]
},
{
Expand Down Expand Up @@ -728,7 +728,7 @@
")\n",
"qprog_naive = synthesize(qmod_naive)\n",
"show(qprog_naive)\n",
"res_naive = execute(qprog_naive).get_sample_result()"
"result_naive = execute(qprog_naive).get_sample_result()"
]
},
{
Expand Down Expand Up @@ -786,10 +786,10 @@
}
],
"source": [
"amplitudes_amplified = post_process_res_samples(res)\n",
"amplitudes_amplified = post_process_res_samples(result_amplified)\n",
"print(\"amplified amplitudes:\", amplitudes_amplified)\n",
"\n",
"amplitudes_naive = post_process_res_samples(res_naive)\n",
"amplitudes_naive = post_process_res_samples(result_naive)\n",
"print(\"naive amplitudes:\", amplitudes_naive)\n",
"\n",
"print(\"classical:\", classical_final)"
Expand Down
8 changes: 4 additions & 4 deletions algorithms/quantum_linear_solvers/hhl/hhl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@
"source": [
"from classiq.execution import ExecutionDetails\n",
"\n",
"res_hhl_exact = execute(qprog_hhl_exact).result_value()"
"result_hhl_exact = execute(qprog_hhl_exact).result_value()"
]
},
{
Expand Down Expand Up @@ -708,7 +708,7 @@
],
"source": [
"precision = QPE_SIZE\n",
"show_solutions(A, b, res_hhl_exact, precision, check=False)"
"show_solutions(A, b, result_hhl_exact, precision, check=False)"
]
},
{
Expand Down Expand Up @@ -859,8 +859,8 @@
"print()\n",
"\n",
"# Show results\n",
"res_hhl_trotter = execute(qprog_hhl_trotter).result_value()\n",
"show_solutions(A, b, res_hhl_trotter, precision)"
"result_hhl_trotter = execute(qprog_hhl_trotter).result_value()\n",
"show_solutions(A, b, result_hhl_trotter, precision)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
"metadata": {},
"outputs": [],
"source": [
"results_qpe_naive = execute(qprog_qpe_naive).get_sample_result()"
"result_qpe_naive = execute(qprog_qpe_naive).get_sample_result()"
]
},
{
Expand Down Expand Up @@ -538,7 +538,7 @@
}
],
"source": [
"df_qpe_naive = results_qpe_naive.dataframe\n",
"df_qpe_naive = result_qpe_naive.dataframe\n",
"print(f\"Classical solution:, {classical_sol} Ha\")\n",
"post_processed_df_qpe_naive = get_qpe_walk_result(\n",
" df_qpe_naive, be_scaling, to_plot=True\n",
Expand Down Expand Up @@ -655,7 +655,7 @@
"metadata": {},
"outputs": [],
"source": [
"results_qpe_walk = execute(qprog_qpe_walk).get_sample_result()"
"result_qpe_walk = execute(qprog_qpe_walk).get_sample_result()"
]
},
{
Expand Down Expand Up @@ -686,7 +686,7 @@
}
],
"source": [
"df_qpe_optimized = results_qpe_walk.dataframe\n",
"df_qpe_optimized = result_qpe_walk.dataframe\n",
"print(f\"Classical solution:, {classical_sol} Ha\")\n",
"post_processed_df_qpe_optimized = get_qpe_walk_result(\n",
" df_qpe_optimized, be_scaling, to_plot=True\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,10 @@
" qmod, num_shots=tot_num_shots\n",
")\n",
"qprog_with_execution_preferences = synthesize(qmod_with_execution_preferences)\n",
"job = execute(qprog_with_execution_preferences)\n",
"\n",
"results = job.result_value().counts\n",
"P_0 = (results[\"0\"]) / tot_num_shots\n",
"P_1 = (results[\"1\"]) / tot_num_shots\n",
"result = execute(qprog_with_execution_preferences).result_value().counts\n",
"P_0 = (result[\"0\"]) / tot_num_shots\n",
"P_1 = (result[\"1\"]) / tot_num_shots\n",
"print(r\"P_0={}\".format(P_0))\n",
"print(r\"P_1={}\".format(P_1))"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
")\n",
"qprog = synthesize(qmod)\n",
"show(qprog)\n",
"res = execute(qprog).get_sample_result()"
"result_gibbs = execute(qprog).get_sample_result()"
]
},
{
Expand Down Expand Up @@ -424,7 +424,7 @@
" plt.show()\n",
"\n",
"\n",
"plot_omega_results(res)"
"plot_omega_results(result_gibbs)"
]
},
{
Expand Down Expand Up @@ -484,8 +484,8 @@
" execution_preferences=ExecutionPreferences(num_shots=10000),\n",
")\n",
"qprog = synthesize(qmod)\n",
"res_uniform = execute(qprog).get_sample_result()\n",
"plot_omega_results(res_uniform)"
"result_uniform = execute(qprog).get_sample_result()\n",
"plot_omega_results(result_uniform)"
]
},
{
Expand Down Expand Up @@ -832,8 +832,8 @@
}
],
"source": [
"res = execute(qprog).get_sample_result()\n",
"res.parsed_counts"
"result_gibbs = execute(qprog).get_sample_result()\n",
"result_gibbs.parsed_counts"
]
},
{
Expand Down Expand Up @@ -864,7 +864,7 @@
"source": [
"samples = dict(\n",
" (int(\"\".join(map(str, reversed(s.state[\"be\"].state))), 2), s.shots)\n",
" for s in res.parsed_counts\n",
" for s in result_gibbs.parsed_counts\n",
")\n",
"measured_probs = np.array([v for k, v in sorted(samples.items())])\n",
"measured_probs = measured_probs / sum(measured_probs)\n",
Expand Down
8 changes: 4 additions & 4 deletions algorithms/quantum_walks/glued_trees/glued_trees.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@
" qprogs.append(qprog)\n",
"\n",
" time_points = [2 * n + i for i in range(-12, 13, 2)]\n",
" results = sample(\n",
" dfs = sample(\n",
" qprog, parameters=[{\"t\": float(t)} for t in time_points], num_shots=8192\n",
" )\n",
" return results, time_points"
" return dfs, time_points"
]
},
{
Expand Down Expand Up @@ -350,7 +350,7 @@
"metadata": {},
"outputs": [],
"source": [
"def graph_results(qubits, results, time_points):\n",
"def graph_results(qubits, dfs, time_points):\n",
" n = qubits - 2\n",
" exit_state = 2 ** (n + 1) - 3\n",
" data = [\n",
Expand All @@ -359,7 +359,7 @@
" if (df[\"state\"] == exit_state).any()\n",
" else 0.0\n",
" )\n",
" for df in results\n",
" for df in dfs\n",
" ]\n",
" plt.plot(time_points, data, \"o-\")\n",
" plt.xlabel(\"Time (s)\")\n",
Expand Down
22 changes: 11 additions & 11 deletions algorithms/search_and_optimization/dqi/dqi_max_xorsat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@
"\n",
"\n",
"qprog_one_hot = synthesize(main)\n",
"res_one_hot = execute(qprog_one_hot).get_sample_result()\n",
"res_one_hot.dataframe"
"result_one_hot = execute(qprog_one_hot).get_sample_result()\n",
"result_one_hot.dataframe"
]
},
{
Expand Down Expand Up @@ -352,8 +352,8 @@
"\n",
"\n",
"qprog_dicke = synthesize(main)\n",
"res_dicke = execute(qprog_dicke).get_sample_result()\n",
"res_dicke.dataframe.head(7)"
"result_dicke = execute(qprog_dicke).get_sample_result()\n",
"result_dicke.dataframe.head(7)"
]
},
{
Expand Down Expand Up @@ -478,8 +478,8 @@
"\n",
"\n",
"qprog_dicke_unary_input = synthesize(main)\n",
"res_dicke_unary_input = execute(qprog_dicke_unary_input).get_sample_result()\n",
"res_dicke_unary_input.dataframe.head(7)"
"result_dicke_unary_input = execute(qprog_dicke_unary_input).get_sample_result()\n",
"result_dicke_unary_input.dataframe.head(7)"
]
},
{
Expand Down Expand Up @@ -1073,8 +1073,8 @@
}
],
"source": [
"res = execute(qprog).get_sample_result()\n",
"res.dataframe"
"result = execute(qprog).get_sample_result()\n",
"result.dataframe"
]
},
{
Expand All @@ -1092,7 +1092,7 @@
"metadata": {},
"outputs": [],
"source": [
"assert sum(sum(sample.state[\"y\"]) for sample in res.parsed_counts) == 0"
"assert sum(sum(sample.state[\"y\"]) for sample in result.parsed_counts) == 0"
]
},
{
Expand Down Expand Up @@ -1152,8 +1152,8 @@
"f_sampled = []\n",
"shots = []\n",
"\n",
"# Populate f_sampled and shots based on res.parsed_counts\n",
"for sample in res.parsed_counts:\n",
"# Populate f_sampled and shots based on result.parsed_counts\n",
"for sample in result.parsed_counts:\n",
" solution = sample.state[\"solution\"]\n",
" f_sampled.append(((-1) ** (B @ solution + v)).sum())\n",
" shots.append(sample.shots)\n",
Expand Down
10 changes: 5 additions & 5 deletions applications/CFD/qlbm/qlbm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,8 @@
"outputs": [],
"source": [
"with ExecutionSession(qprog) as es:\n",
" results = es.sample()\n",
"table = results.dataframe.to_numpy()"
" result = es.sample()\n",
"table = result.dataframe.to_numpy()"
]
},
{
Expand Down Expand Up @@ -935,7 +935,7 @@
}
],
"source": [
"results.dataframe.head()"
"result.dataframe.head()"
]
},
{
Expand Down Expand Up @@ -976,8 +976,8 @@
"\n",
"\n",
"# 2D distribution\n",
"p_xy = get_p(results.dataframe, jx=0, jy=1, n=GRID_LENGTH)\n",
"p_u_xy = get_p(results.dataframe, jx=4, jy=5, n=n_u_i)"
"p_xy = get_p(result.dataframe, jx=0, jy=1, n=GRID_LENGTH)\n",
"p_u_xy = get_p(result.dataframe, jx=4, jy=5, n=n_u_i)"
]
},
{
Expand Down
Loading
Loading