-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/277/index.html |
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.
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.
loki/expression/symbols.py
Outdated
@@ -492,6 +495,7 @@ class MetaSymbol(StrCompareMixin, pmbl.AlgebraicLeaf): | |||
""" | |||
|
|||
def __init__(self, symbol, *args, **kwargs): | |||
self.case_sensitive = kwargs.pop('case_sensitive', False) |
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.
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.
loki/expression/symbols.py
Outdated
@@ -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) |
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.
With case_sensitive
derived from symbol
, this should be redundant.
loki/expression/symbols.py
Outdated
|
||
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) |
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.
Although not really used (anymore), the default value should likely be this:
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) |
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.
Thanks, looks good to me now!
There seems some test failures after the latest rebase - hold off on merging until this is fixed. |
9f42681
to
c10eb44
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Yes, makes sense and looks good. GTG from me.
convert_to_lower_case()
if not variable/symbol.case_sensitive=True
Imported for things like: