Skip to content

Commit

Permalink
some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfhm committed Oct 16, 2023
1 parent 2afa472 commit e68135b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions loki/transform/transform_scalar_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# nor does it submit to any jurisdiction.

from loki.expression import (

Check failure on line 8 in loki/transform/transform_scalar_syntax.py

View workflow job for this annotation

GitHub Actions / code checks (3.11)

W0611: Unused SubstituteExpressions imported from loki.expression (unused-import)
Sum, Product, IntLiteral, Scalar, Array, RangeIndex,
DeferredTypeSymbol, SubstituteExpressions
Sum, Product, IntLiteral, Scalar, Array, RangeIndex,
TypedSymbol, SubstituteExpressions
)
from loki.ir import CallStatement
from loki.visitors import FindNodes, Transformer
Expand All @@ -20,10 +20,19 @@
]

def check_if_scalar_syntax(arg, dummy):
"""
Check if an array argument, arg,
is passed to an array dummy argument, dummy,
using scalar syntax. i.e. arg(1,1) -> d(m,n)
Parameters
----------
arg: variable
dummy: variable
"""
if isinstance(arg, Array) and isinstance(dummy, Array):
if arg.dimensions:
n_dummy_ranges = sum(1 for d in arg.dimensions if isinstance(d, RangeIndex))
if n_dummy_ranges == 0:
if not any(isinstance(d, RangeIndex) for d in arg.dimensions):
return True
return False

Expand All @@ -48,7 +57,7 @@ def merge_parents(parent, symbol):

new_parent = parent.clone()
for p in symbol.parents[1:]:
new_parent = DeferredTypeSymbol(name=p.name_parts[-1], scope=parent.scope, parent=new_parent)
new_parent = TypedSymbol(name=p.name_parts[-1], scope=parent.scope, parent=new_parent)
return symbol.clone(parent=new_parent, scope=parent.scope)


Expand All @@ -61,7 +70,7 @@ def process_symbol(symbol, caller, call):
if symbol in call.routine.arguments:
return call.arg_map[symbol]

elif isinstance(symbol, DeferredTypeSymbol):
elif isinstance(symbol, TypedSymbol):
if symbol.parents[0] in call.routine.arguments:
return merge_parents(call.arg_map[symbol.parents[0]], symbol)

Expand Down

0 comments on commit e68135b

Please sign in to comment.