Skip to content

feat: add flat inverse / Bragg-peak convenience wrappers (#122) - #141

Open
grzanka wants to merge 3 commits into
mainfrom
claude/review-open-prs-issues-fo992b
Open

feat: add flat inverse / Bragg-peak convenience wrappers (#122)#141
grzanka wants to merge 3 commits into
mainfrom
claude/review-open-prs-issues-fo992b

Conversation

@grzanka

@grzanka grzanka commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Add self-contained, re-entrant wrappers to dedx_wrappers.h that manage
workspace and config lifetimes internally, suitable for flat-API consumers
(e.g. JavaScript/WASM) that cannot hold libdedx objects:

  • dedx_get_inverse_csda_simple()
  • dedx_get_inverse_stp_simple()
  • dedx_get_bragg_peak_stp_simple()

Each allocates a fresh workspace per call and sets cfg.ion_a via the
nucleon-number accessor before loading the config.

Bragg-peak support did not previously exist, so add a reusable core
function dedx_get_bragg_peak_stp() to dedx_tools.{h,c} that locates the
stopping-power maximum (reusing the existing peak finder) and returns the
peak mass stopping power.

Add tests/test_wrappers.c covering round-trip inversion of CSDA range and
stopping power, the Bragg-peak value, and the unsupported-combination
error path. All 28 ctest cases pass; clang-format and clang-tidy clean.

claude added 2 commits June 9, 2026 14:13
Add self-contained, re-entrant wrappers to dedx_wrappers.h that manage
workspace and config lifetimes internally, suitable for flat-API consumers
(e.g. JavaScript/WASM) that cannot hold libdedx objects:

  - dedx_get_inverse_csda_simple()
  - dedx_get_inverse_stp_simple()
  - dedx_get_bragg_peak_stp_simple()

Each allocates a fresh workspace per call and sets cfg.ion_a via the
nucleon-number accessor before loading the config.

Bragg-peak support did not previously exist, so add a reusable core
function dedx_get_bragg_peak_stp() to dedx_tools.{h,c} that locates the
stopping-power maximum (reusing the existing peak finder) and returns the
peak mass stopping power.

Add tests/test_wrappers.c covering round-trip inversion of CSDA range and
stopping power, the Bragg-peak value, and the unsupported-combination
error path. All 28 ctest cases pass; clang-format and clang-tidy clean.
The Doxygen claimed "0 = low-energy, 1 = high-energy", but the
implementation treats side < 0 as the low-energy branch and side >= 0
(including 0) as the high-energy branch. Document the actual behavior.
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.29412% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.69%. Comparing base (36990c2) to head (d18911e).

Files with missing lines Patch % Lines
src/dedx_wrappers.c 74.62% 17 Missing ⚠️
src/dedx_tools.c 77.77% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
+ Coverage   72.73%   75.69%   +2.96%     
==========================================
  Files          12       12              
  Lines        1643     1728      +85     
  Branches      300      319      +19     
==========================================
+ Hits         1195     1308     +113     
+ Misses        448      420      -28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds new “flat API” convenience wrappers (workspace/config lifetime managed per call) for inverse CSDA, inverse stopping power, and Bragg-peak stopping power; introduces a reusable core Bragg-peak helper in dedx_tools and corresponding tests.

Changes:

  • Add dedx_get_inverse_csda_simple(), dedx_get_inverse_stp_simple(), and dedx_get_bragg_peak_stp_simple() wrappers in dedx_wrappers.
  • Add core dedx_get_bragg_peak_stp() implementation in dedx_tools.
  • Add tests/test_wrappers.c covering inversion round-trips, Bragg peak value, and an unsupported-combination path.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_wrappers.c New test coverage for the added wrapper APIs (inverse CSDA/STP + Bragg peak + error path).
src/dedx_wrappers.c Implements new one-call wrapper functions allocating/cleaning config+workspace internally.
src/dedx_tools.c Adds core Bragg-peak stopping power helper built on existing peak-finder logic.
include/dedx_wrappers.h Exposes the new wrapper APIs with Doxygen documentation.
include/dedx_tools.h Updates inverse-STP docs and adds Bragg-peak API declaration/docs.

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

Comment thread tests/test_wrappers.c Outdated
Comment thread include/dedx_tools.h Outdated
Comment thread include/dedx_tools.h Outdated
- Assert the exact error code (DEDX_ERR_ION_NOT_SUPPORTED) and -1 return
  for all three flat wrappers on an unsupported combination, instead of
  only checking err != DEDX_OK (Copilot review).
- Clarify the loading preconditions/side effects in the Doxygen for
  dedx_get_inverse_stp() (loads internally) and dedx_get_bragg_peak_stp()
  (auto-loads when not already loaded), which previously claimed the
  configuration must already be loaded (Copilot review).
- Add tests for the low-energy inverse-STP branch, the Bragg-peak core
  helper (success + ion_a guard), and the documented auto-load behavior,
  raising patch coverage above the 70% target.

All 28 ctest cases pass; clang-format and clang-tidy clean.
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