Skip to content

Inline: fix for edge case mapping unbound dims#667

Merged
reuterbal merged 2 commits intomainfrom
nams_inline_offset_fix
Apr 16, 2026
Merged

Inline: fix for edge case mapping unbound dims#667
reuterbal merged 2 commits intomainfrom
nams_inline_offset_fix

Conversation

@MichaelSt98
Copy link
Copy Markdown
Collaborator

Description

This pull request fixes a bug in how array bounds are remapped when inlining subroutines with mismatched array bounds, and adds a regression test to ensure correct behavior. The most important changes are:

Bug Fix: Array Bound Remapping

  • Updated the _offset_lbound function in procedures.py to correctly handle cases where the dimension is a Range, ensuring that both lower and upper bounds are individually adjusted rather than wrapping the range in a sum. This prevents incorrect expressions like -1 + (1:n) and instead generates the correct range 0:n-1.

Testing: Regression Test for 3-Layer Inlining

  • Added a new test, test_inline_marked_subroutines_3layer_array_offset, in test_procedures.py to verify that after inlining, array bounds are properly remapped in a three-layer call scenario, specifically checking that the bug does not reappear.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@MichaelSt98 MichaelSt98 requested a review from reuterbal April 13, 2026 11:38
@github-actions
Copy link
Copy Markdown

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/667/index.html

@MichaelSt98 MichaelSt98 requested a review from mlange05 April 13, 2026 11:53
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.38%. Comparing base (4e60dae) to head (d7f7de0).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #667   +/-   ##
=======================================
  Coverage   96.38%   96.38%           
=======================================
  Files         267      267           
  Lines       46112    46134   +22     
=======================================
+ Hits        44445    44467   +22     
  Misses       1667     1667           
Flag Coverage Δ
lint_rules 96.40% <ø> (ø)
loki 96.38% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Copy link
Copy Markdown
Collaborator

@mlange05 mlange05 left a comment

Choose a reason for hiding this comment

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

Looks good. 👍 :shipit:

@mlange05 mlange05 added the ready to merge This PR has been approved and is ready to be merged label Apr 16, 2026
@reuterbal reuterbal merged commit f83d6d2 into main Apr 16, 2026
14 checks passed
@reuterbal reuterbal deleted the nams_inline_offset_fix branch April 16, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge This PR has been approved and is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants