Conversation
Summary of ChangesHello, 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 addresses a runtime issue in the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Pull request overview
Removes runtime assert isinstance(...) checks in gcmt-to-realisation that were failing when values are np.float64, allowing GCMT CSV-derived nodal-plane values to flow through without hard type assertions.
Changes:
- Removed six
isinstance(..., float | int)asserts for strike/dip/rake values read from the published GCMT CSV.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert isinstance(dip2, float | int) | ||
| assert isinstance(rake2, float | int) | ||
| nodal_plane_1 = NodalPlane(strike1, dip1, rake1) | ||
| nodal_plane_2 = NodalPlane(strike2, rake2, dip2) |
There was a problem hiding this comment.
nodal_plane_2 is constructed with arguments in a different order than nodal_plane_1 (and likely the NodalPlane API). Here it passes (strike2, rake2, dip2), which swaps dip and rake and will produce an incorrect nodal plane; use the same (strike, dip, rake) ordering as for plane 1 (and as implied by NodalPlane(**solution["nodalPlanes"][1])).
| nodal_plane_2 = NodalPlane(strike2, rake2, dip2) | |
| nodal_plane_2 = NodalPlane(strike2, dip2, rake2) |
| assert isinstance(strike2, float | int) | ||
| assert isinstance(dip2, float | int) | ||
| assert isinstance(rake2, float | int) | ||
| nodal_plane_1 = NodalPlane(strike1, dip1, rake1) |
There was a problem hiding this comment.
This PR removes type asserts for strike/dip/rake because pandas returns np.float64, but there are still asserts later in this function (assert isinstance(magnitude, float) and assert isinstance(centroid_depth, float)) that will also fail for np.float64 (and potentially int). Consider removing these asserts too, or replacing them with a numbers.Real/np.floating check or explicit float(...) conversion at the point of use.
There was a problem hiding this comment.
Code Review
This pull request removes several assert statements that were causing issues due to type mismatches with numpy data types. While this fixes the immediate problem, it also removes valuable type validation. My review suggests reintroducing these assertions with a more robust type check that accommodates numpy's numeric types, ensuring both correctness and robustness without causing crashes.
I am having trouble creating individual review comments. Click here to see my feedback.
workflow/scripts/gcmt_to_realisation.py (174-179)
While these assertions were failing due to np.float64 types, removing them entirely eliminates important type validation. This could lead to unexpected errors downstream if the data is not numeric. A better approach is to modify the assertions to correctly handle numpy's numeric types. You can include np.number in the type check, which is a base type for numpy's numeric scalars.
assert isinstance(strike1, (int, float, np.number))
assert isinstance(dip1, (int, float, np.number))
assert isinstance(rake1, (int, float, np.number))
assert isinstance(strike2, (int, float, np.number))
assert isinstance(dip2, (int, float, np.number))
assert isinstance(rake2, (int, float, np.number))
These assert statements were breaking
gcmt-to-realisationbecause the values had typenp.float64not float, so I have removed the assertions