Skip to content

Fix C-model post processing and error propagation#502

Open
dodu94 wants to merge 3 commits intodevelopingfrom
fix-C-model-post-processing
Open

Fix C-model post processing and error propagation#502
dodu94 wants to merge 3 commits intodevelopingfrom
fix-C-model-post-processing

Conversation

@dodu94
Copy link
Copy Markdown
Member

@dodu94 dodu94 commented Mar 26, 2026

This PR fixes #493 C-model bugs in the post-processing.

The main change was adjusting the logic used to compute the error propagation in case of percentage comparisons and small touches to the atlas yaml file

Summary by CodeRabbit

  • Bug Fixes
    • Corrected error propagation calculations for absolute and percentage comparisons
  • Documentation
    • Enhanced neutron boundary metric plot labels with explicit state descriptions (uncollided/collided)
  • Tests
    • Updated test data and test configurations for improved coverage

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/jade/post/manipulate_tally.py 96.03% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

Walkthrough

This PR addresses a C-Model post-processing bug by fixing error propagation calculations in the compare_data function (applying absolute value wrapping and correcting numerator terms for percentage errors) and updating plot configurations to use explicit collision state labels instead of numeric suffixes. Related test configurations and expected values are updated accordingly.

Changes

Cohort / File(s) Summary
Error Propagation Logic
src/jade/post/manipulate_tally.py
Fixed compare_data error calculations: wrapped ABSOLUTE case results with np.abs(...) and corrected PERCENTAGE case numerator terms by removing redundant v1 factor before square root. Comment delimiter style also updated from single to double quotes.
Plot Configuration
src/jade/resources/default_cfg/benchmarks_pp/atlas/C-Model.yaml
Updated neutron boundary metric titles and result identifiers to replace numeric suffixes (0/1) with explicit collision state labels (uncollided/collided).
Test Data
tests/dummy_structure/raw_data/_mcnp_-_*/C-Model/metadata.json
Added new metadata file for ENDFB-VIII.0 configuration; updated version and benchmark name fields in existing FENDL 3.2c metadata file.
Test Configuration
tests/post/test_atlas_processor.py, tests/post/test_excel_processor.py
Changed second codelibs entry from ("mcnp", "FENDL 3.2c") to ("mcnp", "ENDFB-VIII.0") in test_C_model test cases.
Test Assertions
tests/post/test_excel_routines.py
Updated expected error calculations in test_compare by removing redundant factors; reformatted multi-line function calls for readability without changing logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

bug

Poem

🐰 With absolute values we now compute,
No phantom errors in the loot!
From zeros-and-ones to labels clear,
The boundary metrics shine bright here! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: fixing C-model post-processing issues and error propagation logic for percentage comparisons, which are the core objectives.
Linked Issues check ✅ Passed The PR addresses issue #493 by fixing error propagation in percentage comparisons (core coding requirement) and updating YAML configuration for proper metric labeling, resolving the reported post-processing and storage issues.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing C-model post-processing: error propagation corrections, YAML metric label updates, test metadata updates, and test adjustments to validate the fixes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-C-model-post-processing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/post/test_excel_routines.py (1)

21-29: Add one case that produces a negative comparison value.

These assertions validate the corrected numerator, but they still never hit the new np.abs(...) path because both non-zero rows have val1 > val2. One val2 > val1 regression case would lock in the non-negative error behavior this PR is fixing, ideally for both PERCENTAGE and ABSOLUTE.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/post/test_excel_routines.py` around lines 21 - 29, Add a test row to
exercise a negative comparison (val2 > val1) so the np.abs(...) branch in
Table._compare is hit: modify the test dataframes (df1/df2) used in this test to
include at least one row where df2 value exceeds df1 value, then add assertions
for both ComparisonType.PERCENTAGE and ComparisonType.ABSOLUTE runs of
Table._compare to verify "Value" is non-negative and "Error" uses the absolute
numerator path; reference Table._compare, ComparisonType.PERCENTAGE,
ComparisonType.ABSOLUTE, and the existing df1/df2/result variables when updating
the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/metadata.json`:
- Line 5: The metadata.json in the _mcnp_-_ENDFB-VIII.0_ fixture has a
mismatched "library" value ("FENDL 3.2c"); update the "library" field in that
metadata.json to the correct ENDF/B identifier (e.g., "ENDF/B-VIII.0" or the
project-standard string used elsewhere) so the fixture name and its "library"
key are consistent; ensure only the "library" value is changed and other
metadata keys remain untouched.

In `@tests/dummy_structure/raw_data/_mcnp_-_FENDL` 3.2c_/C-Model/metadata.json:
- Line 4: The metadata fixture has an inconsistent benchmark_name value
("C_Model") that should match the folder/sibling fixture naming ("C-Model");
update the "benchmark_name" field in the JSON (the key "benchmark_name"
currently set to "C_Model") to "C-Model" so all fixtures use the same normalized
benchmark name.

---

Nitpick comments:
In `@tests/post/test_excel_routines.py`:
- Around line 21-29: Add a test row to exercise a negative comparison (val2 >
val1) so the np.abs(...) branch in Table._compare is hit: modify the test
dataframes (df1/df2) used in this test to include at least one row where df2
value exceeds df1 value, then add assertions for both ComparisonType.PERCENTAGE
and ComparisonType.ABSOLUTE runs of Table._compare to verify "Value" is
non-negative and "Error" uses the absolute numerator path; reference
Table._compare, ComparisonType.PERCENTAGE, ComparisonType.ABSOLUTE, and the
existing df1/df2/result variables when updating the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be3625e1-713e-4fe6-9ad8-a04fa540b0ff

📥 Commits

Reviewing files that changed from the base of the PR and between ba664bd and 5386cb8.

⛔ Files ignored due to path filters (24)
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN BLANKET [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN CENTRAL SOLENOID [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN CORRECTION COILS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN CRYOSTAT [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN DIVERTOR [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN PF COILS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN PORT PLUGS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN TF COILS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN THERMAL SHIELDS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model NUCLEAR HEAT IN VACUUM VESSEL, PORT EXTENSIONS, AND PORT DUCTS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model Neutron current on plasma boundary.csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/C-Model Neutron flux on plasma boundary.csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN BLANKET [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN CENTRAL SOLENOID [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN CORRECTION COILS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN CRYOSTAT [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN DIVERTOR [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN PF COILS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN PORT PLUGS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN TF COILS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN THERMAL SHIELDS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model NUCLEAR HEAT IN VACUUM VESSEL, PORT EXTENSIONS, AND PORT DUCTS [W].csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model Neutron current on plasma boundary.csv is excluded by !**/*.csv
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/C-Model Neutron flux on plasma boundary.csv is excluded by !**/*.csv
📒 Files selected for processing (7)
  • src/jade/post/manipulate_tally.py
  • src/jade/resources/default_cfg/benchmarks_pp/atlas/C-Model.yaml
  • tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/metadata.json
  • tests/dummy_structure/raw_data/_mcnp_-_FENDL 3.2c_/C-Model/metadata.json
  • tests/post/test_atlas_processor.py
  • tests/post/test_excel_processor.py
  • tests/post/test_excel_routines.py

"benchmark_name": "C-Model",
"benchmark_version": "1.0",
"jade_run_version": "3.1.0",
"library": "FENDL 3.2c",
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.

⚠️ Potential issue | 🟡 Minor

Fix library metadata mismatch in ENDFB fixture.

Line 5 currently sets "library": "FENDL 3.2c" inside the .../_mcnp_-_ENDFB-VIII.0_/... fixture. This makes the test metadata inconsistent and misleading for metadata readers.

Proposed fix
-    "library": "FENDL 3.2c",
+    "library": "ENDFB-VIII.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"library": "FENDL 3.2c",
"library": "ENDFB-VIII.0",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/dummy_structure/raw_data/_mcnp_-_ENDFB-VIII.0_/C-Model/metadata.json`
at line 5, The metadata.json in the _mcnp_-_ENDFB-VIII.0_ fixture has a
mismatched "library" value ("FENDL 3.2c"); update the "library" field in that
metadata.json to the correct ENDF/B identifier (e.g., "ENDF/B-VIII.0" or the
project-standard string used elsewhere) so the fixture name and its "library"
key are consistent; ensure only the "library" value is changed and other
metadata keys remain untouched.

"benchmark_version": "1.0",
"jade_run_version": "3.1.0",
"jade_run_version": "3.0.1",
"benchmark_name": "C_Model",
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.

⚠️ Potential issue | 🟡 Minor

Normalize benchmark naming across C-Model metadata fixtures.

Line 4 uses "benchmark_name": "C_Model" while the benchmark folder and sibling fixture use "C-Model". This inconsistency can produce confusing metadata outputs during tests.

Proposed fix
-    "benchmark_name": "C_Model",
+    "benchmark_name": "C-Model",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"benchmark_name": "C_Model",
"benchmark_name": "C-Model",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/dummy_structure/raw_data/_mcnp_-_FENDL` 3.2c_/C-Model/metadata.json at
line 4, The metadata fixture has an inconsistent benchmark_name value
("C_Model") that should match the folder/sibling fixture naming ("C-Model");
update the "benchmark_name" field in the JSON (the key "benchmark_name"
currently set to "C_Model") to "C-Model" so all fixtures use the same normalized
benchmark name.

@dodu94 dodu94 requested a review from alexvalentine94 March 26, 2026 15:06
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.

[BUG] - C-Model post-processing issue

1 participant