Skip to content

🧪 Add test for run_thrust_simulation in QAG_Truth.ipynb#7

Open
Sir-Ripley wants to merge 1 commit intomainfrom
add-thrust-simulation-test-15320882876725388340
Open

🧪 Add test for run_thrust_simulation in QAG_Truth.ipynb#7
Sir-Ripley wants to merge 1 commit intomainfrom
add-thrust-simulation-test-15320882876725388340

Conversation

@Sir-Ripley
Copy link
Owner

@Sir-Ripley Sir-Ripley commented Mar 14, 2026

I have implemented a unit test for the run_thrust_simulation function in QAG_Truth.ipynb.

🎯 What: The testing gap for the propulsion simulation was addressed by refactoring the simulation function and adding automated consistency checks.
📊 Coverage:

  • Verified that run_thrust_simulation produces the expected displacement (~7713.34) for default parameters.
  • Verified that the simulation correctly scales displacement when input is increased.
  • Fixed a pre-existing syntax error (importimport).
    Result: Improved reliability and automated verification of the QAG propulsion logic within the notebook.

PR created automatically by Jules for task 15320882876725388340 started by @Sir-Ripley

Summary by Sourcery

Add an automated consistency check for the QAG propulsion thrust simulation and integrate it into the notebook’s main execution flow.

Bug Fixes:

  • Fix a syntax error in the NumPy import statement in the QAG_Truth notebook.

Enhancements:

  • Make run_thrust_simulation return the final retrocausal displacement value for programmatic use.

Tests:

  • Add a unit-style test that validates thrust displacement scaling with psychon input and checks the expected displacement for the default configuration, and invoke it from the main execution block.

This commit introduces a unit test for the `run_thrust_simulation` function in `QAG_Truth.ipynb` to ensure reliability and output consistency.

Key changes:
- Corrected `importimport` typo in the notebook's first code cell.
- Updated `run_thrust_simulation` to return the calculated `d_retrocausal[-1]` value for programmatic testing.
- Added `test_thrust_consistency()` which verifies numerical accuracy (~7713.34) and positive scaling of displacement with psychon input.
- Integrated the test into the notebook's main execution block.

These changes improve the testability of the QAG propulsion model and provide a regression baseline for future modifications.

Co-authored-by: Sir-Ripley <31619989+Sir-Ripley@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 14, 2026

Reviewer's Guide

Adds a small testing harness around the QAG propulsion thrust simulation by fixing a syntax error, making run_thrust_simulation return its final displacement, and introducing a notebook-local unit test that validates both scaling behavior and a fixed expected value, which is invoked from the main execution block.

Sequence diagram for QAG main execution and thrust test invocation

sequenceDiagram
    participant Main as main_block
    participant Test as test_thrust_consistency
    participant Sim as run_thrust_simulation

    Main->>Test: call test_thrust_consistency
    Test->>Sim: run_thrust_simulation(5400.0)
    Sim-->>Test: d1 (final_displacement)
    Test->>Sim: run_thrust_simulation(10800.0)
    Sim-->>Test: d2 (final_displacement)
    Test->>Test: assert d2 > d1
    Test->>Test: assert abs(d1 - 7713.3436) < 0.01
    Test-->>Main: test completed

    Main->>Sim: run_thrust_simulation(5400.0)
    Sim-->>Main: displacement
    Main->>Main: run_galactic_theater(1.0)
    Main->>Main: run_stress_test(5400.0)
Loading

File-Level Changes

Change Details Files
Make the thrust simulation return its final displacement value so it can be asserted in tests.
  • Append a return of the final retrocausal displacement from run_thrust_simulation.
  • Preserve existing printed diagnostics while making the function pure enough for programmatic verification.
QAG_Truth.ipynb
Introduce a basic unit-style test function for the thrust simulation and wire it into the notebook's main execution path.
  • Add test_thrust_consistency that calls run_thrust_simulation with two psychon loads and asserts monotonic scaling.
  • Add a fixed-point assertion that the default 5400 µg case yields ~7713.3436 displacement within a tight tolerance.
  • Invoke the new test_thrust_consistency function at the start of the main execution block so the test runs automatically when the notebook is executed as a script.
QAG_Truth.ipynb
Fix a pre-existing import syntax error in the notebook setup.
  • Correct a malformed numpy import statement so the notebook imports numpy correctly alongside matplotlib.
QAG_Truth.ipynb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces automated testing for the QAG propulsion simulation logic within the QAG_Truth.ipynb notebook. By adding a dedicated unit test, it enhances the reliability and verifiability of the simulation's displacement calculations, ensuring consistent and predictable behavior.

Highlights

  • Unit Testing: Implemented test_thrust_consistency to verify the run_thrust_simulation function, ensuring expected displacement values and correct scaling.
  • Code Refinement: Modified run_thrust_simulation to return the final retrocausal displacement, enabling easier testing.
  • Bug Fix: Corrected a importimport syntax error in QAG_Truth.ipynb.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • QAG_Truth.ipynb
    • Fixed a duplicate import statement (importimport numpy to import numpy).
    • Modified the run_thrust_simulation function to return the calculated retrocausal displacement.
    • Added a new function test_thrust_consistency to perform unit tests on run_thrust_simulation, checking for expected displacement and scaling.
    • Integrated the test_thrust_consistency function into the main execution block (if __name__ == "__main__":).
Activity
  • PR created automatically by Jules for task 15320882876725388340, started by @Sir-Ripley.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Hard-coding the expected displacement 7713.3436 inside test_thrust_consistency makes the test brittle; consider deriving this from the same constants/parameters used in the simulation or at least grouping such reference values in a single place so they’re easier to update if the model changes.
  • Automatically running test_thrust_consistency() in the __main__ execution block may not always be desirable for interactive or exploratory notebook runs; consider gating it behind a flag or separate entry point so the simulation can be run without tests when needed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Hard-coding the expected displacement `7713.3436` inside `test_thrust_consistency` makes the test brittle; consider deriving this from the same constants/parameters used in the simulation or at least grouping such reference values in a single place so they’re easier to update if the model changes.
- Automatically running `test_thrust_consistency()` in the `__main__` execution block may not always be desirable for interactive or exploratory notebook runs; consider gating it behind a flag or separate entry point so the simulation can be run without tests when needed.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a unit test for the run_thrust_simulation function, which is a valuable addition for ensuring the simulation's reliability. The changes include fixing a minor syntax error, refactoring the function to return its result, and adding the test case itself. My review includes suggestions to make the new test more robust by verifying the scaling behavior more strictly, and to remove a redundant function call from the main execution block to improve clarity.

Comment on lines +192 to +204
"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",
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.")

" 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant