Conversation
Provides build/test commands, architecture overview, and project-specific naming conventions so future Claude Code sessions can be productive immediately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The C++ binary expects p_source_flag / u{x,y,z}_source_flag to contain
the number of time steps in the source signal (matching legacy
kWaveSimulation.source_p behavior), not just 0/1. Writing a boolean
caused the binary to reject valid HDF5 input files with time-varying
sources.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These fields carry the source signal length, not a boolean — the naming is inherited from the C++ binary's HDF5 API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #698 +/- ##
=======================================
Coverage 74.40% 74.40%
=======================================
Files 56 56
Lines 8026 8026
Branches 1570 1570
=======================================
Hits 5972 5972
Misses 1437 1437
Partials 617 617
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Safer for both 1-D and 2-D source arrays and communicates intent more clearly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
|
@greptile-app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #697.
Greptile Summary
This PR fixes a bug in
CppSimulation._write_hdf5wherep_source_flag,ux_source_flag,uy_source_flag, anduz_source_flagwere written as plain booleans (0or1) instead of the number of time steps the C++ binary actually expects. Without the fix, the C++ solver would always see a count of1regardless of the source signal length, causing incorrect simulations for any source with more than one time step.int(has_p)/int(has_ux)etc. withnp.asarray(source.*).shape[-1], correctly encoding the time-step count.shape[-1]idiom works for both 1-D(Nt,)and 2-D(n_elements, Nt)source arrays, avoiding theTypeErrorthatlen(source.p[0])would raise on a 1-D input.*_source_flagfields, which will help future contributors.Confidence Score: 5/5
Safe to merge — the fix is a targeted correctness patch with no regressions introduced.
The single changed file contains a clearly correct bug fix: source flags now carry the actual time-step count the C++ binary requires. The safer shape[-1] indexing resolves the previously flagged 1-D array edge case. No new code paths, no API changes, and no test regressions are present.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Caller participant CppSimulation participant HDF5 as HDF5 Input File participant Binary as C++ k-Wave Binary Caller->>CppSimulation: run(source, ...) CppSimulation->>CppSimulation: _write_hdf5() Note over CppSimulation: Compute p_source_flag = source.p.shape[-1]<br/>(was: int(has_p) always 1) CppSimulation->>HDF5: write p_source_flag = Nt_source CppSimulation->>HDF5: write ux/uy/uz_source_flag = Nt_source CppSimulation->>HDF5: write p_source_input[n_elements, Nt_source] Binary->>HDF5: read p_source_flag → knows Nt_source time steps Binary->>Binary: simulate for Nt steps using Nt_source-length signalReviews (2): Last reviewed commit: "Merge branch 'master' into fix-cpp-sourc..." | Re-trigger Greptile