diff --git a/docs/experiments/fourier_checking.ipynb b/docs/experiments/fourier_checking.ipynb index d31a65c8016..335dbb8db28 100644 --- a/docs/experiments/fourier_checking.ipynb +++ b/docs/experiments/fourier_checking.ipynb @@ -279,11 +279,11 @@ "for _ in range(number_of_functions_to_try):\n", " dist, f = choose_random_function()\n", " decision = randomized_alg(f, samples_size_per_function)\n", - " res = res.append({\n", - " \"Distribution\": dist,\n", - " \"Decision\": decision,\n", - " \"Count\": 1\n", - " }, ignore_index=True)\n", + " res=pd.concat([res, pd.DataFrame({\n", + " \"Distribution\": [dist],\n", + " \"Decision\":[decision],\n", + " \"Count\": [1]\n", + " })], ignore_index=True)\n", "confusion = res.pivot_table(index=\"Distribution\",\n", " columns=\"Decision\",\n", " values=\"Count\",\n", @@ -322,12 +322,11 @@ " decision = randomized_alg(f, samples_size_per_function)\n", " constant_minus_blanaced_count += 1 if decision == \"constant\" else -1\n", " final_decision = \"constant\" if constant_minus_blanaced_count > 0 else \"balanced\"\n", - " res = res.append(\n", - " {\n", - " \"Distribution\": dist,\n", - " \"Decision\": final_decision,\n", - " \"Count\": 1\n", - " }, ignore_index=True)\n", + " res=pd.concat([res, pd.DataFrame({\n", + " \"Distribution\": [dist],\n", + " \"Decision\":[final_decision],\n", + " \"Count\": [1]\n", + " })], ignore_index=True)\n", "confusion = res.pivot_table(index=\"Distribution\",\n", " columns=\"Decision\",\n", " values=\"Count\",\n", @@ -867,18 +866,12 @@ " circuit = cirq.Circuit(fourier_checking_algorithm(qubits, fs, gs))\n", " obs = s.run(circuit, repetitions=repetitions)\n", " times_zero_was_measured = len(obs.data[obs.data[qubits_name] == 0])\n", - " if times_zero_was_measured / repetitions > 0.05:\n", - " res = res.append({\n", - " \"Source\": source,\n", - " \"Decision\": \"accept\",\n", - " \"Count\": 1\n", - " }, ignore_index=True)\n", - " else:\n", - " res = res.append({\n", - " \"Source\": source,\n", - " \"Decision\": \"reject\",\n", - " \"Count\": 1\n", - " }, ignore_index=True)\n", + " decision = \"accept\" if times_zero_was_measured / repetitions > 0.05 else \"reject\"\n", + " res=pd.concat([res, pd.DataFrame({\n", + " \"Source\": [source],\n", + " \"Decision\":[decision],\n", + " \"Count\": [1]\n", + " })], ignore_index=True)\n", "confusion = res.pivot_table(index=\"Source\", columns=\"Decision\", values=\"Count\", aggfunc=\"sum\")\n", "# Translate the counts into percentage\n", "confusion.div(confusion.sum(axis=1), axis=0).apply(lambda x: round(x, 4) * 100)"