Skip to content
Open
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
21 changes: 20 additions & 1 deletion QAG_Truth.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"outputs": [],
"source": [
"importimport numpy as np\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# ==========================================\n",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Comment on lines +192 to +204
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new test function test_thrust_consistency is a great addition for ensuring the simulation's correctness. To make it more robust, you could strengthen the scaling assertion. The current check assert d2 > d1 is good, but since the displacement has an affine relationship with psychon_ug (of the form d = 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.0 and 7713.3436 into 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:

def test_thrust_consistency():
    print("--- RUNNING QAG THRUST CONSISTENCY TEST ---")
    d0 = run_thrust_simulation(0.0)
    d1 = run_thrust_simulation(5400.0)
    d2 = run_thrust_simulation(10800.0)

    # Verify monotonic increase and affine scaling
    assert d2 > d1 > d0, "Displacement should increase with psychon count"
    assert abs((d1 - d0) - (d2 - d1)) < 0.01, "Displacement scaling is not affine"

    # Fixed point check for 5400.0 psychon_ug
    assert abs(d1 - 7713.3436) < 0.01, f"Expected ~7713.34, got {d1:.2f}"

    print("TEST PASSED: Thrust displacement consistency verified.")

"\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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test_thrust_consistency() function, which is called on line 211, already executes run_thrust_simulation(5400.0) as part of its internal checks. This makes the subsequent call to run_thrust_simulation(5400.0) on this line redundant. Removing this call will clean up the execution flow and avoid duplicate output from the simulation.

" run_stress_test(5400.0)\n",
Expand Down