Skip to content

Conversation

@lispandfound
Copy link
Contributor

Fixes a few bugs spotted by the type-checker:

  1. Type checking failures in realisation-to-srf relating to handling Plane and Fault sources,
  2. Incorrect calculation of area in the point-source case,

Copilot AI review requested due to automatic review settings November 20, 2025 21:03
@gemini-code-assist
Copy link

Summary of Changes

Hello @lispandfound, 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 resolves several type-checking errors and a logical bug across various workflow scripts. The changes improve the robustness and accuracy of the workflow by correctly handling different source types during SRF generation, ensuring precise area calculations for point sources, and addressing type compatibility issues with external libraries.

Highlights

  • Type Checking Fixes: Addressed type-checking failures in realisation_to_srf related to handling Plane and Fault sources, ensuring correct attribute access based on source type.
  • Point Source Area Calculation: Corrected the calculation of fault area for point sources in realisation_to_srf to use length * width for accuracy.
  • External Library Type Ignores: Added type: ignore comments for qcore related tobytes() calls in merge_ts.py to resolve current type-checking issues, with a note for future removal.
  • Stage Parent Property Refinement: Updated the Stage.parent property in plan_workflow.py to use deepcopy when creating a parent stage, ensuring proper object state preservation.
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

@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 addresses several type-checking errors and a bug in area calculation. The changes look good overall. In generate_velocity_model_parameters.py and realisation_to_srf.py, the handling of different source types (Fault, Plane, Point) is now more robust, fixing potential AttributeErrors. The correction to the fault area calculation in realisation_to_srf.py for point sources is also a good fix. The addition of type: ignore in merge_ts.py is a reasonable temporary solution for upstream type hint issues. I have one suggestion in plan_workflow.py to use a more idiomatic and efficient way to copy a dataclass instance.

Copilot finished reviewing on behalf of lispandfound November 20, 2025 21:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes type-checking errors in the workflow codebase, specifically addressing issues in SRF generation, velocity model parameter generation, workflow planning, and timeslice merging.

  • Fixed type-checking failures when handling different source types (Fault, Plane, Point) by adding proper isinstance checks and using appropriate properties
  • Corrected the area calculation for point sources from (length_m / 1000) ** 2 to length * width
  • Improved the Stage.parent property implementation to use deepcopy for better maintainability
  • Added type: ignore comments for qcore type annotation issues that will be resolved upstream

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
workflow/scripts/realisation_to_srf.py Added Fault import and isinstance checks to properly handle multi-plane faults vs single planes; fixed point source area calculation to multiply length by width instead of squaring length
workflow/scripts/plan_workflow.py Improved Stage.parent property to use deepcopy instead of manual instantiation for better maintainability
workflow/scripts/merge_ts.py Added type: ignore comments for tobytes() calls pending qcore type annotation updates
workflow/scripts/generate_velocity_model_parameters.py Changed from computing mean dip across fault planes to using fault.dip property directly for type-checker compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lispandfound
Copy link
Contributor Author

lispandfound commented Nov 20, 2025

Failing test case is because of a bug in zarr that I have just opened: zarr-developers/zarr-python#3592

@lispandfound
Copy link
Contributor Author

Type check will fail until my PR to scipy is merged: scipy/scipy-stubs#992

@lispandfound
Copy link
Contributor Author

I've decided to ignore the scipy type bug, with a TODO to remove this after scipy-stubs updates.

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.

3 participants