Skip to content
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

String-based expression substitution and moar expression tests! #366

Merged
merged 6 commits into from
Sep 6, 2024

Conversation

mlange05
Copy link
Collaborator

This change separates some of the loki.expression tests into separate sub-packages and adds a new SubstituteStringExpressions utility that builds on the recently added parse_expr utility for expression substitution.

The test separation is meant to reduce the size of the general expression test, which is growing slightly out of proportions. I've also added some explicit test of the much used SubstituteExpressions transformer.

Steps in detail:

  • A new loki.expression.test.test_expr_visitors sub-package with some existing tests and new tests for expression substitution; this includes an added test for FindVariables which was previously only covered implicitly (it seems)
  • Separating out the tests of for the new expression parser into loki.expression.tests.test_parser
  • New SubstituteStringExpressions transformer that works pretty much as the SubstituteExpressions but uses parse_expr to use string mapping as input.

Copy link

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

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 99.80952% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.42%. Comparing base (fce5733) to head (ad4b4d8).
Report is 54 commits behind head on main.

Files with missing lines Patch % Lines
loki/expression/tests/test_parser.py 99.77% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #366   +/-   ##
=======================================
  Coverage   95.41%   95.42%           
=======================================
  Files         178      180    +2     
  Lines       37312    37387   +75     
=======================================
+ Hits        35600    35675   +75     
  Misses       1712     1712           
Flag Coverage Δ
lint_rules 96.39% <ø> (ø)
loki 95.40% <99.80%> (+<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.

Copy link
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.

The SubstituteStringExpressions utility is a really nice one! Obviously, loads of ways how someone can use this in dangerous ways, so we need to watch out for this.

The test clean-up and extended explicit coverage is much appreciated!

Good to go from me!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've not gone through this in detail but I'm trusting this is largely just a source move.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is. I tried to be careful here. 😉

"""
fcode = """
module test_mod
use external_mod, only: rick
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
use external_mod, only: rick
use external_mod, only: rick
implicit none

missing also from a few other places in this file, 'cause, wouldn't want to risk Rick letting me down due to implicit typing after all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rick would never tell a lie and hurt you. Fixed now 😉

@reuterbal reuterbal added the ready for merge This PR has been approved and is ready to be merged label Sep 6, 2024
@reuterbal reuterbal merged commit 657fc0f into main Sep 6, 2024
13 checks passed
@reuterbal reuterbal deleted the naml-substitute-expr-string branch September 6, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for 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.

2 participants