diff --git a/algorithms/foundational/quantum_teleportation/quantum_teleportation.ipynb b/algorithms/foundational/quantum_teleportation/quantum_teleportation.ipynb index c5ad5fa29..877487201 100644 --- a/algorithms/foundational/quantum_teleportation/quantum_teleportation.ipynb +++ b/algorithms/foundational/quantum_teleportation/quantum_teleportation.ipynb @@ -344,8 +344,7 @@ } ], "source": [ - "job = execute(qprog)\n", - "job.get_sample_result().dataframe" + "execute(qprog).get_sample_result().dataframe" ] }, { diff --git a/algorithms/metrology/classical_shadow_tomography.ipynb b/algorithms/metrology/classical_shadow_tomography.ipynb index bac0b5196..e7b7d6b94 100644 --- a/algorithms/metrology/classical_shadow_tomography.ipynb +++ b/algorithms/metrology/classical_shadow_tomography.ipynb @@ -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" ] diff --git a/algorithms/number_theory_and_cryptography/elliptic_curves/elliptic_curve_discrete_log.ipynb b/algorithms/number_theory_and_cryptography/elliptic_curves/elliptic_curve_discrete_log.ipynb index 027e0d339..e9181f5b4 100644 --- a/algorithms/number_theory_and_cryptography/elliptic_curves/elliptic_curve_discrete_log.ipynb +++ b/algorithms/number_theory_and_cryptography/elliptic_curves/elliptic_curve_discrete_log.ipynb @@ -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.\")" ] }, @@ -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", @@ -903,7 +903,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = execute(qprog_shor_ecdlp).result_value()" + "result_shor = execute(qprog_shor_ecdlp).result_value()" ] }, { @@ -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", diff --git a/algorithms/number_theory_and_cryptography/hidden_shift/hidden_shift.ipynb b/algorithms/number_theory_and_cryptography/hidden_shift/hidden_shift.ipynb index 01347d71e..ca4950531 100644 --- a/algorithms/number_theory_and_cryptography/hidden_shift/hidden_shift.ipynb +++ b/algorithms/number_theory_and_cryptography/hidden_shift/hidden_shift.ipynb @@ -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\")" ] }, { @@ -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\")" ] }, { @@ -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" ] }, { @@ -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()" ] }, { @@ -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", diff --git a/algorithms/quantum_differential_equations_solvers/time_marching/time_marching.ipynb b/algorithms/quantum_differential_equations_solvers/time_marching/time_marching.ipynb index 7a23427ee..5d96e3777 100644 --- a/algorithms/quantum_differential_equations_solvers/time_marching/time_marching.ipynb +++ b/algorithms/quantum_differential_equations_solvers/time_marching/time_marching.ipynb @@ -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()" ] }, { @@ -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()" ] }, { @@ -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)" diff --git a/algorithms/quantum_linear_solvers/hhl/hhl.ipynb b/algorithms/quantum_linear_solvers/hhl/hhl.ipynb index f87dcd047..4f84d5b32 100644 --- a/algorithms/quantum_linear_solvers/hhl/hhl.ipynb +++ b/algorithms/quantum_linear_solvers/hhl/hhl.ipynb @@ -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()" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { diff --git a/algorithms/quantum_phase_estimation/qpe_with_qubitization/qpe_for_molecule_with_qubitization.ipynb b/algorithms/quantum_phase_estimation/qpe_with_qubitization/qpe_for_molecule_with_qubitization.ipynb index 5b19ac479..5b7a88c22 100644 --- a/algorithms/quantum_phase_estimation/qpe_with_qubitization/qpe_for_molecule_with_qubitization.ipynb +++ b/algorithms/quantum_phase_estimation/qpe_with_qubitization/qpe_for_molecule_with_qubitization.ipynb @@ -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()" ] }, { @@ -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", @@ -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()" ] }, { @@ -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", diff --git a/algorithms/quantum_primitives/hadamard_test/hadamard_test.ipynb b/algorithms/quantum_primitives/hadamard_test/hadamard_test.ipynb index 0af68ab7f..36266d61d 100644 --- a/algorithms/quantum_primitives/hadamard_test/hadamard_test.ipynb +++ b/algorithms/quantum_primitives/hadamard_test/hadamard_test.ipynb @@ -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))" ] diff --git a/algorithms/quantum_state_preparation/gibbs/quantum_thermal_state_preparation.ipynb b/algorithms/quantum_state_preparation/gibbs/quantum_thermal_state_preparation.ipynb index b25e9bb03..1e8674c79 100644 --- a/algorithms/quantum_state_preparation/gibbs/quantum_thermal_state_preparation.ipynb +++ b/algorithms/quantum_state_preparation/gibbs/quantum_thermal_state_preparation.ipynb @@ -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()" ] }, { @@ -424,7 +424,7 @@ " plt.show()\n", "\n", "\n", - "plot_omega_results(res)" + "plot_omega_results(result_gibbs)" ] }, { @@ -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)" ] }, { @@ -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" ] }, { @@ -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", diff --git a/algorithms/quantum_walks/glued_trees/glued_trees.ipynb b/algorithms/quantum_walks/glued_trees/glued_trees.ipynb index 4b9ed5bed..e58e0536d 100644 --- a/algorithms/quantum_walks/glued_trees/glued_trees.ipynb +++ b/algorithms/quantum_walks/glued_trees/glued_trees.ipynb @@ -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" ] }, { @@ -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", @@ -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", diff --git a/algorithms/search_and_optimization/dqi/dqi_max_xorsat.ipynb b/algorithms/search_and_optimization/dqi/dqi_max_xorsat.ipynb index 6fcc484c5..be6803186 100644 --- a/algorithms/search_and_optimization/dqi/dqi_max_xorsat.ipynb +++ b/algorithms/search_and_optimization/dqi/dqi_max_xorsat.ipynb @@ -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" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -1073,8 +1073,8 @@ } ], "source": [ - "res = execute(qprog).get_sample_result()\n", - "res.dataframe" + "result = execute(qprog).get_sample_result()\n", + "result.dataframe" ] }, { @@ -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" ] }, { @@ -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", diff --git a/applications/CFD/qlbm/qlbm.ipynb b/applications/CFD/qlbm/qlbm.ipynb index 6b328aacd..83b6fea15 100644 --- a/applications/CFD/qlbm/qlbm.ipynb +++ b/applications/CFD/qlbm/qlbm.ipynb @@ -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()" ] }, { @@ -935,7 +935,7 @@ } ], "source": [ - "results.dataframe.head()" + "result.dataframe.head()" ] }, { @@ -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)" ] }, { diff --git a/applications/automotive/cooling_systems_optimization/cooling_systems_optimization.ipynb b/applications/automotive/cooling_systems_optimization/cooling_systems_optimization.ipynb index 14f0c7cc1..fdc289674 100644 --- a/applications/automotive/cooling_systems_optimization/cooling_systems_optimization.ipynb +++ b/applications/automotive/cooling_systems_optimization/cooling_systems_optimization.ipynb @@ -464,7 +464,7 @@ " return real_part + 1j * imag_part\n", "\n", "\n", - "def block_encoding_from_results(res, excluded_var_names=[]):\n", + "def block_encoding_from_results(result, excluded_var_names=[]):\n", " \"\"\"\n", " assuming `data_ref` is tagging the entries, and `data`is the result\n", " of the block encoding operation.\n", @@ -473,9 +473,9 @@ " excluded_var_names - names of quantum variables that are not part of the \"block\" variables,\n", " see the example with 'u' in the conditional block encoding\n", " \"\"\"\n", - " encoded_matrix_size = 2 ** len(res[0].value.output_qubits_map[\"data\"])\n", + " encoded_matrix_size = 2 ** len(result.output_qubits_map[\"data\"])\n", " A = np.zeros((encoded_matrix_size, encoded_matrix_size), dtype=complex)\n", - " for s in res[0].value.parsed_state_vector:\n", + " for s in result.parsed_state_vector:\n", "\n", " block = True\n", " for var_name, var_val in s.state.items():\n", @@ -554,8 +554,8 @@ } ], "source": [ - "res_block_encoding = execute(qprog_block_encoding).result()\n", - "A = block_encoding_from_results(res_block_encoding)\n", + "result_block_encoding = execute(qprog_block_encoding).result_value()\n", + "A = block_encoding_from_results(result_block_encoding)\n", "block_encoded_matrix = A * 2 / (C_l**2)\n", "print(block_encoded_matrix)" ] @@ -823,24 +823,21 @@ "metadata": {}, "outputs": [], "source": [ - "matrix_inverse_res = execute(matrix_inverse_qprog).result()\n", + "result_matrix_inverse = execute(matrix_inverse_qprog).result_value()\n", "\n", "# extract the result\n", "T_tilde = np.zeros(4, dtype=complex)\n", - "for i in range(len(matrix_inverse_res[0].value.parsed_state_vector)):\n", - " q_dict = matrix_inverse_res[0].value.parsed_state_vector[i][\"qsvt_state\"]\n", + "for i in range(len(result_matrix_inverse.parsed_state_vector)):\n", + " q_dict = result_matrix_inverse.parsed_state_vector[i][\"qsvt_state\"]\n", " temp = 0\n", " temp += q_dict[\"qsvt_aux\"]\n", " temp += q_dict[\"state\"][\"block\"][\"lcu_aux\"]\n", " temp += q_dict[\"state\"][\"block\"][\"flag\"]\n", " temp += q_dict[\"state\"][\"block\"][\"aux\"]\n", - " if (\n", - " temp == 0\n", - " and abs(matrix_inverse_res[0].value.parsed_state_vector[i].amplitude) > 1e-5\n", - " ):\n", + " if temp == 0 and abs(result_matrix_inverse.parsed_state_vector[i].amplitude) > 1e-5:\n", " T_tilde[\n", " int(str(q_dict[\"state\"][\"data\"][1]) + str(q_dict[\"state\"][\"data\"][0]), 2)\n", - " ] = abs(matrix_inverse_res[0].value.parsed_state_vector[i].amplitude)" + " ] = abs(result_matrix_inverse.parsed_state_vector[i].amplitude)" ] }, { diff --git a/applications/chemistry/qpe_for_molecules/qpe_for_molecules.ipynb b/applications/chemistry/qpe_for_molecules/qpe_for_molecules.ipynb index 32adbf3d3..85930e852 100644 --- a/applications/chemistry/qpe_for_molecules/qpe_for_molecules.ipynb +++ b/applications/chemistry/qpe_for_molecules/qpe_for_molecules.ipynb @@ -611,7 +611,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = execute(qprog).result_value()" + "result = execute(qprog).result_value()" ] }, { @@ -650,8 +650,8 @@ } ], "source": [ - "phase_counts = res.parsed_counts_of_outputs(\"phase\")\n", - "num_shots = res.num_shots\n", + "phase_counts = result.parsed_counts_of_outputs(\"phase\")\n", + "num_shots = result.num_shots\n", "\n", "energy_results = {\n", " sample.state[\"phase\"] * normalization + constant_energy: sample.shots / num_shots\n", diff --git a/applications/finance/autocallable_options/partial_exponential_state_preparation.ipynb b/applications/finance/autocallable_options/partial_exponential_state_preparation.ipynb index 7733f77ee..1ba7829d6 100644 --- a/applications/finance/autocallable_options/partial_exponential_state_preparation.ipynb +++ b/applications/finance/autocallable_options/partial_exponential_state_preparation.ipynb @@ -71,7 +71,7 @@ " ),\n", ")\n", "qprog = synthesize(create_model(main, execution_preferences=execution_preferences))\n", - "res = execute(qprog).get_sample_result()" + "result = execute(qprog).get_sample_result()" ] }, { @@ -95,7 +95,7 @@ "def parse_res(r, plot=True):\n", " x = []\n", " amps = []\n", - " r = res\n", + " r = result\n", " for s in r.parsed_state_vector:\n", " if s.state[\"x\"] in x:\n", " amps[x.index(s.state[\"x\"])] += np.abs(s.amplitude)\n", @@ -109,7 +109,7 @@ " return x, amps\n", "\n", "\n", - "x, amps = parse_res(res)" + "x, amps = parse_res(result)" ] }, { @@ -202,8 +202,8 @@ "qprog = synthesize(create_model(main, execution_preferences=execution_preferences))\n", "show(qprog)\n", "\n", - "res = execute(qprog).get_sample_result()\n", - "x, measured_amps = parse_res(res, plot=False)\n", + "result = execute(qprog).get_sample_result()\n", + "x, measured_amps = parse_res(result, plot=False)\n", "\n", "# compare to expected amplitudes\n", "grid = np.arange(X0, X1 + 1)\n", @@ -328,8 +328,8 @@ "qprog = synthesize(qmod)\n", "show(qprog)\n", "\n", - "res = execute(qprog).get_sample_result()\n", - "x, measured_amps = parse_res(res, plot=False)\n", + "result = execute(qprog).get_sample_result()\n", + "x, measured_amps = parse_res(result, plot=False)\n", "\n", "# compare to expected amplitudes\n", "grid = np.arange(X0, X1 + 1)\n", @@ -359,7 +359,7 @@ "metadata": {}, "outputs": [], "source": [ - "x, measured_amps = parse_res(res, plot=False)\n", + "x, measured_amps = parse_res(result, plot=False)\n", "for i, amp in zip(x, measured_amps):\n", " if i >= X0 and i <= X1:\n", " assert np.isclose(amp, expected_amps[i - X0], atol=0.01)" diff --git a/applications/finance/hybrid_hhl_for_portfolio_optimization/portfolio_optimization_with_hhl.ipynb b/applications/finance/hybrid_hhl_for_portfolio_optimization/portfolio_optimization_with_hhl.ipynb index f2fa0bee2..cb2b413bf 100644 --- a/applications/finance/hybrid_hhl_for_portfolio_optimization/portfolio_optimization_with_hhl.ipynb +++ b/applications/finance/hybrid_hhl_for_portfolio_optimization/portfolio_optimization_with_hhl.ipynb @@ -535,8 +535,8 @@ "from classiq import execute, synthesize\n", "\n", "qprog_qpe = synthesize(qmod_qpe)\n", - "results = execute(qprog_qpe).result()\n", - "res_qpe = results[0].value" + "result_qpe_raw = execute(qprog_qpe).result_value()\n", + "result_qpe = result_qpe_raw" ] }, { @@ -605,9 +605,11 @@ "metadata": {}, "outputs": [], "source": [ - "qpe_eigs = np.array([sample.state[\"phase_result\"] for sample in res_qpe.parsed_counts])\n", + "qpe_eigs = np.array(\n", + " [sample.state[\"phase_result\"] for sample in result_qpe.parsed_counts]\n", + ")\n", "original_eigs = np.array([mat_rescaling ** (-1) * eig - mat_shift for eig in qpe_eigs])\n", - "eigs_prob = np.array([sample.shots / NUM_SHOTS for sample in res_qpe.parsed_counts])\n", + "eigs_prob = np.array([sample.shots / NUM_SHOTS for sample in result_qpe.parsed_counts])\n", "projected_x = np.sqrt(eigs_prob) / original_eigs" ] }, @@ -954,7 +956,7 @@ "outputs": [], "source": [ "qprog_feed_forward_hhl = synthesize(qmod_feed_forward_hhl)\n", - "results_C = execute(qprog_feed_forward_hhl).result()" + "result_C = execute(qprog_feed_forward_hhl).result_value()" ] }, { @@ -1035,11 +1037,11 @@ } ], "source": [ - "res_hhl = results_C[0].value\n", + "result_hhl = result_C\n", "fidelity_C = np.sqrt(\n", - " res_hhl.counts_of_multiple_outputs([\"indicator\", \"test\"])[(\"1\", \"0\")]\n", + " result_hhl.counts_of_multiple_outputs([\"indicator\", \"test\"])[(\"1\", \"0\")]\n", " * 2\n", - " / (res_hhl.counts_of_output(\"indicator\")[\"1\"])\n", + " / (result_hhl.counts_of_output(\"indicator\")[\"1\"])\n", " - 1\n", ")\n", "\n", @@ -1153,13 +1155,13 @@ ")\n", "qprog_hhl_basic = synthesize(qmod_hhl_basic)\n", "show(qprog_hhl_basic)\n", - "results_basic = execute(qprog_hhl_basic).result()\n", + "result_basic = execute(qprog_hhl_basic).result_value()\n", "\n", - "res_hhl_basic = results_basic[0].value\n", + "result_hhl_basic = result_basic\n", "fidelity_basic = np.sqrt(\n", - " res_hhl_basic.counts_of_multiple_outputs([\"indicator\", \"test\"])[(\"1\", \"0\")]\n", + " result_hhl_basic.counts_of_multiple_outputs([\"indicator\", \"test\"])[(\"1\", \"0\")]\n", " * 2\n", - " / (res_hhl_basic.counts_of_output(\"indicator\")[\"1\"])\n", + " / (result_hhl_basic.counts_of_output(\"indicator\")[\"1\"])\n", " - 1\n", ")\n", "\n", diff --git a/applications/finance/portfolio_optimization_hhl/HHL_portfolio.ipynb b/applications/finance/portfolio_optimization_hhl/HHL_portfolio.ipynb index a8b7b65d7..61a8162c3 100644 --- a/applications/finance/portfolio_optimization_hhl/HHL_portfolio.ipynb +++ b/applications/finance/portfolio_optimization_hhl/HHL_portfolio.ipynb @@ -2311,8 +2311,7 @@ "metadata": {}, "outputs": [], "source": [ - "execution_job_id = execute(qprog)\n", - "result = execution_job_id.result_value()" + "result = execute(qprog).result_value()" ] }, { diff --git a/applications/image_processing/quantum_hadamard_edge_detection/quantum_image_edge_detection.ipynb b/applications/image_processing/quantum_hadamard_edge_detection/quantum_image_edge_detection.ipynb index e7b231b8a..ddf1489c2 100644 --- a/applications/image_processing/quantum_hadamard_edge_detection/quantum_image_edge_detection.ipynb +++ b/applications/image_processing/quantum_hadamard_edge_detection/quantum_image_edge_detection.ipynb @@ -521,8 +521,8 @@ "qprog = set_quantum_program_execution_preferences(\n", " qprog, preferences=ExecutionPreferences(num_shots=200000)\n", ")\n", - "res = execute(qprog).result_value()\n", - "res.dataframe" + "result = execute(qprog).result_value()\n", + "result.dataframe" ] }, { @@ -548,7 +548,7 @@ "metadata": {}, "outputs": [], "source": [ - "df = res.dataframe\n", + "df = result.dataframe\n", "edge_df = df[df[\"edge_aux\"] == 1]\n", "\n", "edge_image = np.zeros((n, n))\n", diff --git a/applications/optimization/low_autocorrelation_binary_sequences_problem/evidence_scaling_labs.ipynb b/applications/optimization/low_autocorrelation_binary_sequences_problem/evidence_scaling_labs.ipynb index 437467309..46aefb8f5 100644 --- a/applications/optimization/low_autocorrelation_binary_sequences_problem/evidence_scaling_labs.ipynb +++ b/applications/optimization/low_autocorrelation_binary_sequences_problem/evidence_scaling_labs.ipynb @@ -192,7 +192,7 @@ "source": [ "from classiq import execute\n", "\n", - "res = execute(qprog).result()" + "result = execute(qprog).result_value()" ] }, { @@ -223,7 +223,7 @@ } ], "source": [ - "vqe_result = res[0].value\n", + "vqe_result = result\n", "vqe_result.convergence_graph" ] }, diff --git a/applications/optimization/qaoa_in_qaoa/qaoa_in_qaoa.ipynb b/applications/optimization/qaoa_in_qaoa/qaoa_in_qaoa.ipynb index 0b3a5c3c6..28fa6b258 100644 --- a/applications/optimization/qaoa_in_qaoa/qaoa_in_qaoa.ipynb +++ b/applications/optimization/qaoa_in_qaoa/qaoa_in_qaoa.ipynb @@ -207,10 +207,9 @@ " qmod = set_execution_preferences(qmod, ExecutionPreferences(random_seed=10))\n", " qprog = synthesize(qmod)\n", " show(qprog)\n", - " subgraph_res = execute(qprog)\n", " ordered_solution = get_optimization_solution_from_pyo(\n", " pyo_model=pyo_model,\n", - " vqe_result=subgraph_res.result_value(),\n", + " vqe_result=execute(qprog).result_value(),\n", " penalty_energy=qaoa_config.penalty_energy,\n", " )\n", " # sort by cost and then by count\n", diff --git a/applications/physical_systems/fermi_hubbard_model_1D/fermi_hubbard_1D.ipynb b/applications/physical_systems/fermi_hubbard_model_1D/fermi_hubbard_1D.ipynb index b37f7b68d..e2d9a68e7 100644 --- a/applications/physical_systems/fermi_hubbard_model_1D/fermi_hubbard_1D.ipynb +++ b/applications/physical_systems/fermi_hubbard_model_1D/fermi_hubbard_1D.ipynb @@ -765,7 +765,7 @@ "qprog_state_check = synthesize(qmod_state_check)\n", "\n", "print(\"Circuit depth = \", qprog_state_check.transpiled_circuit.depth)\n", - "res_state_check = execute(qprog_state_check).result_value()" + "result_state_check = execute(qprog_state_check).result_value()" ] }, { @@ -823,7 +823,7 @@ ], "source": [ "# Compare quantum amplitudes with exact diagonalization (Nelec=1)\n", - "qsol = get_quantum_amplitudes(res_state_check)\n", + "qsol = get_quantum_amplitudes(result_state_check)\n", "\n", "# Exact ground state: lowest eigenvector of h\n", "E_exact, Qbar_exact = np.linalg.eigh(h)\n", diff --git a/applications/physical_systems/hhl_lanchester/hhl_lanchester.ipynb b/applications/physical_systems/hhl_lanchester/hhl_lanchester.ipynb index b7400e91f..ee50e0f93 100644 --- a/applications/physical_systems/hhl_lanchester/hhl_lanchester.ipynb +++ b/applications/physical_systems/hhl_lanchester/hhl_lanchester.ipynb @@ -721,7 +721,7 @@ "metadata": {}, "outputs": [], "source": [ - "execution_job_id = execute(qprog_hhl_swap)" + "job = execute(qprog_hhl_swap)" ] }, { @@ -739,7 +739,7 @@ } ], "source": [ - "result = execution_job_id.result_value()\n", + "result = job.result_value()\n", "fidelity_basic = np.sqrt(\n", " result.counts_of_multiple_outputs([\"indicator\", \"test\"])[(\"1\", \"0\")]\n", " * 2\n", @@ -765,7 +765,7 @@ "metadata": {}, "outputs": [], "source": [ - "execution_job_id.open_in_ide()" + "job.open_in_ide()" ] }, { @@ -850,10 +850,10 @@ "metadata": {}, "outputs": [], "source": [ - "execution_job_id = execute(qprog_hhl_basic)\n", - "result = execution_job_id.result_value()\n", + "job = execute(qprog_hhl_basic)\n", + "result = job.result_value()\n", "# statevector = result.state_vector\n", - "execution_job_id.open_in_ide()" + "job.open_in_ide()" ] }, { diff --git a/applications/telecom/radio_access_network/radio_access_network_positioning_antennas.ipynb b/applications/telecom/radio_access_network/radio_access_network_positioning_antennas.ipynb index 9839f2924..c4909d643 100644 --- a/applications/telecom/radio_access_network/radio_access_network_positioning_antennas.ipynb +++ b/applications/telecom/radio_access_network/radio_access_network_positioning_antennas.ipynb @@ -302,7 +302,7 @@ "source": [ "from classiq import execute\n", "\n", - "res = execute(qprog).result()" + "result = execute(qprog).result_value()" ] }, { @@ -335,7 +335,7 @@ "source": [ "from classiq.execution import VQESolverResult\n", "\n", - "vqe_result = res[0].value\n", + "vqe_result = result\n", "vqe_result.convergence_graph" ] }, diff --git a/applications/telecom/resiliency_planning/resiliency_planning_AMD.ipynb b/applications/telecom/resiliency_planning/resiliency_planning_AMD.ipynb index e4e5b173f..dcd4c66fb 100644 --- a/applications/telecom/resiliency_planning/resiliency_planning_AMD.ipynb +++ b/applications/telecom/resiliency_planning/resiliency_planning_AMD.ipynb @@ -771,9 +771,9 @@ " bind_dict = make_aer_bind_dict(qc_t, samples)\n", "\n", " job = sim.run(qc_t, shots=shots, memory=True, parameter_binds=[bind_dict])\n", - " res = job.result()\n", + " result = job.result()\n", "\n", - " samples = res.get_memory(0)\n", + " samples = result.get_memory(0)\n", "\n", " if flip_endian:\n", " samples = [s[::-1] for s in samples]\n", @@ -980,7 +980,7 @@ "samples = qaoa_samples(\n", " optimization_res.x.tolist(), shots=40000\n", ") # es.sample({\"params\": optimization_res.x.tolist()})\n", - "res = qiskit_to_classiq_samples([[int(c) for c in row] for row in samples])" + "result = qiskit_to_classiq_samples([[int(c) for c in row] for row in samples])" ] }, { @@ -1017,7 +1017,7 @@ } ], "source": [ - "sorted_counts = sorted(res.parsed_counts, key=lambda pc: pc.shots, reverse=True)\n", + "sorted_counts = sorted(result.parsed_counts, key=lambda pc: pc.shots, reverse=True)\n", "\n", "\n", "def print_res(sampled, idx):\n", diff --git a/community/Hackathons/QInnovision_2025/advection_equation/advection_equation_winning_submission.ipynb b/community/Hackathons/QInnovision_2025/advection_equation/advection_equation_winning_submission.ipynb index f0c7e9dc8..bd189a722 100644 --- a/community/Hackathons/QInnovision_2025/advection_equation/advection_equation_winning_submission.ipynb +++ b/community/Hackathons/QInnovision_2025/advection_equation/advection_equation_winning_submission.ipynb @@ -886,7 +886,7 @@ "metadata": {}, "outputs": [], "source": [ - "res_proposed = execute(qprog)" + "job_proposed = execute(qprog)" ] }, { @@ -919,8 +919,8 @@ ], "source": [ "# Collected job data by id\n", - "print(\"Job ID:\", res_proposed.id)\n", - "restored_job_proposed = ExecutionJob.from_id(res_proposed.id)\n", + "print(\"Job ID:\", job_proposed.id)\n", + "restored_job_proposed = ExecutionJob.from_id(job_proposed.id)\n", "print(restored_job_proposed.status)" ] }, @@ -939,7 +939,7 @@ "metadata": {}, "outputs": [], "source": [ - "result_proposed = restored_job_proposed.result()" + "result_proposed = restored_job_proposed.result_value()" ] }, { @@ -965,7 +965,7 @@ "amplitudes_proposed = np.zeros(num_states, dtype=complex)\n", "\n", "# Fill in the values from the dictionary\n", - "for bitstring, amplitude in result_proposed[0].value.state_vector.items():\n", + "for bitstring, amplitude in result_proposed.state_vector.items():\n", " index = int(bitstring, 2) # Convert binary string to decimal index\n", " amplitudes_proposed[index] = amplitude" ] @@ -1263,7 +1263,7 @@ "metadata": {}, "outputs": [], "source": [ - "res_trotter = execute(qprog)" + "job_trotter = execute(qprog)" ] }, { @@ -1296,8 +1296,8 @@ ], "source": [ "# Collected job data by id\n", - "print(\"Job ID:\", res_trotter.id)\n", - "restored_job_trotter = ExecutionJob.from_id(res_trotter.id)\n", + "print(\"Job ID:\", job_trotter.id)\n", + "restored_job_trotter = ExecutionJob.from_id(job_trotter.id)\n", "print(restored_job_trotter.status)" ] }, @@ -1316,7 +1316,7 @@ "metadata": {}, "outputs": [], "source": [ - "result_trotter = res_trotter.result()" + "result_trotter = job_trotter.result_value()" ] }, { @@ -1342,7 +1342,7 @@ "amplitudes_trotter = np.zeros(num_states, dtype=complex)\n", "\n", "# Fill in the values from the dictionary\n", - "for bitstring, amplitude in result_trotter[0].value.state_vector.items():\n", + "for bitstring, amplitude in result_trotter.state_vector.items():\n", " index = int(bitstring, 2) # Convert binary string to decimal index\n", " amplitudes_trotter[index] = amplitude" ] @@ -1690,7 +1690,7 @@ "metadata": {}, "outputs": [], "source": [ - "res_proposed_custom = execute(qprog)" + "job_proposed_custom = execute(qprog)" ] }, { @@ -1723,8 +1723,8 @@ ], "source": [ "# Collected job data by id\n", - "print(\"Job ID:\", res_proposed_custom.id)\n", - "restored_job_proposed_custom = ExecutionJob.from_id(res_proposed_custom.id)\n", + "print(\"Job ID:\", job_proposed_custom.id)\n", + "restored_job_proposed_custom = ExecutionJob.from_id(job_proposed_custom.id)\n", "print(restored_job_proposed_custom.status)" ] }, @@ -1743,7 +1743,7 @@ "metadata": {}, "outputs": [], "source": [ - "result_proposed_custom = res_proposed_custom.result()" + "result_proposed_custom = job_proposed_custom.result_value()" ] }, { @@ -1769,7 +1769,7 @@ "amplitudes_proposed_custom = np.zeros(num_states, dtype=complex)\n", "\n", "# Fill in the values from the dictionary\n", - "for bitstring, amplitude in result_proposed_custom[0].value.state_vector.items():\n", + "for bitstring, amplitude in result_proposed_custom.state_vector.items():\n", " index = int(bitstring, 2) # Convert binary string to decimal index\n", " amplitudes_proposed_custom[index] = amplitude" ] diff --git a/community/Hackathons/iQuHack_2025/Workshop/WS_iQuHack_2025_final.ipynb b/community/Hackathons/iQuHack_2025/Workshop/WS_iQuHack_2025_final.ipynb index 76130f30c..221ca9256 100644 --- a/community/Hackathons/iQuHack_2025/Workshop/WS_iQuHack_2025_final.ipynb +++ b/community/Hackathons/iQuHack_2025/Workshop/WS_iQuHack_2025_final.ipynb @@ -441,7 +441,7 @@ "metadata": {}, "outputs": [], "source": [ - "res = execute(qprog).get_sample_result()" + "result = execute(qprog).get_sample_result()" ] }, { @@ -513,7 +513,7 @@ } ], "source": [ - "res.parsed_counts" + "result.parsed_counts" ] }, { @@ -565,7 +565,7 @@ } ], "source": [ - "res.parsed_counts_of_outputs(\"x\") # Only \"correct\" results" + "result.parsed_counts_of_outputs(\"x\") # Only \"correct\" results" ] }, { diff --git a/community/basic_examples/logical_qubits/logical_qubits_by_alice_and_bob.ipynb b/community/basic_examples/logical_qubits/logical_qubits_by_alice_and_bob.ipynb index d84c95b8b..c6f32b59a 100644 --- a/community/basic_examples/logical_qubits/logical_qubits_by_alice_and_bob.ipynb +++ b/community/basic_examples/logical_qubits/logical_qubits_by_alice_and_bob.ipynb @@ -391,7 +391,7 @@ "outputs": [], "source": [ "# Execute quantum program\n", - "res = execute(qprog).result()" + "result = execute(qprog).result_value()" ] }, { @@ -410,7 +410,7 @@ ], "source": [ "# Read results\n", - "print(res[0].value.parsed_counts)" + "print(result.parsed_counts)" ] }, { @@ -448,8 +448,8 @@ "metadata": {}, "outputs": [], "source": [ - "def results_error_rate(res):\n", - " return 1 - res[0].value.counts[\"0\"] / sum(res[0].value.counts.values())" + "def results_error_rate(result):\n", + " return 1 - result.counts[\"0\"] / sum(result.counts.values())" ] }, { @@ -478,7 +478,7 @@ } ], "source": [ - "results_error_rate(res)" + "results_error_rate(result)" ] }, { @@ -587,8 +587,8 @@ "qprog = synthesize(model)\n", "\n", "# Execute Quantum Program and show results\n", - "res = execute(qprog).result()\n", - "print(res[0].value.parsed_counts)\n", + "result = execute(qprog).result_value()\n", + "print(result.parsed_counts)\n", "\n", "show(qprog)" ] @@ -652,13 +652,13 @@ " qprog = synthesize(model)\n", "\n", " # Execute Quantum Program\n", - " res = execute(qprog).result()\n", + " result = execute(qprog).result_value()\n", "\n", " end = time.time()\n", "\n", " # show(qprog)\n", "\n", - " error_rate = results_error_rate(res)\n", + " error_rate = results_error_rate(result)\n", "\n", " print(\"-------------------------------------\")\n", " print(\n", diff --git a/community/paper_implementation_project/block_encoding/select_structures_BE.ipynb b/community/paper_implementation_project/block_encoding/select_structures_BE.ipynb index f40891048..0dce089e1 100644 --- a/community/paper_implementation_project/block_encoding/select_structures_BE.ipynb +++ b/community/paper_implementation_project/block_encoding/select_structures_BE.ipynb @@ -218,7 +218,7 @@ " projections: dict,\n", ") -> np.ndarray:\n", " \"\"\"\n", - " This function returns a reduced statevector from execution results.\n", + " This function returns a reduced statevector from execution result.\n", " measured var: the name of the reduced variable\n", " projections: on which values of the other variables to project, e.g., {\"anc_M\": 1}\n", " \"\"\"\n", @@ -585,11 +585,10 @@ } ], "source": [ - "job = execute(qprog)\n", - "results = job.result_value()\n", + "result = execute(qprog).result_value()\n", "\n", "\n", - "reduced_state = get_projected_state_vector(results, \"j\", {\"s\": 0, \"data\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"j\", {\"s\": 0, \"data\": 0})\n", "reduced_state = reduced_state * N # rescale by subnormalization factor N\n", "print(\"The reduced state vector for j when s=0, data=0 is:\")\n", "print(reduced_state)\n", @@ -867,11 +866,10 @@ "print(\"The circuit depth is:\", circuit_depth)\n", "\n", "\n", - "job = execute(qprog)\n", - "results = job.result_value()\n", + "result = execute(qprog).result_value()\n", "\n", "\n", - "reduced_state = get_projected_state_vector(results, \"j\", {\"s\": 0, \"data\": 0, \"dlt\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"j\", {\"s\": 0, \"data\": 0, \"dlt\": 0})\n", "reduced_state = reduced_state * D # D is the subnormalization factor\n", "print(\"The reduced state vector for j when s=0, dlt=1 and data=0 is:\")\n", "print(reduced_state)\n", @@ -1113,10 +1111,9 @@ "print(\"The circuit width is:\", circuit_width)\n", "print(\"The circuit depth is:\", circuit_depth)\n", "\n", - "job = execute(qprog)\n", - "results = job.result_value()\n", + "result = execute(qprog).result_value()\n", "\n", - "reduced_state = get_projected_state_vector(results, \"j\", {\"s\": 0, \"data\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"j\", {\"s\": 0, \"data\": 0})\n", "print(\"The reduced state vector for j when s=0, data=0 is:\")\n", "print(reduced_state)\n", "\n", @@ -1417,11 +1414,10 @@ "print(\"The circuit width is:\", circuit_width)\n", "print(\"The circuit depth is:\", circuit_depth)\n", "\n", - "job = execute(qprog)\n", - "results = job.result_value()\n", + "result = execute(qprog).result_value()\n", "\n", "# Post processing\n", - "reduced_state = get_projected_state_vector(results, \"j\", {\"s\": 0, \"data\": 0, \"dlt\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"j\", {\"s\": 0, \"data\": 0, \"dlt\": 0})\n", "print(\"The reduced state vector for j when s=0, data=0 is:\")\n", "print(reduced_state)\n", "\n", diff --git a/community/paper_implementation_project/explicit_quantum_circuits_for_block_encoding/quantum_walks_via_efficient_blockencoding.ipynb b/community/paper_implementation_project/explicit_quantum_circuits_for_block_encoding/quantum_walks_via_efficient_blockencoding.ipynb index f63910fc1..670eeb816 100644 --- a/community/paper_implementation_project/explicit_quantum_circuits_for_block_encoding/quantum_walks_via_efficient_blockencoding.ipynb +++ b/community/paper_implementation_project/explicit_quantum_circuits_for_block_encoding/quantum_walks_via_efficient_blockencoding.ipynb @@ -436,7 +436,7 @@ " projections: dict,\n", ") -> np.ndarray:\n", " \"\"\"\n", - " This function returns a reduced statevector from execution results.\n", + " This function returns a reduced statevector from execution result.\n", " measured var: the name of the reduced variable\n", " projections: on which values of the other variables to project, e.g., {\"anc_M\": 1}\n", " Note: For this function to work properly all variables, except auxiliary qubits, must be declared as\n", @@ -507,13 +507,10 @@ "print(\"The circuit depth is:\", circuit_depth)\n", "show(qprog_ebt)\n", "\n", - "job = execute(qprog_ebt)\n", - "results = job.result_value()\n", + "result = execute(qprog_ebt).result_value()\n", "\n", "# Post-processing to get the reduced state vector of the register j when rest of the registers are in zero state\n", - "reduced_state = get_projected_state_vector(\n", - " results, \"j\", {\"l\": 0, \"data\": 0, \"anc_M\": 0}\n", - ")\n", + "reduced_state = get_projected_state_vector(result, \"j\", {\"l\": 0, \"data\": 0, \"anc_M\": 0})\n", "reduced_state = reduced_state\n", "print(\"The reduced state vector for j is:\")\n", "print(np.real(reduced_state))\n", @@ -1098,8 +1095,7 @@ "print(\"The circuit width is:\", circuit_width)\n", "print(\"The circuit depth is:\", circuit_depth)\n", "\n", - "job = execute(qprog_sbc)\n", - "results = job.result_value()" + "result = execute(qprog_sbc).result_value()" ] }, { @@ -1122,7 +1118,7 @@ } ], "source": [ - "reduced_state = get_projected_state_vector(results, \"state\", {\"block\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"state\", {\"block\": 0})\n", "\n", "print(\"The state vector is:\")\n", "print(reduced_state)\n", @@ -1253,8 +1249,7 @@ "print(\"The circuit width is:\", circuit_width)\n", "print(\"The circuit depth is:\", circuit_depth)\n", "\n", - "job = execute(qprog_sbc)\n", - "results = job.result_value()" + "result = execute(qprog_sbc).result_value()" ] }, { @@ -1275,7 +1270,7 @@ } ], "source": [ - "reduced_state = get_projected_state_vector(results, \"state\", {\"block\": 0, \"anc\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"state\", {\"block\": 0, \"anc\": 0})\n", "\n", "print(\"The state vector is:\")\n", "print(reduced_state)\n", @@ -1559,8 +1554,7 @@ "print(\"The circuit width is:\", circuit_width)\n", "print(\"The circuit depth is:\", circuit_depth)\n", "\n", - "job = execute(qprog_nmd)\n", - "results = job.result_value()" + "result = execute(qprog_nmd).result_value()" ] }, { @@ -1581,7 +1575,7 @@ } ], "source": [ - "reduced_state = get_projected_state_vector(results, \"state\", {\"block\": 0, \"anc\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"state\", {\"block\": 0, \"anc\": 0})\n", "\n", "print(\"The state vector is:\")\n", "print(reduced_state)\n", @@ -1671,8 +1665,7 @@ "print(\"The circuit width is:\", circuit_width)\n", "print(\"The circuit depth is:\", circuit_depth)\n", "\n", - "job = execute(qprog_md)\n", - "results = job.result_value()" + "result = execute(qprog_md).result_value()" ] }, { @@ -1693,7 +1686,7 @@ } ], "source": [ - "reduced_state = get_projected_state_vector(results, \"state\", {\"block\": 0, \"anc\": 0})\n", + "reduced_state = get_projected_state_vector(result, \"state\", {\"block\": 0, \"anc\": 0})\n", "\n", "print(\"The state vector is:\")\n", "print(reduced_state)\n", diff --git a/community/paper_implementation_project/quantum_algo_for_solving_linear_differential_equations/harmonic_oscillator.ipynb b/community/paper_implementation_project/quantum_algo_for_solving_linear_differential_equations/harmonic_oscillator.ipynb index 7d2235b20..0b0d798d2 100644 --- a/community/paper_implementation_project/quantum_algo_for_solving_linear_differential_equations/harmonic_oscillator.ipynb +++ b/community/paper_implementation_project/quantum_algo_for_solving_linear_differential_equations/harmonic_oscillator.ipynb @@ -664,9 +664,8 @@ " qmod = create_model(create_main_for_t(t))\n", " qmod = set_execution_preferences(qmod, execution_preferences)\n", " qprog = synthesize(qmod)\n", - " job = execute(qprog)\n", - " results = job.result_value()\n", - " for j in results.parsed_state_vector:\n", + " result = execute(qprog).result_value()\n", + " for j in result.parsed_state_vector:\n", " if int(j.bitstring[:-dim], 2) == 0:\n", " print(j.bitstring, \" : \", np.linalg.norm(j.amplitude) * (N * N))\n", " if int(j.bitstring, 2) == 0:\n", @@ -780,7 +779,7 @@ } ], "source": [ - "results = [\n", + "result = [\n", " [\n", " t / 10,\n", " kinetic_expected[t],\n", @@ -791,7 +790,7 @@ " for t in range(t_range + 1)\n", "]\n", "table = tabulate(\n", - " results,\n", + " result,\n", " headers=[\n", " \"t\",\n", " \"Kinetic expected\",\n", diff --git a/community/paper_implementation_project/quantum_compression_algorithm_for_symmetric_states/quantum_compression_algorithm_for_symmetric_states.ipynb b/community/paper_implementation_project/quantum_compression_algorithm_for_symmetric_states/quantum_compression_algorithm_for_symmetric_states.ipynb index 7660798c1..640184f23 100644 --- a/community/paper_implementation_project/quantum_compression_algorithm_for_symmetric_states/quantum_compression_algorithm_for_symmetric_states.ipynb +++ b/community/paper_implementation_project/quantum_compression_algorithm_for_symmetric_states/quantum_compression_algorithm_for_symmetric_states.ipynb @@ -468,10 +468,9 @@ "\n", "\n", "qprog_1 = synthesize(main)\n", - "job1 = execute(qprog_1)\n", - "results1 = job1.result_value().parsed_counts\n", + "result_1 = execute(qprog_1).result_value().parsed_counts\n", "show(qprog_1)\n", - "results1" + "result_1" ] }, { @@ -524,10 +523,9 @@ "\n", "model2 = create_model(main)\n", "qprog_2 = synthesize(model2)\n", - "job2 = execute(qprog_2)\n", - "results2 = job2.result_value().parsed_counts\n", + "result_2 = execute(qprog_2).result_value().parsed_counts\n", "show(qprog_2)\n", - "results2" + "result_2" ] }, { @@ -588,10 +586,9 @@ "\n", "model3 = create_model(main)\n", "qprog_3 = synthesize(model3)\n", - "job3 = execute(qprog_3)\n", - "results3 = job3.result_value().parsed_counts\n", + "result_3 = execute(qprog_3).result_value().parsed_counts\n", "show(qprog_3)\n", - "results3" + "result_3" ] }, { diff --git a/functions/qmod_library_reference/classiq_open_library/amplitude_amplification/exact_amplitude_amplification.ipynb b/functions/qmod_library_reference/classiq_open_library/amplitude_amplification/exact_amplitude_amplification.ipynb index ce83be9d6..56789707f 100644 --- a/functions/qmod_library_reference/classiq_open_library/amplitude_amplification/exact_amplitude_amplification.ipynb +++ b/functions/qmod_library_reference/classiq_open_library/amplitude_amplification/exact_amplitude_amplification.ipynb @@ -111,8 +111,8 @@ "qprog = synthesize(main)\n", "show(qprog)\n", "\n", - "res = execute(qprog).get_sample_result()\n", - "res.dataframe" + "result = execute(qprog).get_sample_result()\n", + "result.dataframe" ] }, { @@ -122,7 +122,7 @@ "metadata": {}, "outputs": [], "source": [ - "assert sum(res.dataframe[res.dataframe.x == 1][\"counts\"]) == res.num_shots" + "assert sum(result.dataframe[result.dataframe.x == 1][\"counts\"]) == result.num_shots" ] }, { diff --git a/tutorials/basic_tutorials/quantum_primitives/hadamard_test_tutorial/hadamard_test_tutorial.ipynb b/tutorials/basic_tutorials/quantum_primitives/hadamard_test_tutorial/hadamard_test_tutorial.ipynb index 6dcad0bed..21bf1b8bf 100644 --- a/tutorials/basic_tutorials/quantum_primitives/hadamard_test_tutorial/hadamard_test_tutorial.ipynb +++ b/tutorials/basic_tutorials/quantum_primitives/hadamard_test_tutorial/hadamard_test_tutorial.ipynb @@ -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))" ] diff --git a/tutorials/basic_tutorials/quantumwalk_complex_network/quantumwalk_complex_network.ipynb b/tutorials/basic_tutorials/quantumwalk_complex_network/quantumwalk_complex_network.ipynb index 50ae02770..3873c36ef 100644 --- a/tutorials/basic_tutorials/quantumwalk_complex_network/quantumwalk_complex_network.ipynb +++ b/tutorials/basic_tutorials/quantumwalk_complex_network/quantumwalk_complex_network.ipynb @@ -378,8 +378,7 @@ "metadata": {}, "outputs": [], "source": [ - "execution_job = execute(qprog)\n", - "result = execution_job.result_value()" + "result = execute(qprog).result_value()" ] }, { diff --git a/tutorials/basic_tutorials/the_classiq_tutorial/Qmod_tutorial_part1.ipynb b/tutorials/basic_tutorials/the_classiq_tutorial/Qmod_tutorial_part1.ipynb index d017abaa2..d7a08fb3f 100644 --- a/tutorials/basic_tutorials/the_classiq_tutorial/Qmod_tutorial_part1.ipynb +++ b/tutorials/basic_tutorials/the_classiq_tutorial/Qmod_tutorial_part1.ipynb @@ -78,7 +78,7 @@ } ], "source": [ - "res = sample(qprog)" + "df = sample(qprog)" ] }, { @@ -159,8 +159,8 @@ "\n", "# execute the model to see that we get similar results\n", "qprog = synthesize(main)\n", - "res = sample(qprog)\n", - "res" + "df = sample(qprog)\n", + "df" ] }, { @@ -219,8 +219,8 @@ "# execute and inspect the results\n", "\n", "qprog = synthesize(main)\n", - "res = sample(qprog)\n", - "res" + "df = sample(qprog)\n", + "df" ] }, { @@ -617,8 +617,7 @@ "# execute the model to see that we get similar results\n", "\n", "qprog = synthesize(main)\n", - "job = execute(qprog)\n", - "job.get_sample_result().parsed_counts" + "execute(qprog).get_sample_result().parsed_counts" ] }, { @@ -673,8 +672,7 @@ "# execute and inspect the results\n", "\n", "qprog = synthesize(main)\n", - "job = execute(qprog)\n", - "job.get_sample_result().parsed_counts" + "execute(qprog).get_sample_result().parsed_counts" ] }, { @@ -1060,8 +1058,8 @@ "\n", "\n", "qprog = synthesize(main)\n", - "res = sample(qprog)\n", - "res" + "df = sample(qprog)\n", + "df" ] }, { @@ -1278,8 +1276,8 @@ "\n", "\n", "qprog = synthesize(main)\n", - "res = sample(qprog)\n", - "res" + "df = sample(qprog)\n", + "df" ] }, { diff --git a/tutorials/basic_tutorials/the_classiq_tutorial/classiq_overview_tutorial.ipynb b/tutorials/basic_tutorials/the_classiq_tutorial/classiq_overview_tutorial.ipynb index 8d09112c7..7e45a20af 100644 --- a/tutorials/basic_tutorials/the_classiq_tutorial/classiq_overview_tutorial.ipynb +++ b/tutorials/basic_tutorials/the_classiq_tutorial/classiq_overview_tutorial.ipynb @@ -193,7 +193,7 @@ } ], "source": [ - "res = sample(qprog)" + "df = sample(qprog)" ] }, { @@ -342,7 +342,7 @@ } ], "source": [ - "res" + "df" ] }, { diff --git a/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial.ipynb b/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial.ipynb index 1f7bb6aa5..95a718ed0 100644 --- a/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial.ipynb +++ b/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial.ipynb @@ -73,7 +73,7 @@ } ], "source": [ - "results = sample(qprog)" + "df = sample(qprog)" ] }, { @@ -205,7 +205,7 @@ } ], "source": [ - "results" + "df" ] }, { @@ -245,7 +245,7 @@ } ], "source": [ - "results_more_shots = sample(qprog, num_shots=10000)" + "df_more_shots = sample(qprog, num_shots=10000)" ] }, { @@ -377,7 +377,7 @@ } ], "source": [ - "results_more_shots" + "df_more_shots" ] }, { @@ -542,8 +542,8 @@ ], "source": [ "cfg = {\"noise_model\": \"ibm_pittsburgh\"}\n", - "res = sample(qprog, backend=\"simulator\", config=cfg)\n", - "res" + "df_noisy = sample(qprog, backend=\"simulator\", config=cfg)\n", + "df_noisy" ] }, { @@ -825,8 +825,8 @@ "default_backend = \"classiq/simulator\"\n", "MPS_backend = \"classiq/simulator_matrix_product_state\"\n", "\n", - "res_default = calculate_state_vector(qprog, backend=default_backend)\n", - "res_MPS = sample(qprog, MPS_backend)" + "result_default = calculate_state_vector(qprog, backend=default_backend)\n", + "df_MPS = sample(qprog, MPS_backend)" ] }, { @@ -899,7 +899,7 @@ } ], "source": [ - "res_default" + "result_default" ] }, { @@ -966,7 +966,7 @@ } ], "source": [ - "res_MPS" + "df_MPS" ] } ], diff --git a/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial_part2.ipynb b/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial_part2.ipynb index f0a105560..e735cff05 100644 --- a/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial_part2.ipynb +++ b/tutorials/basic_tutorials/the_classiq_tutorial/execution_tutorial_part2.ipynb @@ -166,10 +166,10 @@ } ], "source": [ - "first_sample = sample(qprog, parameters=parameter)\n", + "df = sample(qprog, parameters=parameter)\n", "\n", "print(\"Counts for angle = pi/2: \")\n", - "first_sample" + "df" ] }, { @@ -201,7 +201,7 @@ "parameters_list = [{\"angle\": angles} for angles in angles_list]\n", "\n", "# Execute batch sampling over all angles\n", - "second_sample = sample(qprog, parameters=parameters_list)" + "dfs = sample(qprog, parameters=parameters_list)" ] }, { @@ -239,8 +239,8 @@ " return pops\n", "\n", "\n", - "pops_00 = get_counts(second_sample, \"00\")\n", - "pops_11 = get_counts(second_sample, \"11\")" + "pops_00 = get_counts(dfs, \"00\")\n", + "pops_11 = get_counts(dfs, \"11\")" ] }, { @@ -469,7 +469,7 @@ "# Retrieving the job from its ID\n", "retrieved_estimate = ExecutionJob.from_id(estimate_job_ID)\n", "\n", - "print(\"Retrieved job result:\", retrieved_estimate.result_value().value)" + "print(\"Retrieved job df:\", retrieved_estimate.result_value().value)" ] }, { diff --git a/tutorials/technology_demonstrations/qaoa/qaoa_demonstration.ipynb b/tutorials/technology_demonstrations/qaoa/qaoa_demonstration.ipynb index 232076385..92575beb2 100644 --- a/tutorials/technology_demonstrations/qaoa/qaoa_demonstration.ipynb +++ b/tutorials/technology_demonstrations/qaoa/qaoa_demonstration.ipynb @@ -164,18 +164,18 @@ "qmod = set_preferences(qmod, preferences=preferences)\n", "\n", "qprog = synthesize(qmod)\n", - "res = execute(qprog).result()\n", + "result = execute(qprog).result_value()\n", "depth_classiq = qprog.transpiled_circuit.depth\n", "cx_counts_classiq = qprog.transpiled_circuit.count_ops[\"cx\"]\n", - "classiq_solving_time = res[0].value.time\n", + "classiq_solving_time = result.time\n", "\n", "interations_classiq = [\n", " intermediate_result.iteration_number\n", - " for intermediate_result in res[0].value.intermediate_results\n", + " for intermediate_result in result.intermediate_results\n", "]\n", "results_classiq = [\n", " -intermediate_result.mean_all_solutions\n", - " for intermediate_result in res[0].value.intermediate_results\n", + " for intermediate_result in result.intermediate_results\n", "]" ] }, @@ -386,7 +386,7 @@ "metadata": {}, "outputs": [], "source": [ - "# pauli_list = get_classiq_hamiltonian(res)\n", + "# pauli_list = get_classiq_hamiltonian(result)\n", "# hamiltonian = SparsePauliOp.from_list(pauli_list)\n", "\n", "# (\n", diff --git a/tutorials/workshops/oracle_workshop/oracles_workshop.ipynb b/tutorials/workshops/oracle_workshop/oracles_workshop.ipynb index 00876fe3e..425e99921 100644 --- a/tutorials/workshops/oracle_workshop/oracles_workshop.ipynb +++ b/tutorials/workshops/oracle_workshop/oracles_workshop.ipynb @@ -302,13 +302,13 @@ "exec_prefs = ExecutionPreferences(num_shots=1, backend_preferences=backend_prefs)\n", "\n", "with ExecutionSession(qprog_phase_kickback, execution_preferences=exec_prefs) as es:\n", - " res = es.sample()\n", + " result_kickback = es.sample()\n", "\n", "# ---- Cleaning up results: keeping only (x,y), dropping ancillas ----\n", "DATA_BITS = 3 # y (2 qubits) + x (1 qubit)\n", "\n", "rows = []\n", - "for st in res.parsed_state_vector:\n", + "for st in result_kickback.parsed_state_vector:\n", " bstr = st.bitstring\n", " if set(bstr[:-DATA_BITS]) == {\"0\"}: # ancilla must be |0⟩\n", " y = int(bstr[-3:-1], 2)\n", @@ -597,8 +597,8 @@ "# Printing the results to check that the algorithm\n", "qprog_grover = synthesize(main)\n", "show(qprog_grover)\n", - "res = execute(qprog_grover).result()\n", - "counts = res[0].value.parsed_counts\n", + "result_grover = execute(qprog_grover).result_value()\n", + "counts = result_grover.parsed_counts\n", "counts" ] }, @@ -712,13 +712,13 @@ "exec_prefs = ExecutionPreferences(num_shots=1, backend_preferences=backend_prefs)\n", "\n", "with ExecutionSession(qprog_phase_kickback, execution_preferences=exec_prefs) as es:\n", - " res = es.sample()\n", + " result_kickback = es.sample()\n", "\n", "# ---- Cleaning up results: keeping only (x,y), dropping ancillas ----\n", "DATA_BITS = 3 # y (2 qubits) + x (1 qubit)\n", "\n", "rows = []\n", - "for st in res.parsed_state_vector:\n", + "for st in result_kickback.parsed_state_vector:\n", " bstr = st.bitstring\n", " if set(bstr[:-DATA_BITS]) == {\"0\"}: # ancilla must be |0⟩\n", " y = int(bstr[-3:-1], 2)\n", @@ -929,8 +929,8 @@ "source": [ "qprog_grover = synthesize(main)\n", "show(qprog_grover)\n", - "res = execute(qprog_grover).result()\n", - "counts = res[0].value.parsed_counts\n", + "result_grover = execute(qprog_grover).result_value()\n", + "counts = result_grover.parsed_counts\n", "counts" ] }