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

F2C: optional case-sensitivity for variables/symbols #277

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

MichaelSt98
Copy link
Collaborator

convert_to_lower_case() if not variable/symbol .case_sensitive=True

Imported for things like:

... = threadIdx.x
cudaMalloc(...)

Copy link

github-actions bot commented Apr 8, 2024

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

@reuterbal reuterbal changed the title F2C case-sensitivity for variables/symbols F2C: optional case-sensitivity for variables/symbols Apr 10, 2024
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.

Thanks. That's a good solution to the specific problem.

I think MetaSymbol should derive the case_sensitive value directly from the wrapped symbol. Otherwise this looks good to me.

@@ -492,6 +495,7 @@ class MetaSymbol(StrCompareMixin, pmbl.AlgebraicLeaf):
"""

def __init__(self, symbol, *args, **kwargs):
self.case_sensitive = kwargs.pop('case_sensitive', False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be a property deduced directly from self._symbol?

@property
def case_sensitive(self):
    return self.symbol.case_sensitive

Otherwise you could in principle create inconsistent objects.

@@ -649,8 +653,9 @@ class Scalar(MetaSymbol): # pylint: disable=too-many-ancestors
def __init__(self, name, scope=None, type=None, **kwargs):
# Stop complaints about `type` in this function
# pylint: disable=redefined-builtin
symbol = VariableSymbol(name=name, scope=scope, type=type, **kwargs)
super().__init__(symbol=symbol)
case_sensitive = kwargs.pop('case_sensitive', False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

With case_sensitive derived from symbol, this should be redundant.


def __init__(self, *args, **kwargs):
self.name = kwargs['name']
self.parent = kwargs.pop('parent', None)
self.scope = kwargs.pop('scope', None)
self.case_sensitive = kwargs.pop('case_sensitive', False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although not really used (anymore), the default value should likely be this:

loki/loki/__init__.py

Lines 73 to 74 in dd7ec90

config.register('case-sensitive', False, env_variable='LOKI_CASE_SENSITIVE',
preprocess=lambda i: bool(i) if isinstance(i, int) else i)

@reuterbal reuterbal added rebase required Rebase required for the PR branch to resolve conflicts and removed rebase required Rebase required for the PR branch to resolve conflicts labels Apr 10, 2024
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.

Thanks, looks good to me now!

@reuterbal
Copy link
Collaborator

There seems some test failures after the latest rebase - hold off on merging until this is fixed.

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.95%. Comparing base (6311d46) to head (c3f3f33).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #277   +/-   ##
=======================================
  Coverage   94.94%   94.95%           
=======================================
  Files         153      153           
  Lines       32008    32044   +36     
=======================================
+ Hits        30391    30428   +37     
+ Misses       1617     1616    -1     
Flag Coverage Δ
lint_rules 96.39% <ø> (ø)
loki 95.12% <100.00%> (+<0.01%) ⬆️
transformations 92.11% <ø> (ø)

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.

@reuterbal reuterbal added the ready for merge This PR has been approved and is ready to be merged label Apr 18, 2024
Copy link
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.

Yes, makes sense and looks good. GTG from me. :shipit:

@reuterbal reuterbal merged commit c6d9d84 into main Apr 18, 2024
12 checks passed
@reuterbal reuterbal deleted the nams_f2c_case_sensitive branch April 18, 2024 07:58
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.

3 participants