-
Notifications
You must be signed in to change notification settings - Fork 0
🧪 Add test for run_thrust_simulation in QAG_Truth.ipynb #7
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "importimport numpy as np\n", | ||
| "import numpy as np\n", | ||
| "import matplotlib.pyplot as plt\n", | ||
| "\n", | ||
| "# ==========================================\n", | ||
|
|
@@ -92,6 +92,7 @@ | |
| "\n", | ||
| " print(f\"--- QAG PROPULSION ({psychon_ug}µg Psychon) ---\")\n", | ||
| " print(f\"Retrocausal Displacement: {d_retrocausal[-1]:.4f} units\")\n", | ||
| " return d_retrocausal[-1]\n", | ||
| "\n", | ||
| "def run_stress_test(psychon_ug=5400.0):\n", | ||
| " steps = 500\n", | ||
|
|
@@ -186,10 +187,28 @@ | |
| " print(f\"Recycling (R_qag): {r_qag*100:.2f}%\")\n", | ||
| "\n", | ||
| "# ==========================================\n", | ||
| "# 7. UNIT TESTS\n", | ||
| "# ==========================================\n", | ||
| "def test_thrust_consistency():\n", | ||
| " print(\"--- RUNNING QAG THRUST CONSISTENCY TEST ---\")\n", | ||
| " d1 = run_thrust_simulation(5400.0)\n", | ||
| " d2 = run_thrust_simulation(10800.0)\n", | ||
| " \n", | ||
| " # Verify that doubling psychon increases displacement (it scales linearly with qid_scale)\n", | ||
| " assert d2 > d1, \"Displacement should increase with psychon count\"\n", | ||
| " \n", | ||
| " # Fixed point check for 5400.0 psychon_ug\n", | ||
| " # Formula derived expected value: ~7713.34\n", | ||
| " assert abs(d1 - 7713.3436) < 0.01, f\"Expected ~7713.34, got {d1:.2f}\"\n", | ||
| " \n", | ||
| " print(\"TEST PASSED: Thrust displacement consistency verified.\")\n", | ||
| "\n", | ||
| "# ==========================================\n", | ||
| "# EXECUTION BLOCK (Run them all!)\n", | ||
| "# ==========================================\n", | ||
| "if __name__ == \"__main__\":\n", | ||
| " print(\"\\n--- INITIALIZING QAG MASTER SIMULCAST ---\\n\")\n", | ||
| " test_thrust_consistency()\n", | ||
| " run_galactic_theater(1.0)\n", | ||
| " run_thrust_simulation(5400.0)\n", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| " run_stress_test(5400.0)\n", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test function
test_thrust_consistencyis a great addition for ensuring the simulation's correctness. To make it more robust, you could strengthen the scaling assertion. The current checkassert d2 > d1is good, but since the displacement has an affine relationship withpsychon_ug(of the formd = k * psychon_ug + c), you can verify this more strictly by checking if the displacement increase is constant for a constant increase in input.Also, consider extracting magic numbers like
5400.0and7713.3436into named constants to improve readability. I've omitted that from the code suggestion below to keep the line count consistent with the original code block.Here's a suggested implementation that strengthens the test logic: