Skip to content
Snippets Groups Projects
Commit 3cb194c5 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Deprecate map_param. Fix test suite

parent f0d11ee2
No related branches found
No related tags found
No related merge requests found
Pipeline #69677 passed
...@@ -468,8 +468,14 @@ class SfgBasicComposer(SfgIComposer): ...@@ -468,8 +468,14 @@ class SfgBasicComposer(SfgIComposer):
depends: VarLike | Sequence[VarLike], depends: VarLike | Sequence[VarLike],
mapping: str, mapping: str,
): ):
"""Arbitrary parameter mapping: Add a single line of code to define a left-hand from warnings import warn
side object from one or multiple right-hand side dependencies."""
warn(
"The `map_param` method of `SfgBasicComposer` is deprecated and will be removed "
"in a future version. Use `sfg.set_param` instead.",
FutureWarning,
)
if isinstance(depends, _VarLike): if isinstance(depends, _VarLike):
depends = [depends] depends = [depends]
lhs_var: SfgVar | sp.Symbol = ( lhs_var: SfgVar | sp.Symbol = (
...@@ -508,37 +514,37 @@ def make_sequence(*args: SequencerArg) -> SfgSequence: ...@@ -508,37 +514,37 @@ def make_sequence(*args: SequencerArg) -> SfgSequence:
- Sub-ASTs and AST builders, which are often produced by the syntactic sugar and - Sub-ASTs and AST builders, which are often produced by the syntactic sugar and
factory methods of `SfgComposer`. factory methods of `SfgComposer`.
Its usage is best shown by example: :Example:
.. code-block:: Python .. code-block:: Python
tree = make_sequence( tree = make_sequence(
"int a = 0;", "int a = 0;",
"int b = 1;", "int b = 1;",
( (
"int tmp = b;", "int tmp = b;",
"b = a;", "b = a;",
"a = tmp;" "a = tmp;"
), ),
SfgKernelCall(kernel_handle) SfgKernelCall(kernel_handle)
) )
sfg.context.add_function("myFunction", tree) sfg.context.add_function("myFunction", tree)
will translate to will translate to
.. code-block:: C++ .. code-block:: C++
void myFunction() { void myFunction() {
int a = 0; int a = 0;
int b = 0; int b = 0;
{ {
int tmp = b; int tmp = b;
b = a; b = a;
a = tmp; a = tmp;
}
kernels::kernel( ... );
} }
kernels::kernel( ... );
}
""" """
children = [] children = []
for i, arg in enumerate(args): for i, arg in enumerate(args):
......
...@@ -288,8 +288,9 @@ def asvar(var: VarLike) -> SfgVar: ...@@ -288,8 +288,9 @@ def asvar(var: VarLike) -> SfgVar:
SfgVar: Variable cast as `SfgVar`. SfgVar: Variable cast as `SfgVar`.
Raises: Raises:
SfgException: If given a non-variable `AugExpr`, or a `TypedSymbol` with a `DynamicType` ValueError: If given a non-variable `AugExpr`,
ValueError: If given any non-variable-like object. a `TypedSymbol` with a `DynamicType`,
or any non-variable-like object.
""" """
match var: match var:
case SfgVar(): case SfgVar():
...@@ -300,7 +301,7 @@ def asvar(var: VarLike) -> SfgVar: ...@@ -300,7 +301,7 @@ def asvar(var: VarLike) -> SfgVar:
from pystencils import DynamicType from pystencils import DynamicType
if isinstance(var.dtype, DynamicType): if isinstance(var.dtype, DynamicType):
raise SfgException( raise ValueError(
f"Unable to cast dynamically typed symbol {var} to a variable.\n" f"Unable to cast dynamically typed symbol {var} to a variable.\n"
f"{var} has dynamic type {var.dtype}, which cannot be resolved to a type outside of a kernel." f"{var} has dynamic type {var.dtype}, which cannot be resolved to a type outside of a kernel."
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment