Skip to content

🧹 Consolidate duplicate neo_verification definitions in notebook#8

Merged
Sir-Ripley merged 1 commit intogaq2from
fix-consolidate-neo-verification-1001432498825415985
Mar 17, 2026
Merged

🧹 Consolidate duplicate neo_verification definitions in notebook#8
Sir-Ripley merged 1 commit intogaq2from
fix-consolidate-neo-verification-1001432498825415985

Conversation

@Sir-Ripley
Copy link
Owner

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

This change addresses a code health issue in the QAG_VerifiedNexus.ipynb notebook where the neo_verification function (and several others) were redefined multiple times.

Key improvements:

  • De-duplication: Removed redundant definitions of neo_verification, cehtr_resolver, and aa_resolver from multiple cells.
  • Consolidation: Moved these functions to an early setup cell (cell 13) along with their required imports.
  • Functional Enhancement: The consolidated functions now support both direct printing and returning a string, allowing them to work correctly both in interactive mode and as part of the automated report generation engine (VRE).
  • Interactive State Management: Consolidated the definition of output_portal (ipywidgets Output) to ensure it is shared consistently across all visualizations.
  • Code Health: Improved the overall readability and maintainability of the notebook by following a "single source of truth" pattern for core ODICE module functions.

Verification:

  • Confirmed the notebook remains a valid JSON file.
  • Verified that only one definition of each consolidated function exists.
  • Ensured all call sites (standalone and in VRE) are preserved and functional.
  • Preserved complex Unicode and ASCII art documentation during the JSON transformation.

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

Summary by Sourcery

Consolidate ODICE module functions into a single shared definition in the QAG_VerifiedNexus notebook to eliminate duplication and improve interactive behavior.

Enhancements:

  • Unify definitions of neo_verification, cehtr_resolver, and aa_resolver into an early setup cell with their imports to serve as a single source of truth for the notebook and VRE usage.
  • Introduce a shared ipywidgets-based output_portal that is created once and reused across visual modules for consistent interactive visualization handling.
  • Adjust ODICE functions to both print and return human-readable report strings so they work in interactive runs as well as automated report generation flows.

Chores:

  • Remove redundant redefinitions of ODICE module functions and local output_portal instances from later cells to simplify and declutter the notebook.

…s.ipynb

Consolidated 'neo_verification', 'cehtr_resolver', and 'aa_resolver' functions into a single cell (cell 13) to improve maintainability and resolve code health issues. The new definitions support both direct printing for standalone execution and returning report strings for the Visualization & Reporting Engine (VRE). Redundant definitions and imports have been removed from later cells, and shared resources like 'output_portal' are now handled consistently.
@google-labs-jules
Copy link

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

@netlify
Copy link

netlify bot commented Mar 14, 2026

Deploy Preview for gaqv3 ready!

Name Link
🔨 Latest commit b8eb41e
🔍 Latest deploy log https://app.netlify.com/projects/gaqv3/deploys/69b5a0cd2dcef4000869be7f
😎 Deploy Preview https://deploy-preview-8--gaqv3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Consolidates the ODICE ODICE module helper functions and visualization output handling in QAG_VerifiedNexus.ipynb into a single shared definition cell, and wires them to support both interactive printing and string-returning behavior while removing now-redundant duplicate definitions later in the notebook.

Sequence diagram for consolidated neo_verification flow

sequenceDiagram
    actor User
    participant NotebookKernel
    participant ODICEModule
    participant NASA_API

    User->>NotebookKernel: run neo_verification()
    NotebookKernel->>ODICEModule: neo_verification()

    ODICEModule->>ODICEModule: build today_date
    ODICEModule->>NASA_API: GET /neo/rest/v1/feed?start_date=today&end_date=today&api_key=DEMO_KEY
    NASA_API-->>ODICEModule: JSON near_earth_objects

    ODICEModule->>ODICEModule: compute shielding and qag_speed for first 3 asteroids
    ODICEModule->>ODICEModule: append lines to report_lines

    ODICEModule->>ODICEModule: join report_lines into report_str
    ODICEModule->>NotebookKernel: print(report_str)
    ODICEModule-->>NotebookKernel: return report_str

    NotebookKernel-->>User: display printed report_str
Loading

Sequence diagram for consolidated cehtr_resolver visualization and reporting

sequenceDiagram
    actor User
    participant NotebookKernel
    participant ODICEModule
    participant Matplotlib
    participant OutputPortalWidget as output_portal

    User->>NotebookKernel: run cehtr_resolver(plot_results, save_only)
    NotebookKernel->>ODICEModule: cehtr_resolver(plot_results, save_only)

    ODICEModule->>ODICEModule: init report_lines
    alt save_only is false
        ODICEModule->>NotebookKernel: print header line
    end

    ODICEModule->>ODICEModule: define standard_friedmann, qag_friedmann
    ODICEModule->>ODICEModule: solve_ivp for sol_std, sol_qag

    alt plot_results or save_only
        ODICEModule->>Matplotlib: create figure and axes
        ODICEModule->>Matplotlib: plot sol_std and sol_qag
        alt save_only is true
            Matplotlib->>ODICEModule: fig
            ODICEModule->>Matplotlib: fig.savefig('QAG_CEHTR_Expansion.png')
            ODICEModule->>NotebookKernel: print save confirmation
        else save_only is false
            alt output_portal exists
                ODICEModule->>OutputPortalWidget: with output_portal
                OutputPortalWidget->>Matplotlib: plt.show()
            else output_portal missing
                ODICEModule->>Matplotlib: plt.show()
            end
        end
    end

    ODICEModule->>ODICEModule: append resolution message to report_lines
    alt save_only is false
        ODICEModule->>NotebookKernel: print resolution message
    end
    ODICEModule-->>NotebookKernel: return joined report_lines

    NotebookKernel-->>User: show prints and/or saved file
Loading

Sequence diagram for consolidated aa_resolver visualization with shared output_portal

sequenceDiagram
    actor User
    participant NotebookKernel
    participant ODICEModule
    participant Matplotlib
    participant OutputPortalWidget as output_portal

    User->>NotebookKernel: run aa_resolver(plot_results)
    NotebookKernel->>ODICEModule: aa_resolver(plot_results)

    ODICEModule->>NotebookKernel: print header line
    ODICEModule->>ODICEModule: init report_lines
    ODICEModule->>ODICEModule: create meshgrid X, Y
    ODICEModule->>ODICEModule: define qag_lens
    ODICEModule->>ODICEModule: compute gas and qag_affinity_peaks

    alt plot_results is true
        ODICEModule->>Matplotlib: create figure and axes
        ODICEModule->>Matplotlib: contourf gas, contour qag_affinity_peaks
        ODICEModule->>Matplotlib: plot markers, labels, title
        alt output_portal exists
            ODICEModule->>output_portal: with output_portal
            output_portal->>Matplotlib: plt.show()
        else output_portal missing
            ODICEModule->>Matplotlib: plt.show()
        end
    end

    ODICEModule->>NotebookKernel: print resolution message
    ODICEModule-->>NotebookKernel: return joined report_lines

    NotebookKernel-->>User: show printed text and visualization
Loading

Updated class diagram for consolidated ODICE notebook helpers and shared output_portal

classDiagram
    class ODICEModule {
        +output_portal Output
        +neo_verification() str
        +cehtr_resolver(plot_results bool, save_only bool) str
        +aa_resolver(plot_results bool) str
    }

    class neo_verification_function {
        -NASA_API_URL str
        -API_KEY str
        -today str
        -report_lines list~str~
        +neo_verification() str
    }

    class cehtr_resolver_function {
        -Omega_m float
        -Omega_L float
        -affinity_base float
        -t_span tuple
        -t_eval ndarray
        -initial_conditions list~float~
        -report_lines list~str~
        +standard_friedmann(t float, y list~float~) list~float~
        +qag_friedmann(t float, y list~float~) list~float~
        +cehtr_resolver(plot_results bool, save_only bool) str
    }

    class aa_resolver_function {
        -X ndarray
        -Y ndarray
        -gas ndarray
        -qag_affinity_peaks ndarray
        -report_lines list~str~
        +qag_lens(xc float, yc float, spread float, alpha float, m float) ndarray
        +aa_resolver(plot_results bool) str
    }

    class OutputPortalManager {
        +output_portal Output
        +ensure_output_portal() Output
        +show_with_portal() void
    }

    class Output {
        +context_manager
    }

    ODICEModule ..> neo_verification_function : uses
    ODICEModule ..> cehtr_resolver_function : uses
    ODICEModule ..> aa_resolver_function : uses
    ODICEModule ..> OutputPortalManager : uses

    OutputPortalManager *-- Output : manages
Loading

File-Level Changes

Change Details Files
Consolidated ODICE helper functions and shared output widget into an early setup cell, enhancing both interactive and VRE/report usage.
  • Replaced a cell’s standalone imports and function definitions with a consolidated block that imports numpy/matplotlib/scipy/requests/etc. plus ipywidgets and IPython.display.clear_output.
  • Introduced a global output_portal ipywidgets.Output instance guarded by a globals() check so the widget is created once and reused.
  • Updated neo_verification to accumulate output in a list, always print the final report string, and also return it for downstream report generation.
  • Updated cehtr_resolver to both print a human-readable header, return a text summary string, and conditionally route plot display via output_portal when available, including a save_only flag that writes plots to disk without showing them.
  • Updated aa_resolver to print a header, route plots through output_portal when available, and return a text summary string while preserving existing visualization styling.
QAG_VerifiedNexus.ipynb
Removed later duplicate definitions of ODICE helpers and redundant output_portal widget creation from VRE-specific sections.
  • Dropped repeated ipywidgets/import display/clear_output imports and local output_portal = widgets.Output() lines from several VRE setup cells, relying on the shared initialization cell instead.
  • Deleted VRE-local redefinitions of neo_verification, cehtr_resolver, and aa_resolver that previously mirrored the same logic, so call sites now use the single consolidated implementations.
QAG_VerifiedNexus.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

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:

  • Consider adding a flag (e.g., verbose / print_output) to neo_verification, cehtr_resolver, and aa_resolver so callers that only need the returned string can suppress printing to stdout, which is useful in non-interactive or batch contexts.
  • For standard_friedmann and qag_friedmann, using multi-line function bodies instead of one-line def ...: return ... definitions would improve readability in this already dense setup cell.
  • Since output_portal is now created conditionally in a global scope, you may want a small helper (e.g., def get_output_portal()) to encapsulate the globals() check and make its usage more explicit and consistent across the notebook.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a flag (e.g., `verbose` / `print_output`) to `neo_verification`, `cehtr_resolver`, and `aa_resolver` so callers that only need the returned string can suppress printing to stdout, which is useful in non-interactive or batch contexts.
- For `standard_friedmann` and `qag_friedmann`, using multi-line function bodies instead of one-line `def ...: return ...` definitions would improve readability in this already dense setup cell.
- Since `output_portal` is now created conditionally in a global scope, you may want a small helper (e.g., `def get_output_portal()`) to encapsulate the `globals()` check and make its usage more explicit and consistent across the notebook.

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.

@Sir-Ripley Sir-Ripley enabled auto-merge March 17, 2026 09:14
@Sir-Ripley Sir-Ripley disabled auto-merge March 17, 2026 09:14
@Sir-Ripley Sir-Ripley merged commit 0c876f5 into gaq2 Mar 17, 2026
5 checks passed
@Sir-Ripley Sir-Ripley deleted the fix-consolidate-neo-verification-1001432498825415985 branch March 17, 2026 18:13
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