-
Notifications
You must be signed in to change notification settings - Fork 3
Make assignment replacement with trixi_include
recursive
#54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements recursive assignment replacement for the trixi_include
function, allowing keyword arguments to be passed down through nested trixi_include
calls. This enables overriding variables that are defined in base files when including special files that reference them.
Key changes:
- Added recursive keyword argument passing to nested
trixi_include
calls - Enhanced validation to warn instead of error when assignments are not found in files with nested calls
- Added comprehensive test coverage for recursive assignment scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/trixi_include.jl |
Implements recursive kwarg passing by detecting nested calls and adding missing kwargs, plus enhanced validation with warnings |
test/trixi_include.jl |
Adds extensive test coverage for recursive assignment scenarios including multi-level nesting and various kwarg patterns |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…amework/TrixiBase.jl into ef/recursive-replace-assignment
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
- Coverage 97.27% 92.82% -4.46%
==========================================
Files 5 5
Lines 147 237 +90
==========================================
+ Hits 143 220 +77
- Misses 4 17 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Tests are only failing because of the Coveralls upload. |
Yes, coveralls seems to be down at the moment. I noticed this also in another PR. |
Coveralls is alive again, I reran the tests, and CI is passing now, but code coverage reports that |
Yes. It was never actually tested. It was just covered because before I added |
Ok, but do we need |
AFAIK, it is used by Trixi.jl in the convergence test to read the initial refinement level, which is then increased in each iteration. At least this was the case a while ago. Not sure if it is still used there. |
Good point. Yes, it's still used there. In this case, let's proceed as you suggested and add tests for it in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'd still wait for another review by someone with macro experience before merging...
I have no comments on the macro implementation, but I am generally not a fan of the loss of referential transparency and pushing things through to the lowest-level. I can see a real use-case for a name reuse between recipes, as an example the inner example calculating a reference solution and the outer example using a different solver. Now passing |
Why would you pass |
I think my question to you is "Why do you assume that the name I would rather have something that conveys that I am setting |
I now made the recursive feature optional (disabled by default). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I cannot vouch for the macro implementation, but the explicit intent with its descriptive variable names is a nice touch 🙏
@vchuravy could you please have a look? |
In TrixiParticles.jl, we often define recursive
trixi_include
calls in our example files.We have a base "dam break 2D" file and then more files like "dam break 2D GPU" and "dam break 2D IISPH", which just define a few lines that changed and then use
trixi_include
to include the base file with these changes to avoid duplicate code.This PR allows changing variables defined in the base file when including the special file:
even if
cfl
is not defined in the special file but only in the base file.