From af6d33aec48dcf7e8c774132e58660c9a15ab6ef Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 14 Mar 2026 16:17:46 +0000 Subject: [PATCH] test: add unit test for simulate_cellular_relaxation - Refactored `simulate_cellular_relaxation` to return `t` and `final_path` arrays. - Added a `plot=True` argument to allow disabling plots during testing. - Fixed a typo where `import numpy as np` was written as `importimport numpy as np`. - Created a `test_simulate_cellular_relaxation` function to verify the shape, initial values, and bounds of the generated data. - Added a `UNIT TESTS` section to the notebook and updated the execution block to run the test automatically. Co-authored-by: Sir-Ripley <31619989+Sir-Ripley@users.noreply.github.com> --- QAG_Truth.ipynb | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/QAG_Truth.ipynb b/QAG_Truth.ipynb index b1286ba..8d65a34 100644 --- a/QAG_Truth.ipynb +++ b/QAG_Truth.ipynb @@ -35,7 +35,7 @@ }, "outputs": [], "source": [ - "importimport numpy as np\n", + "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# ==========================================\n", @@ -52,7 +52,7 @@ "# ==========================================\n", "# 1. BIOLOGICAL HEALING & CELLULAR RELAXATION\n", "# ==========================================\n", - "def simulate_cellular_relaxation():\n", + "def simulate_cellular_relaxation(plot=True):\n", " t = np.linspace(0, 100, 1000)\n", " initial_zeta = -15.0\n", " zeta_target = -55.0\n", @@ -61,13 +61,16 @@ " vortex_hum = 2.0 * np.sin(t * 0.5)\n", " final_path = zeta_curve + vortex_hum\n", "\n", - " plt.figure(figsize=(8, 4))\n", - " plt.plot(t, final_path, color='#00ffcc', label='Cellular Zeta Potential (mV)')\n", - " plt.axhline(y=zeta_target, color='r', linestyle='--', label='Target Coherence')\n", - " plt.title(\"QAG Healing: Magnetic Relaxation\")\n", - " plt.ylabel(\"Stability (mV)\")\n", - " plt.legend()\n", - " plt.show()\n", + " if plot:\n", + " plt.figure(figsize=(8, 4))\n", + " plt.plot(t, final_path, color='#00ffcc', label='Cellular Zeta Potential (mV)')\n", + " plt.axhline(y=zeta_target, color='r', linestyle='--', label='Target Coherence')\n", + " plt.title(\"QAG Healing: Magnetic Relaxation\")\n", + " plt.ylabel(\"Stability (mV)\")\n", + " plt.legend()\n", + " plt.show()\n", + "\n", + " return t, final_path\n", "\n", "# ==========================================\n", "# 2. PROPULSION & SPACE-TIME STORM\n", @@ -90,7 +93,7 @@ " d_initial = np.cumsum(np.cumsum(np.full(steps, effective_accel)))\n", " d_retrocausal = np.cumsum(np.cumsum(np.full(steps, handshake_accel)))\n", "\n", - " print(f\"--- QAG PROPULSION ({psychon_ug}µg Psychon) ---\")\n", + " print(f\"--- QAG PROPULSION ({psychon_ug}\u00b5g Psychon) ---\")\n", " print(f\"Retrocausal Displacement: {d_retrocausal[-1]:.4f} units\")\n", "\n", "def run_stress_test(psychon_ug=5400.0):\n", @@ -185,11 +188,36 @@ " print(f\"Vacuum Tension: {tension:.4e} units\")\n", " print(f\"Recycling (R_qag): {r_qag*100:.2f}%\")\n", "\n", + "\n", + "# ==========================================\n", + "# UNIT TESTS\n", + "# ==========================================\n", + "def test_simulate_cellular_relaxation():\n", + " t, final_path = simulate_cellular_relaxation(plot=False)\n", + " \n", + " assert len(t) == 1000, \"Time array should have 1000 elements\"\n", + " assert len(final_path) == 1000, \"Path array should have 1000 elements\"\n", + " \n", + " # Check initial conditions (t=0)\n", + " assert np.isclose(final_path[0], -15.0), f\"Initial zeta expected -15.0, got {final_path[0]}\"\n", + " \n", + " # Check bounds/properties\n", + " assert np.max(final_path) <= -13.0, \"Path should not exceed bounds significantly above initial\"\n", + " assert np.min(final_path) >= -57.0, \"Path should not fall significantly below target\"\n", + " \n", + " print(\"\u2713 test_simulate_cellular_relaxation passed\")\n", + "\n", "# ==========================================\n", "# EXECUTION BLOCK (Run them all!)\n", "# ==========================================\n", "if __name__ == \"__main__\":\n", " print(\"\\n--- INITIALIZING QAG MASTER SIMULCAST ---\\n\")\n", + " \n", + " print(\"--- RUNNING UNIT TESTS ---\")\n", + " test_simulate_cellular_relaxation()\n", + " print(\"--- TESTS PASSED ---\\n\")\n", + "\n", + " simulate_cellular_relaxation()\n", " run_galactic_theater(1.0)\n", " run_thrust_simulation(5400.0)\n", " run_stress_test(5400.0)\n",